[PATCH][RFC] link error when DSO is before object files (similar to PR ld/11138)
Ryosei Takagi
ryosei@sm.sony.co.jp
Tue Aug 2 05:55:00 GMT 2011
Hi all,
I'm using a following toolchain for ARM Linux EABI and met an ld issue,
which is similar to PR ld/11138.
binutils: 2.20.51.0.11
gcc: 4.5.1
glibc: 2.11.2
A symbol exported by DSO, the version of which is 3 or above,
may be defined in non-shared object and forced local. In this case we
meet link error.
I have confirmed that binutils-2.21.1 also has the same issue.
Following is the test case.
* Test Code
[foo.c]
void
bar ()
{
}
int
main ()
{
bar ();
return 0;
}
[bar.c]
void
bar ()
{
}
[foo.map]
{
global: main;
local: *;
};
[bar.map]
VERS_1 {
local: *;
};
VERS_2 {
global: bar;
} VERS_1;
* Build
arm-unknown-linux-gnueabi-dev-gcc -c -o foo.o foo.c
arm-unknown-linux-gnueabi-dev-gcc -c -o bar.o bar.c
arm-unknown-linux-gnueabi-dev-ld -o libbar.so -shared --version-script=bar.map bar.o
arm-unknown-linux-gnueabi-dev-ld -e main --version-script=foo.map -o bar foo.o libbar.so
arm-unknown-linux-gnueabi-dev-ld -e main --version-script=foo.map -o foo libbar.so foo.o
arm-unknown-linux-gnueabi-dev-ld: foo: local symbol `bar' in foo.o is referenced by DSO
arm-unknown-linux-gnueabi-dev-ld: final link failed: Nonrepresentable section on output
make: *** [foo] Error 1
ld reports an error in case we specify a shared library before an object
file.
If I put the shared library after the object file, ld does not report
this error.
Following is a patch to fix this issue, which I referred PR ld/11138
and prepared.
I have verified that the above test case is PASS after applying this
patch.
binutils makecheck has been done for ARM Linux EABI.
No addtional FAILs are found.
Could you please give me some comments??
Best Regards,
Ryosei Takagi
2011-08-02 Ryosei Takagi <ryosei@sm.sony.co.jp>
* elflink.c (elf_link_check_versioned_symbol): Don't handle as
error if a symbol referenced by DSO, the version of which is 3
or above, is defined in a non-shared object and forced local.
Index: b/bfd/elflink.c
===================================================================
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8613,14 +8613,19 @@ elf_link_check_versioned_symbol (struct
_bfd_elf_swap_versym_in (input, ever, &iver);
- if ((iver.vs_vers & VERSYM_HIDDEN) == 0
- && !(h->def_regular
- && h->forced_local))
+ if ((iver.vs_vers & VERSYM_HIDDEN) == 0)
{
/* If we have a non-hidden versioned sym, then it should
have provided a definition for the undefined sym unless
it is defined in a non-shared object and forced local.
*/
+ if (h->def_regular && h->forced_local)
+ {
+ free (extversym);
+ free (isymbuf);
+ return TRUE;
+ }
+
abort ();
}
More information about the Binutils
mailing list