mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-16 23:06:48 +08:00
ld: Change indirect symbol from IR to undefined
bfd/ PR ld/28264 * elflink.c (_bfd_elf_merge_symbol): Change indirect symbol from IR to undefined. ld/ PR ld/28264 * testsuite/ld-plugin/lto.exp: Run PR ld/28264 test. * testsuite/ld-plugin/pr28264-1.d: New file. * testsuite/ld-plugin/pr28264-2.d: Likewise. * testsuite/ld-plugin/pr28264-3.d: Likewise. * testsuite/ld-plugin/pr28264-4.d: Likewise. * testsuite/ld-plugin/pr28264.c: Likewise. * testsuite/ld-plugin/pr28264.ver: Likewise.
This commit is contained in:
@ -1272,14 +1272,25 @@ _bfd_elf_merge_symbol (bfd *abfd,
|
|||||||
olddyn = (oldsec->symbol->flags & BSF_DYNAMIC) != 0;
|
olddyn = (oldsec->symbol->flags & BSF_DYNAMIC) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle a case where plugin_notice won't be called and thus won't
|
|
||||||
set the non_ir_ref flags on the first pass over symbols. */
|
|
||||||
if (oldbfd != NULL
|
if (oldbfd != NULL
|
||||||
&& (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN)
|
&& (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN))
|
||||||
&& newdyn != olddyn)
|
|
||||||
{
|
{
|
||||||
h->root.non_ir_ref_dynamic = true;
|
if (newdyn != olddyn)
|
||||||
hi->root.non_ir_ref_dynamic = true;
|
{
|
||||||
|
/* Handle a case where plugin_notice won't be called and thus
|
||||||
|
won't set the non_ir_ref flags on the first pass over
|
||||||
|
symbols. */
|
||||||
|
h->root.non_ir_ref_dynamic = true;
|
||||||
|
hi->root.non_ir_ref_dynamic = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((oldbfd->flags & BFD_PLUGIN) != 0
|
||||||
|
&& hi->root.type == bfd_link_hash_indirect)
|
||||||
|
{
|
||||||
|
/* Change indirect symbol from IR to undefined. */
|
||||||
|
hi->root.type = bfd_link_hash_undefined;
|
||||||
|
hi->root.u.undef.abfd = oldbfd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEWDEF and OLDDEF indicate whether the new or old symbol,
|
/* NEWDEF and OLDDEF indicate whether the new or old symbol,
|
||||||
|
@ -238,6 +238,15 @@ if { [at_least_gcc_version 10 0] } {
|
|||||||
"-flto -fno-common $lto_no_fat" \
|
"-flto -fno-common $lto_no_fat" \
|
||||||
{pr25355.c} \
|
{pr25355.c} \
|
||||||
[list [list "nm" "$plug_opt" "pr25355.d"]]] \
|
[list [list "nm" "$plug_opt" "pr25355.d"]]] \
|
||||||
|
[list "pr28264.so" \
|
||||||
|
"-shared -Wl,--version-script=pr28264.ver" \
|
||||||
|
"-flto $lto_no_fat -fPIC" \
|
||||||
|
{pr28264.c} \
|
||||||
|
{{readelf {--dyn-syms --wide} pr28264-1.d} \
|
||||||
|
{readelf {--dyn-syms --wide} pr28264-2.d} \
|
||||||
|
{readelf {--dyn-syms --wide} pr28264-3.d} \
|
||||||
|
{readelf {--dyn-syms --wide} pr28264-4.d}} \
|
||||||
|
{pr28264.so}] \
|
||||||
]]
|
]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
ld/testsuite/ld-plugin/pr28264-1.d
Normal file
5
ld/testsuite/ld-plugin/pr28264-1.d
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Symbol table '\.dynsym' contains [0-9]+ entries:
|
||||||
|
+Num: +Value +Size Type +Bind +Vis +Ndx Name
|
||||||
|
#...
|
||||||
|
+[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _?foo@VERSION.1
|
||||||
|
#pass
|
5
ld/testsuite/ld-plugin/pr28264-2.d
Normal file
5
ld/testsuite/ld-plugin/pr28264-2.d
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Symbol table '\.dynsym' contains [0-9]+ entries:
|
||||||
|
+Num: +Value +Size Type +Bind +Vis +Ndx Name
|
||||||
|
#...
|
||||||
|
+[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _?bar@@VERSION.1
|
||||||
|
#pass
|
4
ld/testsuite/ld-plugin/pr28264-3.d
Normal file
4
ld/testsuite/ld-plugin/pr28264-3.d
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#failif
|
||||||
|
#...
|
||||||
|
+[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _?foo
|
||||||
|
#...
|
4
ld/testsuite/ld-plugin/pr28264-4.d
Normal file
4
ld/testsuite/ld-plugin/pr28264-4.d
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#failif
|
||||||
|
#...
|
||||||
|
+[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _?bar
|
||||||
|
#...
|
11
ld/testsuite/ld-plugin/pr28264.c
Normal file
11
ld/testsuite/ld-plugin/pr28264.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
void
|
||||||
|
__attribute__ ((symver ("foo@VERSION.1")))
|
||||||
|
foo (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
__attribute__ ((symver ("bar@@VERSION.1")))
|
||||||
|
bar1 (void)
|
||||||
|
{
|
||||||
|
}
|
8
ld/testsuite/ld-plugin/pr28264.ver
Normal file
8
ld/testsuite/ld-plugin/pr28264.ver
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
VERSION.1
|
||||||
|
{
|
||||||
|
global:
|
||||||
|
foo;
|
||||||
|
bar;
|
||||||
|
local:
|
||||||
|
*;
|
||||||
|
};
|
Reference in New Issue
Block a user