aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-10-12 13:19:10 +1030
committerAlan Modra <amodra@gmail.com>2017-10-12 14:37:11 +1030
commit22b1ee183d19a92cc57859c04307d31c06792d13 (patch)
tree0f467fdbb2a7a7453b0d02b19018d506f1439892 /ld
parent559192d89d743834951fc386530c6bc7f89b358d (diff)
downloadgdb-22b1ee183d19a92cc57859c04307d31c06792d13.zip
gdb-22b1ee183d19a92cc57859c04307d31c06792d13.tar.gz
gdb-22b1ee183d19a92cc57859c04307d31c06792d13.tar.bz2
Set dynamic_undefined_weak to zero for static PIEs
I believe we should be warning if ld is given both --no-dynamic-linker and -z dynamic-undefined-weak. The two options are contradictory, the first says an executable has no dynamic interpreter to resolve dynamic symbols, while the second is asking for dynamic symbols to be emitted. (And even if a static PIE's relocation code, which is needed to process R_*_RELATIVE relocs, could process symbols, there are no DT_NEEDED dynamic objects to define such symbols.) I also think that dynamic_undefined_weak is the right flag to control whether undefined weaks are made dynamic, whether in static PIEs or anywhere else. So force it to 0 for static PIEs, fixing PR 22269 for powerpc and any other target where the backend usually defaults to undefined weaks being made dynamic. This patch introduces regressions. I'd normally not do that, but these are all in very recently added test cases, or expose bugs in the x86 backend. The test cases were added after I'd made it known that this patch or one like it was imminent. PR 22269 * emultempl/elf32.em (after_parse): Warn on --no-dynamic-linker -z dynamic-undefined-weak combination. Set dynamic_undefined_weak to zero when nointerp.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/emultempl/elf32.em7
2 files changed, 14 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 0ae8134..1331a7b 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,12 @@
2017-10-12 Alan Modra <amodra@gmail.com>
+ PR 22269
+ * emultempl/elf32.em (after_parse): Warn on --no-dynamic-linker
+ -z dynamic-undefined-weak combination. Set dynamic_undefined_weak
+ to zero when nointerp.
+
+2017-10-12 Alan Modra <amodra@gmail.com>
+
* emultempl/elf32.em (before_allocation): Call
elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol.
Formatting.
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index e6cf968..8737376 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -120,6 +120,13 @@ gld${EMULATION_NAME}_after_parse (void)
if (bfd_link_pie (&link_info))
link_info.flags_1 |= (bfd_vma) DF_1_PIE;
+ if (bfd_link_executable (&link_info)
+ && link_info.nointerp)
+ {
+ if (link_info.dynamic_undefined_weak > 0)
+ einfo (_("%P: warning: -z dynamic-undefined-weak ignored\n"));
+ link_info.dynamic_undefined_weak = 0;
+ }
after_parse_default ();
}