SHA256
1
0
forked from pool/binutils
binutils/binutils-skip-rpaths.patch
Richard Biener 32d9ceffd6 - Remove empty rpath component removal optimization from
binutils-skip-rpaths.patch to workaround CMake rpath handling.
  [boo#1025282]

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/binutils?expand=0&rev=236
2017-03-30 11:17:57 +00:00

117 lines
3.2 KiB
Diff

Index: ld/emultempl/elf32.em
===================================================================
--- ld/emultempl/elf32.em.orig 2017-03-02 09:23:54.000000000 +0100
+++ ld/emultempl/elf32.em 2017-03-30 13:06:06.406399958 +0200
@@ -1581,8 +1581,35 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" !=
else
ELF_INTERPRETER_SET_DEFAULT=
fi
+
+ libpath_nl=`echo ${NATIVE_LIB_DIRS// /\\\n}`
fragment <<EOF
+static int
+gld${EMULATION_NAME}_is_contained (const char *path, const char *dc)
+{
+ while (*dc)
+ {
+ const char *pc = path;
+
+ while (*dc && *pc && *dc == *pc && *dc != '\n'
+ && *pc != ':' && *dc != '=')
+ {
+ dc++;
+ pc++;
+ }
+ if ((*pc == 0 || *pc == ':') && (*dc == '\n' || *dc == '=' || *dc == 0))
+ return 1;
+
+ while (*dc && *dc != '\n')
+ dc++;
+ if (*dc == '\n')
+ dc++;
+ }
+
+ return 0;
+}
+
/* used by before_allocation and handle_option. */
static void
gld${EMULATION_NAME}_append_to_separated_string (char **to, char *op_arg)
@@ -1634,7 +1661,7 @@ static struct bfd_link_hash_entry ehdr_s
static void
gld${EMULATION_NAME}_before_allocation (void)
{
- const char *rpath;
+ char *rpath;
asection *sinterp;
bfd *abfd;
struct elf_link_hash_entry *ehdr_start = NULL;
@@ -1691,7 +1718,65 @@ gld${EMULATION_NAME}_before_allocation (
by dynamic linking. */
rpath = command_line.rpath;
if (rpath == NULL)
- rpath = (const char *) getenv ("LD_RUN_PATH");
+ rpath = getenv ("LD_RUN_PATH");
+
+ if (rpath != NULL && getenv ("SUSE_IGNORED_RPATHS"))
+ {
+ char *dirs = 0;
+ FILE *ldso = fopen (getenv ("SUSE_IGNORED_RPATHS"), "r");
+ if (ldso)
+ {
+ off_t endcur = 0;
+ fseek (ldso, 0, SEEK_END);
+ endcur = ftell (ldso);
+ fseek (ldso, 0, SEEK_SET);
+ dirs = xmalloc (endcur);
+ if (fread (dirs, 1, endcur, ldso) != (size_t) endcur)
+ {
+ free (dirs);
+ dirs = NULL;
+ }
+ }
+ if (dirs)
+ {
+ char *cr;
+ rpath = xstrdup (rpath);
+ cr = rpath; /* cursor read */
+
+ while (*cr)
+ {
+ if (gld${EMULATION_NAME}_is_contained (cr, dirs)
+ || gld${EMULATION_NAME}_is_contained (cr, "$libpath_nl"))
+ {
+ char *cc = cr, *cw = cr;
+ while (*cc && *cc != ':')
+ cc++;
+ if (*cc == ':')
+ {
+ cc++;
+ for (; *cc; cc++, cw++)
+ *cw = *cc;
+ }
+ else if (cw > rpath)
+ cw[-1] = 0;
+
+ *cw = 0;
+ }
+ else
+ {
+ while (*cr && *cr != ':')
+ cr++;
+ if (*cr == ':')
+ cr++;
+ }
+ }
+ if (*rpath == '\0')
+ {
+ free (rpath);
+ rpath = NULL;
+ }
+ }
+ }
for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)