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]

Forcing all SGI-compatible DSOs to use DT_SONAME


You might remember a recent patch that forced SGI-compatible MIPS
objects to have named section symbols.  I'm afraid I've another
patch in the same vein...

Richard Sandiford <rsandifo@redhat.com> writes:
> I put your patch through a gcc bootstrap (just as a basic sanity check)
> and there were no problems with the -mabi=32 multilibs.  The native linker
> segfaults if you try to link against a GNU-ld-generated DSO, but the same
> happens before the patch as well.  Hope to look into it soon.

It seems that the native SGI linkers will segfault if you try to link
against a shared object with no DT_SONAME.  I suppose we could just tell
users (and gcc) to always supply -soname, but it'd be more friendly for
ld to set up a default DT_SONAME instead, just like the native linker does.

Patch tested on mips-sgi-irix6.5.  It makes it possible to link against
GNU-generated DSOs using the native linker even if -soname isn't given.
Also put through a gcc bootstrap and regression test.

Can anyone see any potential problems with doing this?  If not, is the
patch OK to install?  OK for 2.15 too?

Richard


bfd/
	* elf-bfd.h (elf_backend_data): Add elf_backend_need_soname.
	* elflink.c (bfd_elf_size_dynamic_sections): Check it.
	* elfxx-target.h (elf_backend_need_soname): Provide default definition.
	(elfNN_bed): Initialize elf_backend_need_soname.
	* elfxx-mips.h (_bfd_mips_elf_need_soname): Declare.
	(elf_backend_need_soname): Define to _bfd_mips_elf_need_soname.
	* elfxx-mips.c (_bfd_mips_elf_need_soname): New.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.136
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.136 elf-bfd.h
*** bfd/elf-bfd.h	27 Mar 2004 10:58:05 -0000	1.136
--- bfd/elf-bfd.h	6 Apr 2004 19:50:34 -0000
*************** struct elf_backend_data
*** 582,587 ****
--- 582,592 ----
    bfd_boolean (*elf_backend_name_local_section_symbols)
      (bfd *);
  
+   /* Return true if all shared objects should have a DT_SONAME.
+      NULL implies false.  */
+   bfd_boolean (*elf_backend_need_soname)
+     (bfd *);
+ 
    /* A function to do additional processing on the ELF section header
       just before writing it out.  This is used to set the flags and
       type fields for some sections, or to actually write out data for
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.63
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.63 elflink.c
*** bfd/elflink.c	27 Mar 2004 10:58:08 -0000	1.63
--- bfd/elflink.c	6 Apr 2004 19:50:36 -0000
*************** bfd_elf_size_dynamic_sections (bfd *outp
*** 4686,4691 ****
--- 4686,4698 ----
        *sinterpptr = bfd_get_section_by_name (dynobj, ".interp");
        BFD_ASSERT (*sinterpptr != NULL || !info->executable);
  
+       /* Some backends want all shared objects to have an soname.  */
+       if (soname == NULL
+ 	  && info->shared
+ 	  && bed->elf_backend_need_soname
+ 	  && bed->elf_backend_need_soname (output_bfd))
+ 	soname = basename (output_bfd->filename);
+ 
        if (soname != NULL)
  	{
  	  soname_indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
Index: bfd/elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.62
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.62 elfxx-target.h
*** bfd/elfxx-target.h	27 Mar 2004 10:58:07 -0000	1.62
--- bfd/elfxx-target.h	6 Apr 2004 19:50:36 -0000
*************** #define elf_backend_get_symbol_type 0
*** 287,292 ****
--- 287,295 ----
  #ifndef elf_backend_name_local_section_symbols
  #define elf_backend_name_local_section_symbols	0
  #endif
+ #ifndef elf_backend_need_soname
+ #define elf_backend_need_soname	0
+ #endif
  #ifndef elf_backend_section_processing
  #define elf_backend_section_processing	0
  #endif
*************** static const struct elf_backend_data elf
*** 479,484 ****
--- 482,488 ----
    elf_backend_symbol_table_processing,
    elf_backend_get_symbol_type,
    elf_backend_name_local_section_symbols,
+   elf_backend_need_soname,
    elf_backend_section_processing,
    elf_backend_section_from_shdr,
    elf_backend_section_flags,
Index: bfd/elfxx-mips.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.h,v
retrieving revision 1.19
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.19 elfxx-mips.h
*** bfd/elfxx-mips.h	26 Mar 2004 06:13:40 -0000	1.19
--- bfd/elfxx-mips.h	6 Apr 2004 19:50:36 -0000
*************** extern void _bfd_mips_elf_symbol_process
*** 26,31 ****
--- 26,33 ----
    (bfd *, asymbol *);
  extern bfd_boolean _bfd_mips_elf_name_local_section_symbols
    (bfd *);
+ extern bfd_boolean _bfd_mips_elf_need_soname
+   (bfd *);
  extern bfd_boolean _bfd_mips_elf_section_processing
    (bfd *, Elf_Internal_Shdr *);
  extern bfd_boolean _bfd_mips_elf_section_from_shdr
*************** extern bfd_vma _bfd_mips_elf_sign_extend
*** 123,126 ****
--- 125,130 ----
  extern struct bfd_elf_special_section const _bfd_mips_elf_special_sections[];
  #define elf_backend_name_local_section_symbols \
    _bfd_mips_elf_name_local_section_symbols
+ #define elf_backend_need_soname \
+   _bfd_mips_elf_need_soname
  #define elf_backend_special_sections _bfd_mips_elf_special_sections
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.96
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.96 elfxx-mips.c
*** bfd/elfxx-mips.c	27 Mar 2004 10:58:07 -0000	1.96
--- bfd/elfxx-mips.c	6 Apr 2004 19:50:39 -0000
*************** _bfd_mips_elf_name_local_section_symbols
*** 4276,4281 ****
--- 4276,4291 ----
  {
    return SGI_COMPAT (abfd);
  }
+ 
+ /* The MIPSpro (static) linker will segfault if you try to link against
+    a shared object that has no soname.  Force SGI-compatible objects
+    to have one.  */
+ 
+ bfd_boolean
+ _bfd_mips_elf_need_soname (bfd *abfd)
+ {
+   return SGI_COMPAT (abfd);
+ }
  
  /* Work over a section just before writing it out.  This routine is
     used by both the 32-bit and the 64-bit ABI.  FIXME: We recognize


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