diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-04-25 10:51:39 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-05-04 16:26:51 -0700 |
commit | da422fa49d508e33b8f1b2bd9b8f719b831b199b (patch) | |
tree | 197586145f0c372bad5abda8d2032fd9eaf6db63 /ld/testsuite/ld-plugin | |
parent | 40ae4abe44fa4e0a53d1681bc48adf445df25822 (diff) | |
download | gdb-da422fa49d508e33b8f1b2bd9b8f719b831b199b.zip gdb-da422fa49d508e33b8f1b2bd9b8f719b831b199b.tar.gz gdb-da422fa49d508e33b8f1b2bd9b8f719b831b199b.tar.bz2 |
LTO: Handle __real_SYM reference in IR
When an IR symbol SYM is referenced in IR via __real_SYM, its resolution
should be LDPR_PREVAILING_DEF, not PREVAILING_DEF_IRONLY, since LTO
doesn't know that __real_SYM should be resolved by SYM.
bfd/
PR ld/29086
* linker.c (bfd_wrapped_link_hash_lookup): Mark SYM is referenced
via __real_SYM.
include/
PR ld/29086
* bfdlink.h (bfd_link_hash_entry): Add ref_real.
ld/
PR ld/29086
* plugin.c (get_symbols): Resolve SYM definition to
LDPR_PREVAILING_DEF for __real_SYM reference.
* testsuite/ld-plugin/lto.exp: Run PR ld/29086 test.
* testsuite/ld-plugin/pr29086.c: New file.
Diffstat (limited to 'ld/testsuite/ld-plugin')
-rw-r--r-- | ld/testsuite/ld-plugin/lto.exp | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr29086.c | 19 |
2 files changed, 27 insertions, 0 deletions
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index f4ea1d4..4e8e2dc 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -522,6 +522,14 @@ set lto_link_elf_tests [list \ {{"nm" {-D} "pr28849.d"}} \ "pr28849" \ ] \ + [list \ + "PR ld/pr29086" \ + "-Wl,--wrap=foo" \ + "-O0 -flto" \ + {pr29086.c} \ + {} \ + "pr29086" \ + ] \ ] # PR 14918 checks that libgcc is not spuriously included in a shared link of diff --git a/ld/testsuite/ld-plugin/pr29086.c b/ld/testsuite/ld-plugin/pr29086.c new file mode 100644 index 0000000..d333d68 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr29086.c @@ -0,0 +1,19 @@ +int +foo (void) +{ + return 0; +} + +int +main () +{ + return foo (); +} + +extern int __real_foo (void); + +int +__wrap_foo (void) +{ + return __real_foo (); +} |