diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-02-02 14:40:03 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-03-09 18:23:43 -0800 |
commit | 320fdefef139160c93089a19ba41a2fcc4121203 (patch) | |
tree | d845e8df9ccc432cfb3d06d97cb6d2082a78da93 /ld/testsuite | |
parent | 399f9ba236fa8026ca8115cb030ee87a1408ce8b (diff) | |
download | gdb-320fdefef139160c93089a19ba41a2fcc4121203.zip gdb-320fdefef139160c93089a19ba41a2fcc4121203.tar.gz gdb-320fdefef139160c93089a19ba41a2fcc4121203.tar.bz2 |
ld: Add a before_plugin_all_symbols_read hook
Add a before_plugin_all_symbols_read hook to load symbol references from
DT_NEEDED entries, included from --copy-dt-needed-entries, before reading
plugin symbols to properly resolve plugin symbol references.
bfd/
PR ld/28849
* elf-bfd.h (elf_link_hash_table): Add handling_dt_needed.
* elflink.c (_bfd_elf_merge_symbol): Don't set non_ir_ref_dynamic
before plugin 'all symbols read' hook is called.
ld/
PR ld/28849
* ldelf.c (ldelf_handle_dt_needed): New function.
(ldelf_before_plugin_all_symbols_read): Likewise.
(ldelf_after_open): Call ldelf_handle_dt_needed.
* ldelf.h (ldelf_before_plugin_all_symbols_read): New.
* ldemul.c (ldemul_before_plugin_all_symbols_read): Likewise.
* ldemul.h (ldemul_before_plugin_all_symbols_read): Likewise.
(ld_emulation_xfer_struct): Add before_plugin_all_symbols_read.
* ldlang.c (lang_process): Call
ldemul_before_plugin_all_symbols_read before calling
plugin_call_all_symbols_read.
* emultempl/elf.em
(gld${EMULATION_NAME}_before_plugin_all_symbols_read): New.
(LDEMUL_BEFORE_PLUGIN_ALL_SYMBOLS_READ): New.
* emultempl/emulation.em (ld_${EMULATION_NAME}_emulation):
Initialize the before_plugin_all_symbols_read field.
* testsuite/ld-plugin/lto.exp: Run PR ld/28849 tests.
* testsuite/ld-plugin/pr28849.d: New file.
* testsuite/ld-plugin/pr28849a.c: Likewise.
* testsuite/ld-plugin/pr28849b.c: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-plugin/lto.exp | 25 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr28849.d | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr28849a.c | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr28849b.c | 3 |
4 files changed, 33 insertions, 0 deletions
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index 64b8802..f4ea1d4 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -497,6 +497,31 @@ set lto_link_elf_tests [list \ "pr28879" \ "c++" \ ] \ + [list \ + "Build libpr28849a.so" \ + "-shared" \ + "-fPIC" \ + {pr28849a.c} \ + "" \ + "libpr28849a.so" \ + ] \ + [list \ + "Build libpr28849b.so" \ + "-shared -Wl,--no-as-needed,tmpdir/libpr28849a.so" \ + "" \ + {dummy.c} \ + "" \ + "libpr28849b.so" \ + ] \ + [list \ + "Build pr28849" \ + "-Wl,--no-as-needed,--copy-dt-needed-entries,-rpath-link,. \ + tmpdir/libpr28849b.so" \ + "-O2 -flto" \ + {pr28849b.c} \ + {{"nm" {-D} "pr28849.d"}} \ + "pr28849" \ + ] \ ] # PR 14918 checks that libgcc is not spuriously included in a shared link of diff --git a/ld/testsuite/ld-plugin/pr28849.d b/ld/testsuite/ld-plugin/pr28849.d new file mode 100644 index 0000000..a1f90c1 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr28849.d @@ -0,0 +1,3 @@ +#... +[0-9a-f]+ T _?should_be_dynamic_in_exec +#pass diff --git a/ld/testsuite/ld-plugin/pr28849a.c b/ld/testsuite/ld-plugin/pr28849a.c new file mode 100644 index 0000000..2fc5c7b --- /dev/null +++ b/ld/testsuite/ld-plugin/pr28849a.c @@ -0,0 +1,2 @@ +extern void should_be_dynamic_in_exec (void); +void y (void) { should_be_dynamic_in_exec (); } diff --git a/ld/testsuite/ld-plugin/pr28849b.c b/ld/testsuite/ld-plugin/pr28849b.c new file mode 100644 index 0000000..616d9a5 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr28849b.c @@ -0,0 +1,3 @@ +extern void y (void); +void should_be_dynamic_in_exec (void) {} +int main (void) { y (); return 0; } |