Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Apr 2011 11:47:20 +0530
From:      "Jayachandran C." <c.jayachandran@gmail.com>
To:        Andrew Duane <aduane@juniper.net>
Cc:        "mips@freebsd.org" <mips@freebsd.org>
Subject:   Re: Trouble with dynamic executables
Message-ID:  <BANLkTimoc9Xd50LgiubDJGKOiUjztF-EfQ@mail.gmail.com>
In-Reply-To: <AC6674AB7BC78549BB231821ABF7A9AEB53018A224@EMBX01-WF.jnpr.net>
References:  <AC6674AB7BC78549BB231821ABF7A9AEB53018A09F@EMBX01-WF.jnpr.net> <BANLkTi=Jw=q5sUVs8-sEG09nSHwFbMFKjw@mail.gmail.com> <AC6674AB7BC78549BB231821ABF7A9AEB53018A224@EMBX01-WF.jnpr.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Apr 15, 2011 at 12:47 AM, Andrew Duane <aduane@juniper.net> wrote:
> I've figured out what the problem is. The elf header of a sample dynamic =
executable shows:
>
> Elf file type is EXEC (Executable file)
> Entry point 0x1200028f0
> There are 7 program headers, starting at offset 64
>
> Program Headers:
> =A0Type =A0 =A0 =A0 =A0 =A0 Offset =A0 =A0 =A0 =A0 =A0 =A0 VirtAddr =A0 =
=A0 =A0 =A0 =A0 PhysAddr =A0 =A0 =A0 =A0 =A0 FileSiz =A0 =A0 =A0 =A0 =A0 =
=A0MemSiz =A0 =A0 =A0 =A0 =A0 =A0 =A0Flags =A0Align
> =A0PHDR =A0 =A0 =A0 =A0 =A0 0x0000000000000040 0x0000000120000040 0x00000=
00120000040 0x0000000000000188 0x0000000000000188 =A0R E =A0 =A08
> =A0INTERP =A0 =A0 =A0 =A0 0x0000000000012788 0x0000000120012788 0x0000000=
120012788 0x0000000000000015 0x0000000000000015 =A0R =A0 =A0 =A01
> =A0 =A0 =A0[Requesting program interpreter: /libexec/ld-elf.so.1]
> =A0LOAD =A0 =A0 =A0 =A0 =A0 0x0000000000000000 0x0000000120000000 0x00000=
00120000000 0x00000000000127bc 0x00000000000127bc =A0R E =A0 =A010000
> =A0LOAD =A0 =A0 =A0 =A0 =A0 0x0000000000013000 0x0000000120023000 0x00000=
00120023000 0x00000000000017d8 0x0000000000003c28 =A0RW =A0 =A0 10000
> =A0DYNAMIC =A0 =A0 =A0 =A00x0000000000000808 0x0000000120000808 0x0000000=
120000808 0x00000000000001e0 0x00000000000001e0 =A0RWE =A0 =A08
> =A0NOTE =A0 =A0 =A0 =A0 =A0 0x00000000000127a4 0x00000001200127a4 0x00000=
001200127a4 0x0000000000000018 0x0000000000000018 =A0R =A0 =A0 =A04
> =A0NULL =A0 =A0 =A0 =A0 =A0 0x0000000000000000 0x0000000000000000 0x00000=
00000000000 0x0000000000000000 0x0000000000000000 =A0 =A0 =A0 =A0 8
>
> Note section 1 the INTERP header: the offset is 0x12788. There's a check =
in the ELF64 image activator to see if the offset is outside the first page=
 and returns ENOEXEC. The exec path reads in the first page first, and trie=
s to figure out what to do with the rest. So if the interpreter name isn't =
in the first page, it can't decode it.
>
> This is a toolchain issue, or some setup issue.

This may be a mip64r2 issue.

I use the  mips64 config and 32 and 64 bit dynamic executables have
been working for a long time.

For reference, here is my setup:

Environment for buildworld:
export TARGET=3Dmips
export TARGET_ARCH=3Dmips64eb
export TARGET_CPUTYPE=3Dmips64

Makeoptions in conf  file (from XLP64)

makeoptions     KERNLOADADDR=3D0xffffffff80100000
makeoptions     ARCH_FLAGS=3D"-march=3Dmips64 -mabi=3D64"
options         ISA_MIPS64

And on the XLR engineering board:

xlrboard# uname -a
FreeBSD xlrboard.netlogicmicro.com 9.0-CURRENT FreeBSD 9.0-CURRENT #2
r220649M: Fri Apr 15 11:27:57 IST 2011
jc@daemon.razamicroelectronics.com:/var/obj/jc/freebsd-obj-64/mips.mips64eb=
/work/jayachandranc/freebsd-devel-clean/sys/XLRJC64
 mips
xlrboard# ldd /bin/ls
/bin/ls:
        libutil.so.9 =3D> /lib/libutil.so.9 (0x16024d000)
        libncurses.so.8 =3D> /lib/libncurses.so.8 (0x16035f000)
        libc.so.7 =3D> /lib/libc.so.7 (0x1604b3000)
xlrboard# readelf -a /bin/ls
ELF Header:
  Magic:   7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - FreeBSD
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           MIPS R3000
  Version:                           0x1
  Entry point address:               0x120001dd0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          34808 (bytes into file)
  Flags:                             0x60000007, noreorder, pic, cpic, mips=
64
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         6
  Size of section headers:           64 (bytes)
  Number of section headers:         29
  Section header string table index: 28

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         0000000120000190  00000190
       0000000000000015  0000000000000000   A       0     0     1
  [ 2] .note.ABI-tag     NOTE             00000001200001a8  000001a8
       0000000000000018  0000000000000000   A       0     0     4
  [ 3] .MIPS.options     MIPS_OPTIONS     00000001200001c0  000001c0
       0000000000000168  0000000000000001  Ao       0     0     8
  [ 4] .dynamic          DYNAMIC          0000000120000328  00000328
       0000000000000200  0000000000000010   A       7     0     8
  [ 5] .hash             HASH             0000000120000528  00000528
       0000000000000450  0000000000000004   A       6     0     8
  [ 6] .dynsym           DYNSYM           0000000120000978  00000978
....

The .interp offset is reasonable here...

JC.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTimoc9Xd50LgiubDJGKOiUjztF-EfQ>