This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][RFC] link error when DSO is before object files (similar to PR ld/11138)

Hi all,

I'm using a following toolchain for ARM Linux EABI and met an ld issue,
which is similar to PR ld/11138.

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

bar ()

main ()
  bar ();
  return 0;

bar ()

        global: main;
        local: *;

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 -shared bar.o
arm-unknown-linux-gnueabi-dev-ld -e main  -o bar foo.o
arm-unknown-linux-gnueabi-dev-ld -e main  -o foo 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
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

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  <>

	* 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 ();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]