public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fixes for GNU ld on amd64 Solaris
@ 2006-06-28  9:17 Michael Wetherell
  2006-06-28 11:46 ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Wetherell @ 2006-06-28  9:17 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1365 bytes --]

Hi,

ld has been giving the following error on Solaris x86-64:
/usr/lib/amd64/crti.o: file not recognized: File format not recognized 

I found under a debugger that it's because of an unknown header type 
0x6ffffff6 (SHT_SUNW_signature). Then searching for that, I discovered 
that they've already fixed in OpenSolaris, and that they also added two 
more: SHT_SUNW_dof and SHT_SUNW_syminfo.

The patch below ignores these three headers and also sets LIBPATH_SUFFIX 
and ELF_INTERPRETER_NAME. I've checked that gcc now builds 
--with-gnu-ld both natively and as a cross compiler, and compiled some 
large projects with it.

Regards,
Mike

bfd/ChangeLog
2006-06-28  Michael Wetherell  <mike.wetherell@ntlworld.com>

	* elf.c (bfd_section_from_shdr): ingore Sun section types
	SHT_GNU_syminfo, SHT_GNU_signature and SHT_GNU_dof.

include/elf/ChangeLog
2006-06-28  Michael Wetherell  <mike.wetherell@ntlworld.com>

	* common.h (SHT_SUNW_dof, SHT_SUNW_signature, SHT_SUNW_syminfo): New.
	* common.h (SHT_GNU_dof, SHT_GNU_signature, SHT_GNU_syminfo): Define
	GNU versions of the new SUNW defines.

ld/ChangeLog
2006-06-28  Michael Wetherell  <mike.wetherell@ntlworld.com>

	* configure.tgt (i[3-7]86-*-solaris2*, i[3-7]86-*-solaris*): Correct
	typo setting targ_extra_libpath.
	* emulparams/elf_x86_64.sh (LIBPATH_SUFFIX, ELF_INTERPRETER_NAME):
	Set for *-*-solaris2*.


[-- Attachment #2: solaris-amd64.diff --]
[-- Type: text/x-diff, Size: 3700 bytes --]

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.347
diff -u -2 -r1.347 elf.c
--- bfd/elf.c	23 Jun 2006 02:58:00 -0000	1.347
+++ bfd/elf.c	28 Jun 2006 00:32:08 -0000
@@ -2104,4 +2104,9 @@
       break;
 
+    case SHT_GNU_dof:
+    case SHT_GNU_signature:
+    case SHT_GNU_syminfo:
+      return TRUE;
+
     case SHT_GNU_verdef:
       elf_dynverdef (abfd) = shindex;
Index: include/elf/common.h
===================================================================
RCS file: /cvs/src/src/include/elf/common.h,v
retrieving revision 1.77
diff -u -2 -r1.77 common.h
--- include/elf/common.h	17 Feb 2006 14:36:26 -0000	1.77
+++ include/elf/common.h	28 Jun 2006 00:41:58 -0000
@@ -341,14 +341,20 @@
 #define SHT_GNU_LIBLIST	0x6ffffff7	/* List of prelink dependencies */
 
-/* The next three section types are defined by Solaris, and are named
+/* The next six section types are defined by Solaris, and are named
    SHT_SUNW*.  We use them in GNU code, so we also define SHT_GNU*
    versions.  */
-#define SHT_SUNW_verdef	0x6ffffffd	/* Versions defined by file */
-#define SHT_SUNW_verneed 0x6ffffffe	/* Versions needed by file */
-#define SHT_SUNW_versym	0x6fffffff	/* Symbol versions */
-
-#define SHT_GNU_verdef	SHT_SUNW_verdef
-#define SHT_GNU_verneed	SHT_SUNW_verneed
-#define SHT_GNU_versym	SHT_SUNW_versym
+#define SHT_SUNW_dof	    0x6ffffff4	/* Solaris DTrace Object Format */
+#define SHT_SUNW_signature  0x6ffffff6	/* Solaris Cryptographic Framework: Digital Signature */
+#define SHT_SUNW_syminfo    0x6ffffffc	/* Symbol information */
+#define SHT_SUNW_verdef	    0x6ffffffd	/* Versions defined by file */
+#define SHT_SUNW_verneed    0x6ffffffe	/* Versions needed by file */
+#define SHT_SUNW_versym	    0x6fffffff	/* Symbol versions */
+
+#define SHT_GNU_dof	    SHT_SUNW_dof
+#define SHT_GNU_signature   SHT_SUNW_signature
+#define SHT_GNU_syminfo	    SHT_SUNW_syminfo
+#define SHT_GNU_verdef	    SHT_SUNW_verdef
+#define SHT_GNU_verneed	    SHT_SUNW_verneed
+#define SHT_GNU_versym	    SHT_SUNW_versym
 
 #define SHT_LOPROC	0x70000000	/* Processor-specific semantics, lo */
Index: ld/configure.tgt
===================================================================
RCS file: /cvs/src/src/ld/configure.tgt,v
retrieving revision 1.189
diff -u -2 -r1.189 configure.tgt
--- ld/configure.tgt	23 Jun 2006 18:11:47 -0000	1.189
+++ ld/configure.tgt	28 Jun 2006 00:42:40 -0000
@@ -164,10 +164,10 @@
 i[3-7]86-*-solaris2*)	targ_emul=elf_i386_ldso
                         targ_extra_emuls="elf_i386 elf_x86_64"
