]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Require --no-dynamic-linker with -static -E/--dynamic-list
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 21 Apr 2017 19:00:55 +0000 (12:00 -0700)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 27 Apr 2017 15:52:58 +0000 (12:52 -0300)
When -static -E/--dynamic-list are passed to linker, linker may create
executable with dynamic sections which aren't supported by run-time.
We require --no-dynamic-linker together with -static -E/--dynamic-list
before adding dynamic symbol table to static executable.

bfd/

PR ld/19617
PR ld/21086
* elflink.c (elf_link_add_object_symbols): Require
--no-dynamic-linker with -E/--dynamic-list when creating
dynamic sections.

ld/

PR ld/19617
PR ld/21086
* testsuite/ld-elf/pr19617a.d: Pass --no-dynamic-linker to ld.
* testsuite/ld-elf/pr19617b.d: Likewise.
* testsuite/ld-elf/pr19617c.d: Likewise.
*testsuite/ld-i386/pr19636-4d.d: Likewise.
* testsuite/ld-elf/readelf.exp: Pass --no-dynamic-linker to ld
with --export-dynamic.
* testsuite/ld-elf/shared.exp: Pass --no-dynamic-linker to ld
with -E.

Cherry-pick of 3c5fce9bc29b216af7d10f8d6e4d8c3f11a48359.

Change-Id: Ia85dd5cd783d60a63164ae34ea096d73806b9987

bfd/ChangeLog.linaro
bfd/elflink.c
ld/ChangeLog.linaro [new file with mode: 0644]
ld/testsuite/ld-elf/pr19617a.d
ld/testsuite/ld-elf/pr19617b.d
ld/testsuite/ld-elf/pr19617c.d
ld/testsuite/ld-elf/pr21086.c [new file with mode: 0644]
ld/testsuite/ld-elf/pr21086.list [new file with mode: 0644]
ld/testsuite/ld-i386/pr19636-4d.d

index 56e1de759fc075268ec356564215fe62f17554ae..c5d711785ff3aef790c646ace10a08244394dc90 100644 (file)
@@ -1,3 +1,14 @@
+2017-04-27  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+       Backport from mainline:
+       2017-04-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19617
+       PR ld/21086
+       * elflink.c (elf_link_add_object_symbols): Require
+       --no-dynamic-linker with -E/--dynamic-list when creating
+       dynamic sections.
+
 2016-09-15  Christophe Lyon  <christophe.lyon@linaro.org>
 
        Backport from mainline:
@@ -5,4 +16,3 @@
 
        * elf32-arm.c (elf32_arm_count_additional_relocs): Return zero if
        there is no arm data associated with the section.
-
index 3e249400f67f75f492c1a7f72b811965aa39995c..c6b69929c6f9cc3f37866534e9b732d5290b7bfb 100644 (file)
@@ -3750,6 +3750,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
       if (!just_syms
          && (bfd_link_pic (info)
              || (!bfd_link_relocatable (info)
+                 && info->nointerp
                  && (info->export_dynamic || info->dynamic)))
          && is_elf_hash_table (htab)
          && info->output_bfd->xvec == abfd->xvec
diff --git a/ld/ChangeLog.linaro b/ld/ChangeLog.linaro
new file mode 100644 (file)
index 0000000..65f006d
--- /dev/null
@@ -0,0 +1,11 @@
+2017-04-27  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+       Backport from mainline:
+       2017-04-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19617
+       PR ld/21086
+       * testsuite/ld-elf/pr19617a.d: Pass --no-dynamic-linker to ld.
+       * testsuite/ld-elf/pr19617b.d: Likewise.
+       * testsuite/ld-elf/pr19617c.d: Likewise.
+       *testsuite/ld-i386/pr19636-4d.d: Likewise.
index 784aacb940ba8828380cb5903768f46b59da0f1f..132021fbb55e91b8148e84caafb626287116abc1 100644 (file)
@@ -1,5 +1,5 @@
 #source: pr19617.s
-#ld: -E
+#ld: -E --no-dynamic-linker
 #readelf : --dyn-syms --wide
 #target: *-*-linux* *-*-gnu* *-*-solaris*
 
index e1dcb714383fc45a0c30a22b758c931286d1e7b4..4d1886f2bd6913e6ff6cc0f267c4a7b2121efcd4 100644 (file)
@@ -1,5 +1,5 @@
 #source: pr19617.s
-#ld: --dynamic-list-data
+#ld: --dynamic-list-data --no-dynamic-linker
 #readelf : --dyn-syms --wide
 #target: *-*-linux* *-*-gnu* *-*-solaris*
 
index 00e2e7e2bbb1b8381396a5ba876789308359afb6..9ac8fc1941fce067b2ec0f47625c461c5cd1becc 100644 (file)
@@ -1,5 +1,5 @@
 #source: pr19617.s
-#ld: --dynamic-list-data
+#ld: --dynamic-list-data --no-dynamic-linker
 #readelf : --dyn-syms --wide
 #target: *-*-linux* *-*-gnu* *-*-solaris*
 
diff --git a/ld/testsuite/ld-elf/pr21086.c b/ld/testsuite/ld-elf/pr21086.c
new file mode 100644 (file)
index 0000000..8fb892c
--- /dev/null
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int
+main ()
+{
+  printf ("PASS\n");
+  return 0;
+}
diff --git a/ld/testsuite/ld-elf/pr21086.list b/ld/testsuite/ld-elf/pr21086.list
new file mode 100644 (file)
index 0000000..a4e712f
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  main;
+};
index a9487f0be64558ed771d50e2abe833abc06ec0cf..e3db60989299443356a14b594683dc866318c1bf 100644 (file)
@@ -1,6 +1,6 @@
 #source: pr19636-4.s
 #as: --32
-#ld: -E --defsym foobar=0x100 -m elf_i386
+#ld: -E --defsym foobar=0x100 -m elf_i386 --no-dynamic-linker
 #readelf : --dyn-syms --wide
 
 Symbol table '\.dynsym' contains [0-9]+ entries: