Subject: Re: Solaris emulation problems
To: Alexander Strauss <strauss@astracom.net>
From: Eduardo Horvath <eeh@turbolinux.com>
List: port-sparc
Date: 06/08/2000 13:10:21
On Thu, 8 Jun 2000, Alexander Strauss wrote:

> Eduardo Horvath wrote:
> > 
> > On Thu, 8 Jun 2000, Alexander Strauss wrote:
> > 
> > > Hi there,
> > >
> > > I've setup a Sparc Classic with Solaris emulation as described in
> > > compat_svr4(8) - the Solaris files are located in /emul/svr4, and my
> > > kernel build includes the options "COMPAT_SVR4" and "EXEC_ELF32".
> > > Anyway, if I try to execute a simple Solaris 7 program, the kernel fails
> > > to execute it:
> > >
> > > alex@modena:/mnt/bin:(5)> ./less
> > > ./less: Exec format error. Binary file not executable.
> > > alex@modena:/mnt/bin:(6)>
> > >
> > > Any suggestions?
> > 
> > Make sure it's a 32-bit ELF executable and not 64-bit ELF:
> > 
> >         file ./less
> > 
> > You cannot run 64-bit binaries on a 32-bit machine.
> > 
> > If that checks out, then try ldd to make sure all the libraries can be
> > found and ktrace to find out where it's dying.
> > 
> > If it dies inside one execve then try using objdump on it to dump the ELF
> > headers.
> > 
> > Eduardo Horvath
> 
> 
> alex@modena:/tmp:(17)> file /mnt/bin/less
> /mnt/bin/less: ELF 32-bit MSB executable, SPARC, version 1, dynamically
> linked (uses shared libs), not stripped
> alex@modena:/tmp:(18)> ldd /mnt/bin/less
> ldd: /mnt/bin/less: not a dynamic executable
> alex@modena:/tmp:(19)> ktrace /mnt/bin/less
> /mnt/bin/less: 1: Syntax error: "(" unexpected
> alex@modena:/tmp:(20)> objdump --section-headers /mnt/bin/less
> 
> /mnt/bin/less:     file format elf32-sparc
> 
> Sections:
> Idx Name          Size      VMA       LMA       File off  Algn
>   0 .interp       00000011  000100d4  000100d4  000000d4  2**0
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   1 .hash         00000e1c  000100e8  000100e8  000000e8  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   2 .dynsym       00001bc0  00010f04  00010f04  00000f04  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   3 .dynstr       00001f47  00012ac4  00012ac4  00002ac4  2**0
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   4 .SUNW_version 00000040  00014a0c  00014a0c  00004a0c  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   5 .rela.bss     00000018  00014a4c  00014a4c  00004a4c  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   6 .rela.plt     0000030c  00014a64  00014a64  00004a64  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   7 .text         0000f59c  00014d70  00014d70  00004d70  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   8 .init         0000001c  0002430c  0002430c  0001430c  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   9 .fini         00000014  00024328  00024328  00014328  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>  10 .rodata       000045c3  00024340 00024340 00014340 2**3
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>  11 .got          00000020  00038904  00038904  00018904  2**2
>                   CONTENTS, ALLOC, LOAD, DATA
>  12 .plt          00000340  00038924  00038924  00018924  2**2
>                   CONTENTS, ALLOC, LOAD, CODE
>  13 .dynamic      000000c0  00038c64  00038c64  00018c64  2**2
>                   CONTENTS, ALLOC, LOAD, DATA
>  14 .data         00000a64  00038d28  00038d28  00018d28  2**3
>                   CONTENTS, ALLOC, LOAD, DATA
>  15 .ctors        00000008  0003978c  0003978c  0001978c  2**2
>                   CONTENTS, ALLOC, LOAD, DATA
>  16 .dtors        00000008  00039794  00039794  00019794  2**2
>                   CONTENTS, ALLOC, LOAD, DATA
>  17 .eh_frame     00000154  0003979c  0003979c  0001979c  2**2
>                   CONTENTS, ALLOC, LOAD, DATA
>  18 .bss          00001fa0  000398f0  000398f0  000198f0  2**3
>                   ALLOC
>  19 .comment      000009d6  00000000  00000000  0001e6ec  2**0
>                   CONTENTS, READONLY
>  20 .stab.index   00000024  00000000  00000000  0001f0c4  2**2
>                   CONTENTS, READONLY, DEBUGGING
>  21 .stab         0002af00  00000000  00000000  0001f0e8  2**2
>                   CONTENTS, READONLY, DEBUGGING
>  22 .stab.indexstr 00000171  00000000  00000000  0004a0c6  2**0
>                   CONTENTS, READONLY, DEBUGGING
>  23 .stabstr      00046c4e  00000000  00000000  0004a237  2**0
>                   CONTENTS, READONLY, DEBUGGING
> 
> Interesting, eh? Probably a kernel configuration problem, but I couldn't
> find one...same behaviour with any other Solaris binary I've tested.

Interesting.  Looks O.K. to me.

	/mnt/bin/less: 1: Syntax error: "(" unexpected

is because exec_elf() and exec_aout() failed so exec_script() is trying to
run the binary.

First of all it is a dynamic executable, so exec_elf() will try to load
any .intrp sections, and if that fails exec_elf() will fail.  Can you try
a static binary and see how that works?

If a static binary works then it's probably some issue with /emul/svr4 and
possibly LD_LIBRARY_PATH.

If the static binary does not work then it is some kernel issue and you
may need to instrument exec_elf() and other parts of execve() to find out
why it's failing.

Eduardo Horvath