-			targ_extra_libpath=$target_extra_emuls
+			targ_extra_libpath=$targ_extra_emuls
                         ;;
 i[3-7]86-*-unixware)	targ_emul=elf_i386 ;;
 i[3-7]86-*-solaris*)	targ_emul=elf_i386_ldso
                         targ_extra_emuls="elf_i386"
-			targ_extra_libpath=$target_extra_emuls
+			targ_extra_libpath=$targ_extra_emuls
                         ;;
 i[3-7]86-*-netbsdelf* | \
Index: ld/emulparams/elf_x86_64.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_x86_64.sh,v
retrieving revision 1.17
diff -u -2 -r1.17 elf_x86_64.sh
--- ld/emulparams/elf_x86_64.sh	30 May 2006 16:45:32 -0000	1.17
+++ ld/emulparams/elf_x86_64.sh	28 Jun 2006 00:42:47 -0000
@@ -23,5 +23,5 @@
 fi
 
-# Linux modify the default library search path to first include
+# Linux/solaris modify the default library search path to first include
 # a 64-bit specific directory.
 case "$target" in
@@ -31,3 +31,7 @@
     esac
     ;;
+  *-*-solaris2*) 
+      LIBPATH_SUFFIX=/amd64
+      ELF_INTERPRETER_NAME=\"/lib/amd64/ld.so.1\"
+    ;;
 esac

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fixes for GNU ld on amd64 Solaris
  2006-06-28  9:17 [PATCH] Fixes for GNU ld on amd64 Solaris Michael Wetherell
@ 2006-06-28 11:46 ` Jakub Jelinek
  2006-06-28 11:49   ` Michael Wetherell
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2006-06-28 11:46 UTC (permalink / raw)
  To: Michael Wetherell; +Cc: binutils

On Wed, Jun 28, 2006 at 10:16:09AM +0100, Michael Wetherell wrote:
> ld has been giving the following error on Solaris x86-64:
> /usr/lib/amd64/crti.o: file not recognized: File format not recognized 
> 
> I found under a debugger that it's because of an unknown header type 
> 0x6ffffff6 (SHT_SUNW_signature). Then searching for that, I discovered 
> that they've already fixed in OpenSolaris, and that they also added two 
> more: SHT_SUNW_dof and SHT_SUNW_syminfo.

