This is the mail archive of the binutils@sources.redhat.com 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]

Re: [PATCH] Fix --as-needed for MIPS.


Thiemo Seufer wrote:
David Daney wrote:
[snip]

+   /* Shared objects may have a dynamic symbol '_gp_disp' defined as
+      a SECTION *ABS*.  This causes ld to think it can resolve _gp_disp
+      by setting a DT_NEEDED for the shared object.  Since _gp_disp is
+      a magic symbol resolved by the linker, we ignore this bogus definition
+      of _gp_disp. */
+   if ((strcmp (*namep, "_gp_disp") == 0) && !bfd_is_und_section (*secp))
+     {
+       *namep = NULL;
+       return TRUE;
+     }


This should be limited to OldABI objects, for N32/N64 _gp_disp is not
a magic symbol.

O.K,


Attached is the new version of the patch.

Preventing the _gp_disp from being emitted into dynamic objects is a more difficult problem. I think to do it properly that hacking would have to be done in the core of ld and bfd.

Tested with a cross build running on i686-pc-linux configured as:

../src/configure --target=mipsel-linux --prefix=/usr/local/mipsel-linux-3.4.3 --with-sysroot=/usr/local/mipsel-linux-3.4.3

make -k check with no regressions.

2005-07-29 David Daney <ddaney@avtrex.com>

    * elfxx-mips.c (_bfd_mips_elf_add_symbol_hook):  Ignore _gp_disp
    if it is in the *ABS* section.

O.K. to commit?

David Daney


? doc/bfd.info
Index: elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.146
diff -c -p -r1.146 elfxx-mips.c
*** elfxx-mips.c	8 Jul 2005 06:20:05 -0000	1.146
--- elfxx-mips.c	29 Jul 2005 22:15:23 -0000
*************** _bfd_mips_elf_add_symbol_hook (bfd *abfd
*** 5414,5419 ****
--- 5414,5433 ----
        return TRUE;
      }
  
+   /* Shared objects may have a dynamic symbol '_gp_disp' defined as
+      a SECTION *ABS*.  This causes ld to think it can resolve _gp_disp
+      by setting a DT_NEEDED for the shared object.  Since _gp_disp is
+      a magic symbol resolved by the linker, we ignore this bogus definition
+      of _gp_disp.  New ABI objects do not suffer from this problem so this
+      is not done for them. */
+   if (!NEWABI_P(abfd)
+       && (sym->st_shndx == SHN_ABS)
+       && (strcmp (*namep, "_gp_disp") == 0))
+     {
+       *namep = NULL;
+       return TRUE;
+     }
+ 
    switch (sym->st_shndx)
      {
      case SHN_COMMON:

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