Subject: Re: Cannot execute binary file
To: Matt Thomas <matt@3am-software.com>
From: Andrew Cagney <cagney@mac.com>
List: port-powerpc
Date: 07/31/2001 12:28:50
Matt Thomas wrote:
> My guess if that your program is missing the NetBSD ELF signature.
> A change since June was made to not assume that un-signed ELF
> programs are NetBSD.


You mean:

/usr/bin/cal:     file format elf32-powerpc

Sections:
Idx Name          Size      VMA       LMA       File off  Algn

....

  1 .note.netbsd.ident 00000034  0180012c  0180012c  0000012c  2**2


no, my program does not have that section.

Matthew Green wrote:

> yah, as i recall, andrew's GCC patches use the gcc crt, which doesn't
> include the proper netbsd note.  i had similar problems until i changed
> my sparc/i386 patches to use our crt.


The link line is:

/home/scratch/cygnus/H-powerpc-apple-netbsd1.5W/T-powerpc-apple-netbsd1.5W/B-EGCS/lib/gcc-lib/powerpc-apple-netbsd1.5W/3.1/collect2

-V -Qy -dc -dp

-dynamic-linker /usr/libexec/ld.elf_so

/home/scratch/cygnus/H-powerpc-apple-netbsd1.5W/T-powerpc-apple-netbsd1.5W/B-EGCS/lib/gcc-lib/powerpc-apple-netbsd1.5W/3.1/ncrti.o

/usr/lib/crt0.o /home/scratch/cygnus/H-powerpc-apple-netbsd1.5W/T-powerpc-apple-netbsd1.5W/B-EGCS/lib/gcc-lib/powerpc-apple-netbsd1.5W/3.1/crtbegin.o

-L/home/scratch/cygnus/H-powerpc-apple-netbsd1.5W/T-powerpc-apple-netbsd1.5W/B-EGCS/lib/gcc-lib/powerpc-apple-netbsd1.5W/3.1

/tmp/cc7YreGo.o

-lgcc -lc -lgcc

/home/scratch/cygnus/H-powerpc-apple-netbsd1.5W/T-powerpc-apple-netbsd1.5W/B-EGCS/lib/gcc-lib/powerpc-apple-netbsd1.5W/3.1/crtend.o

/home/scratch/cygnus/H-powerpc-apple-netbsd1.5W/T-powerpc-apple-netbsd1.5W/B-EGCS/lib/gcc-lib/powerpc-apple-netbsd1.5W/3.1/ncrtn.o

So I'm using NetBSD's crt0 but GCC's crt{begin,end} and crt{i,n}.  I 
guess the note was burried in one of the latter:

/usr/lib/crtbegin.o:     file format elf32-powerpc

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
...
  10 .note.netbsd.ident 00000034  00000000  00000000  00000238  2**2
                   CONTENTS, ALLOC, LOAD, READONLY, DATA

yep....

	Andrew