The patch is bad:
1) you shouldn't define SHT_GNU_dof etc. - the reason why SHT_GNU_versym
etc. are defined the same as SHT_SUNW_* is because the GNU symbol versioning
uses them.  The SHT_SUNW_* types you are adding are not used for any GNU
feature (therefore shouldn't be in GNU namespace) and worse they clash
with GNU section types.
Linux (and GNU ld too) has:
#define SHT_GNU_LIBLIST   0x6ffffff7    /* Prelink library list */
#define SHT_CHECKSUM      0x6ffffff8    /* Checksum for DSO content.  */
#define SHT_LOSUNW        0x6ffffffa    /* Sun-specific low bound.  */
#define SHT_SUNW_move     0x6ffffffa
#define SHT_SUNW_COMDAT   0x6ffffffb
#define SHT_SUNW_syminfo  0x6ffffffc
#define SHT_GNU_verdef    0x6ffffffd    /* Version definition section.  */
#define SHT_GNU_verneed   0x6ffffffe    /* Version needs section.  */
#define SHT_GNU_versym    0x6fffffff    /* Version symbol table.  */
#define SHT_HISUNW        0x6fffffff    /* Sun-specific high bound.  */
(and one patch we're working on uses 0x6ffffff6 section type).

Solaris 10 use clashes with this, clearly they keep decreasing SHT_LOSUNW:
#define SHT_LOSUNW              0x6ffffff4
#define SHT_SUNW_dof            0x6ffffff4
#define SHT_SUNW_cap            0x6ffffff5
#define SHT_SUNW_SIGNATURE      0x6ffffff6
#define SHT_SUNW_ANNOTATE       0x6ffffff7
#define SHT_SUNW_DEBUGSTR       0x6ffffff8
#define SHT_SUNW_DEBUG          0x6ffffff9
#define SHT_SUNW_move           0x6ffffffa
#define SHT_SUNW_COMDAT         0x6ffffffb
#define SHT_SUNW_syminfo        0x6ffffffc
#define SHT_SUNW_verdef         0x6ffffffd
#define SHT_SUNW_verneed        0x6ffffffe
#define SHT_SUNW_versym         0x6fffffff
#define SHT_HISUNW              0x6fffffff

That's itself OK, this is all in OS range, but you really can't use OS
specific SHT_* tags in generic code if they can have multiple meanings.
You need to use switch on the ELF's OS.

	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fixes for GNU ld on amd64 Solaris
  2006-06-28 11:46 ` Jakub Jelinek
@ 2006-06-28 11:49   ` Michael Wetherell
  2006-07-14 14:50     ` Michael Wetherell
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Wetherell @ 2006-06-28 11:49 UTC (permalink / raw)
  To: binutils

On Wednesday 28 Jun 2006 12:32, Jakub Jelinek wrote:
> That's itself OK, this is all in OS range, but you really can't use
> OS specific SHT_* tags in generic code if they can have multiple
> meanings. You need to use switch on the ELF's OS.

Oh yes I see your point, I'll redo the patch.

Regards,
Mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fixes for GNU ld on amd64 Solaris
  2006-06-28 11:49   ` Michael Wetherell
@ 2006-07-14 14:50     ` Michael Wetherell
  2006-07-24 18:19       ` Nick Clifton
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Wetherell @ 2006-07-14 14:50 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1452 bytes --]

On Wednesday 28 Jun 2006 12:32, Jakub Jelinek wrote:
> That's itself OK, this is all in OS range, but you really can't use
> OS specific SHT_* tags in generic code if they can have multiple
> meanings. You need to use switch on the ELF's OS.

Hi,

I thought I should read-up before trying again. It seems that 
unrecognised OS specific sections shouldn't cause an error unless 
SHF_OS_NONCONFORMING is in the flag bits:
http://www.caldera.com/developers/gabi/latest/ch4.sheader.html#linking_rules

The patch below does that and programs do link now (this other patch is 
need too http://sources.redhat.com/ml/binutils/2006-06/msg00431.html).

bfd/ChangeLog
2006-07-14  Michael Wetherell  <mike.wetherell@ntlworld.com>

	* elf.c (bfd_section_from_shdr): Reject unrecognised OS-specific
	sections only if the SHF_OS_NONCONFORMING flag is present.

ld/ChangeLog
2006-07-14  Michael Wetherell  <mike.wetherell@ntlworld.com>

	* emulparams/elf_x86_64.sh (LIBPATH_SUFFIX, ELF_INTERPRETER_NAME):
	Set for *-*-solaris2*.

There is a wider problem though. What you were saying about checking the 
ELF's OS before looking at the OS-specific tags also applies to the GNU 
tags. And the problem with doing that is that e_ident[EI_OSABI] isn't 
being set currently.

It seems that the original intention was that e_ident[EI_OSABI] would be 
set if any OS-specific extensions were present see:
http://www.cygwin.com/ml/binutils/2000-11/msg00383.html

Regards,
Mike


[-- Attachment #2: solaris-amd64-2.diff --]
[-- Type: text/x-diff, Size: 2001 bytes --]

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.348
diff -u -r1.348 elf.c
--- bfd/elf.c	10 Jul 2006 21:40:23 -0000	1.348
+++ bfd/elf.c	13 Jul 2006 23:54:56 -0000
@@ -2201,11 +2201,20 @@
 	     "`%s' [0x%8x]"),
 	   abfd, name, hdr->sh_type);
       else if (hdr->sh_type >= SHT_LOOS && hdr->sh_type <= SHT_HIOS)
-	/* FIXME: We should handle this section.  */
-	(*_bfd_error_handler)
-	  (_("%B: don't know how to handle OS specific section "
-	     "`%s' [0x%8x]"),
-	   abfd, name, hdr->sh_type);
+	{
+	  /* Unrecognised OS-specific sections.  */
+	  if ((hdr->sh_flags & SHF_OS_NONCONFORMING) != 0)
+	    /* SHF_OS_NONCONFORMING indicates that special knowledge is
+	       required to correctly process the section and the file should 
+	       be rejected with an error message.  */
+	    (*_bfd_error_handler)
+	      (_("%B: don't know how to handle OS specific section "
+		 "`%s' [0x%8x]"),
+	       abfd, name, hdr->sh_type);
+	  else
+	    /* Otherwise it should be processed.  */
+	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
+	}
       else
 	/* FIXME: We should handle this section.  */
 	(*_bfd_error_handler)
Index: ld/emulparams/elf_x86_64.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_x86_64.sh,v
retrieving revision 1.17
diff -u -r1.17 elf_x86_64.sh
--- ld/emulparams/elf_x86_64.sh	30 May 2006 16:45:32 -0000	1.17
+++ ld/emulparams/elf_x86_64.sh	13 Jul 2006 23:54:59 -0000
@@ -22,7 +22,7 @@
   esac
 fi
 
-# Linux modify the default library search path to first include
+# Linux/solaris modify the default library search path to first include
 # a 64-bit specific directory.
 case "$target" in
   x86_64*-linux*)
