SHA256
1
0
forked from pool/binutils
binutils/binutils-skip-rpaths.patch
Michael Matz 7678d731bf Accepting request 774884 from home:marxin:branches:devel:gcc-clean
- Update to binutils 2.34:
  * The disassembler (objdump --disassemble) now has an option to
    generate ascii art thats show the arcs between that start and end
    points of control flow instructions.
  * The binutils tools now have support for debuginfod.  Debuginfod is a 
    HTTP service for distributing ELF/DWARF debugging information as
    well as source code.  The tools can now connect to debuginfod
    servers in order to download debug information about the files that
    they are processing.
  * The assembler and linker now support the generation of ELF format
    files for the Z80 architecture.
- Rename and get binutils-2.34-branch.diff.gz (boo#1160254).
- Rebase add-ulp-section.diff, binutils-revert-plt32-in-branches.diff,
  cross-avr-size.patch and binutils-skip-rpaths.patch.
- Add new subpackages for libctf and libctf-nobfd.
- Disable LTO due to boo#1163333.
- Includes fixes for these CVEs:
  bnc#1153768 aka CVE-2019-17451 aka PR25070
  bnc#1153770 aka CVE-2019-17450 aka PR25078

OBS-URL: https://build.opensuse.org/request/show/774884
OBS-URL: https://build.opensuse.org/package/show/devel:gcc/binutils?expand=0&rev=331
2020-02-17 14:18:06 +00:00

126 lines
3.4 KiB
Diff

diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
index 42c552b36e..dd0a6b1e60 100644
--- a/ld/emultempl/elf.em
+++ b/ld/emultempl/elf.em
@@ -135,6 +135,8 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation;
if test x"${ELF_INTERPRETER_NAME}" = x; then
ELF_INTERPRETER_NAME=NULL
fi
+
+ libpath_nl=`echo ${NATIVE_LIB_DIRS// /\\\n}`
fragment <<EOF
/* This is called after the sections have been attached to output
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 2e27cf48a8..7162d0cf91 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1506,6 +1506,31 @@ ldelf_append_to_separated_string (char **to, char *op_arg)
}
}
+static int
+ldelf_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;
+}
+
/* This is called after the sections have been attached to output
sections, but before any sizes or addresses have been set. */
@@ -1513,7 +1538,7 @@ void
ldelf_before_allocation (char *audit, char *depaudit,
const char *default_interpreter_name)
{
- const char *rpath;
+ char *rpath;
asection *sinterp;
bfd *abfd;
struct bfd_link_hash_entry *ehdr_start = NULL;
@@ -1572,7 +1597,65 @@ ldelf_before_allocation (char *audit, char *depaudit,
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 (ldelf_is_contained (cr, dirs)
+ || ldelf_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)