Bug 2495 - Solaris2 amd64 file format not recognized
Summary: Solaris2 amd64 file format not recognized
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.17
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-29 11:34 UTC by Andrew Rybchenko
Modified: 2006-06-30 05:02 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i386-pc-solaris2.11
Build:
Last reconfirmed:


Attachments
Ignore (accept) SHT_LOOS...SHT_HIOS sections in elf64 (361 bytes, patch)
2006-06-30 04:58 UTC, Petr Vandrovec
Details | Diff
Oops, this one compiles. Sorry. (360 bytes, patch)
2006-06-30 05:02 UTC, Petr Vandrovec
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Rybchenko 2006-03-29 11:34:33 UTC
Today (March, 29 2006) binutils TOT configured on i686-pc-linux-gnu using

../binutils/configure --target=i386-pc-solaris2.11 --enable-64-bit-bfd
--prefix=/srv/local/cross

and successfully build.

/binutils/objdump: /srv/local/cross/i386-pc-solaris2.11/lib/amd64/crti.o: File
format not recognized

crti.o file is got from OpenSolaris (snv_33) /usr/lib/amd64/crti.o.
Comment 1 Alan Modra 2006-03-29 11:48:19 UTC
Not a bug.  You need to build binutils with support for all targets of interest.
 In this case, you probably want to add --enable-targets=x86_64-elf to your
configure line (or --enable-targets=all).  If that doesn't work, then it means
that binutils doesn't have support for amd64 on solaris.
Comment 2 Andrew Rybchenko 2006-03-29 12:25:03 UTC
Thanks for reply.

When configured with --enable-targets=all, build failed

make[4]: *** No rule to make target
`../../binutils/ld/emulparams/elf32bfinfd.sh', needed by `eelf32bfinfd.c'.  Stop.
make[4]: Leaving directory `/home/arybchik/cvs/build/ld'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/arybchik/cvs/build/ld'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/arybchik/cvs/build/ld'
make[1]: *** [all-ld] Error 2
make[1]: Leaving directory `/home/arybchik/cvs/build'
make: *** [all] Error 2


When it is configured with --enable-targets=x86_64-elf, build works fine, but
the result is the same. The most interesting point here is that multiplatform
binutils (2.15) from Debian Sarge works fine.
Comment 3 Petr Vandrovec 2006-06-30 04:58:21 UTC
Created attachment 1128 [details]
Ignore (accept) SHT_LOOS...SHT_HIOS sections in elf64

Just FYI, attached patch is sufficient to make binutils happy on Solaris. 
Problem is that there is strange section named .SUNW_signature of an OS
specific type piggybacked on files which come with Solaris.

Problem is regression from 2.15.92 binutils.  Although they did not behave
quite correctly (they've completely ignored section, even not showing it in
objdump -h output), they did not fail with quite unexpected error that file
format is not recognized.

eu-readelf says:

There are 11 section headers, starting at offset 0x308:

Section Headers:
[Nr] Name	     Type	Addr	 Off	  Size	   ES Flags Lk Inf Al
[ 0]		     NULL	00000000 00000000 00000000  0	     0	 0  0
[ 1] .text	     PROGBITS	00000000 00000040 00000000  0 AX     0	 0  4
[ 2] .data	     PROGBITS	00000000 00000040 00000000  0 WA     0	 0  4
[ 3] .bss	     NOBITS	00000000 00000040 00000000  0 WA     0	 0  4
[ 4] .comment	     PROGBITS	00000000 00000040 00000025  0	     0	 0  1
[ 5] .init	     PROGBITS	00000000 00000070 00000004  0 AX     0	 0 16
[ 6] .fini	     PROGBITS	00000000 00000080 00000004  0 AX     0	 0 16
[ 7] .shstrtab	     STRTAB	00000000 00000084 00000051  0	     0	 0  1
[ 8] .symtab	     SYMTAB	00000000 000000d8 00000108 24	     9	 9  8
[ 9] .strtab	     STRTAB	00000000 000001e0 00000014  0	     0	 0  1
[10] .SUNW_signature 0x6ffffff6 00000000 000001f4 0000010e  0 E      0	 0  1

Thanks,  Petr Vandrovec
Comment 4 Petr Vandrovec 2006-06-30 05:01:11 UTC
Comment on attachment 1128 [details]
Ignore (accept) SHT_LOOS...SHT_HIOS sections in elf64

>--- binutils-2.17/bfd/elf64-x86-64.c.orig	2006-03-23 09:23:09.000000000 +0100
>+++ binutils-2.17/bfd/elf64-x86-64.c	2006-06-30 06:42:19.000000000 +0200
>@@ -3439,13 +3439,11 @@
> 				const char *name,
> 				int shindex)
> {
>-  if (hdr->sh_type != SHT_X86_64_UNWIND)
>-    return FALSE;
>-
>-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
>-    return FALSE;
>-
>-  return TRUE;
>+  if (hdr->sh_type == SHT_X86_64_UNWIND ||
>+      (hdr->sh_type >= SHT_LOOS && hdr->sh_type <= SHT_HIOS)) {
>+    return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
>+  }
>+  return FALSE;
> }
> 
> /* Hook called by the linker routine which adds symbols from an object
Comment 5 Petr Vandrovec 2006-06-30 05:02:36 UTC
Created attachment 1129 [details]
Oops, this one compiles.  Sorry.