@@ -30,4 +30,8 @@
       *64*) LIBPATH_SUFFIX=64 ;;
     esac
     ;;
+  *-*-solaris2*) 
+      LIBPATH_SUFFIX=/amd64
+      ELF_INTERPRETER_NAME=\"/lib/amd64/ld.so.1\"
+    ;;
 esac

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fixes for GNU ld on amd64 Solaris
  2006-07-14 14:50     ` Michael Wetherell
@ 2006-07-24 18:19       ` Nick Clifton
  2006-07-24 19:12         ` Michael Wetherell
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Clifton @ 2006-07-24 18:19 UTC (permalink / raw)
  To: Michael Wetherell; +Cc: binutils

Hi Michael,

> bfd/ChangeLog
> 2006-07-14  Michael Wetherell  <mike.wetherell@ntlworld.com>
> 
> 	* elf.c (bfd_section_from_shdr): Reject unrecognised OS-specific
> 	sections only if the SHF_OS_NONCONFORMING flag is present.
> 
> ld/ChangeLog
> 2006-07-14  Michael Wetherell  <mike.wetherell@ntlworld.com>
> 
> 	* emulparams/elf_x86_64.sh (LIBPATH_SUFFIX, ELF_INTERPRETER_NAME):
> 	Set for *-*-solaris2*.

Approved and applied.  (Sorry for the long delay...)

Cheers
   Nick


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fixes for GNU ld on amd64 Solaris
  2006-07-24 18:19       ` Nick Clifton
@ 2006-07-24 19:12         ` Michael Wetherell
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Wetherell @ 2006-07-24 19:12 UTC (permalink / raw)
  To: binutils

On Monday 24 Jul 2006 19:19, Nick Clifton wrote:
> Approved and applied.  (Sorry for the long delay...)

Thanks and no problem.

Regards,
Mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-07-24 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-28  9:17 [PATCH] Fixes for GNU ld on amd64 Solaris Michael Wetherell
2006-06-28 11:46 ` Jakub Jelinek
2006-06-28 11:49   ` Michael Wetherell
2006-07-14 14:50     ` Michael Wetherell
2006-07-24 18:19       ` Nick Clifton
2006-07-24 19:12         ` Michael Wetherell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).