Properly mark the plugin symbol undefined
Mark the unused plugin defined symbol in elf_link_input_bfd instead of _bfd_elf_fix_symbol_flags. Limit the PR ld/12365 test to x86 targets. bfd/ PR ld/12365 PR ld/14272 * elflink.c (_bfd_elf_fix_symbol_flags): Revert the last change. (elf_link_input_bfd): Mark the plugin symbol undefined if it is referenced from a non-IR file. ld/testsuite/ PR ld/12365 PR ld/14272 * ld-plugin/lto.exp: Run the PR ld/12365 test only for x86 targets. * ld-plugin/plugin-7.d: Updated. * ld-plugin/plugin-8.d: Likewise.
This commit is contained in:
parent
e584fdbc6a
commit
9e2dec4710
6 changed files with 53 additions and 22 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2015-02-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/12365
|
||||||
|
PR ld/14272
|
||||||
|
* elflink.c (_bfd_elf_fix_symbol_flags): Revert the last change.
|
||||||
|
(elf_link_input_bfd): Mark the plugin symbol undefined if it is
|
||||||
|
referenced from a non-IR file.
|
||||||
|
|
||||||
2015-02-06 Nick Clifton <nickc@redhat.com>
|
2015-02-06 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
PR binutils/17512
|
PR binutils/17512
|
||||||
|
|
|
@ -2423,20 +2423,6 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* If a plugin symbol is referenced from a non-IR file, mark
|
|
||||||
the symbol as undefined, except for symbol for linker
|
|
||||||
created section. */
|
|
||||||
if (h->root.non_ir_ref
|
|
||||||
&& (h->root.type == bfd_link_hash_defined
|
|
||||||
|| h->root.type == bfd_link_hash_defweak)
|
|
||||||
&& (h->root.u.def.section->flags & SEC_LINKER_CREATED) == 0
|
|
||||||
&& h->root.u.def.section->owner != NULL
|
|
||||||
&& (h->root.u.def.section->owner->flags & BFD_PLUGIN) != 0)
|
|
||||||
{
|
|
||||||
h->root.type = bfd_link_hash_undefined;
|
|
||||||
h->root.u.undef.abfd = h->root.u.def.section->owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unfortunately, NON_ELF is only correct if the symbol
|
/* Unfortunately, NON_ELF is only correct if the symbol
|
||||||
was first seen in a non-ELF file. Fortunately, if the symbol
|
was first seen in a non-ELF file. Fortunately, if the symbol
|
||||||
was first seen in an ELF file, we're probably OK unless the
|
was first seen in an ELF file, we're probably OK unless the
|
||||||
|
@ -9807,6 +9793,22 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
|
||||||
|
|
||||||
s_type = h->type;
|
s_type = h->type;
|
||||||
|
|
||||||
|
/* If a plugin symbol is referenced from a non-IR file,
|
||||||
|
mark the symbol as undefined, except for symbol for
|
||||||
|
linker created section. */
|
||||||
|
if (h->root.non_ir_ref
|
||||||
|
&& (h->root.type == bfd_link_hash_defined
|
||||||
|
|| h->root.type == bfd_link_hash_defweak)
|
||||||
|
&& (h->root.u.def.section->flags
|
||||||
|
& SEC_LINKER_CREATED) == 0
|
||||||
|
&& h->root.u.def.section->owner != NULL
|
||||||
|
&& (h->root.u.def.section->owner->flags
|
||||||
|
& BFD_PLUGIN) != 0)
|
||||||
|
{
|
||||||
|
h->root.type = bfd_link_hash_undefined;
|
||||||
|
h->root.u.undef.abfd = h->root.u.def.section->owner;
|
||||||
|
}
|
||||||
|
|
||||||
ps = NULL;
|
ps = NULL;
|
||||||
if (h->root.type == bfd_link_hash_defined
|
if (h->root.type == bfd_link_hash_defined
|
||||||
|| h->root.type == bfd_link_hash_defweak)
|
|| h->root.type == bfd_link_hash_defweak)
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
2015-02-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/12365
|
||||||
|
PR ld/14272
|
||||||
|
* ld-plugin/lto.exp: Run the PR ld/12365 test only for x86 targets.
|
||||||
|
* ld-plugin/plugin-7.d: Updated.
|
||||||
|
* ld-plugin/plugin-8.d: Likewise.
|
||||||
|
|
||||||
2015-02-04 H.J. Lu <hongjiu.lu@intel.com>
|
2015-02-04 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* ld-plugin/lto.exp: Pass -flto-partition=none to the PR
|
* ld-plugin/lto.exp: Pass -flto-partition=none to the PR
|
||||||
|
|
|
@ -383,6 +383,16 @@ if {![string match "" $catch_output]} {
|
||||||
|
|
||||||
if { [at_least_gcc_version 4 7] } {
|
if { [at_least_gcc_version 4 7] } {
|
||||||
# Check expected LTO linker errors.
|
# Check expected LTO linker errors.
|
||||||
|
# Since the asm symbol name hack in pr12365b.c doesn't work on all
|
||||||
|
# targets, run PR ld/12365 tests only for known targets.
|
||||||
|
if { ([istarget "i?86-*-elf*"]
|
||||||
|
|| (([istarget "i?86-*-linux*"] || [istarget "i?86-*-gnu*"])
|
||||||
|
&& ![istarget "*-*-*aout*"]
|
||||||
|
&& ![istarget "*-*-*oldld*"])
|
||||||
|
|| [istarget "i?86-*-nacl*"]
|
||||||
|
|| [istarget "x86_64-*-nacl*"]
|
||||||
|
|| [istarget "x86_64-*-linux*"]
|
||||||
|
|| [istarget "amd64-*-linux*"]) } {
|
||||||
set testname "PR ld/12365"
|
set testname "PR ld/12365"
|
||||||
set exec_output [run_host_cmd "$CC" "-O2 -flto -flto-partition=none -fuse-linker-plugin tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
|
set exec_output [run_host_cmd "$CC" "-O2 -flto -flto-partition=none -fuse-linker-plugin tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
|
||||||
if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
|
if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
|
||||||
|
@ -390,6 +400,7 @@ if { [at_least_gcc_version 4 7] } {
|
||||||
} {
|
} {
|
||||||
fail $testname
|
fail $testname
|
||||||
}
|
}
|
||||||
|
}
|
||||||
set testname "PR ld/12942 (3)"
|
set testname "PR ld/12942 (3)"
|
||||||
set exec_output [run_host_cmd "$CXX" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
|
set exec_output [run_host_cmd "$CXX" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
|
||||||
if { [ regexp "undefined reference to `link_error\\(\\)'" $exec_output ] } {
|
if { [ regexp "undefined reference to `link_error\\(\\)'" $exec_output ] } {
|
||||||
|
|
|
@ -28,6 +28,7 @@ hook called: claim_file tmpdir/func.o \[@0/.* CLAIMED
|
||||||
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
|
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
|
||||||
#...
|
#...
|
||||||
hook called: all symbols read.
|
hook called: all symbols read.
|
||||||
`_?func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .*
|
tmpdir/main.o: In function `main':
|
||||||
|
.*main.c.*: undefined reference to `func'
|
||||||
hook called: cleanup.
|
hook called: cleanup.
|
||||||
#...
|
#...
|
||||||
|
|
|
@ -32,6 +32,7 @@ hook called: claim_file tmpdir/text.o \[@0/.* not claimed
|
||||||
hook called: all symbols read.
|
hook called: all symbols read.
|
||||||
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
|
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
|
||||||
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
|
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
|
||||||
`_?func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .*
|
tmpdir/main.o: In function `main':
|
||||||
|
.*main.c.*: undefined reference to `func'
|
||||||
hook called: cleanup.
|
hook called: cleanup.
|
||||||
#...
|
#...
|
||||||
|
|
Loading…
Reference in a new issue