cvs commit: ports/devel/gold Makefile
Juergen Lock
nox at jelal.kn-bremen.de
Tue Nov 3 21:37:30 UTC 2009
On Mon, Sep 21, 2009 at 07:11:47PM +0000, Dirk Meyer wrote:
> dinoex 2009-09-21 19:11:47 UTC
>
> FreeBSD ports repository
>
> Modified files:
> devel/gold Makefile
> Log:
> - mark BROKEN for FreeBSD 6.x
> Feature safe: yes
Is this about `exec format error' (ENOEXEC)? We discussed this
yesterday on irc (hi Sprewell! :) and found out that gold can produce
executables that won't run on FreeBSD 7 and 8 too (for him it was
chromium and some test executables on 7.2/i386, for me it was test
executables on 8/amd64, I couldnt reproduce it here on 8 and 7 i386) -
and after some debugging using qemu's gdbstub and a FreeBSD 8/amd64
livefs guest that I scp'd a problem executable into I found out that
its this condition in sys/kern/imgact_elf.c that fails:
http://fxr.watson.org/fxr/source/kern/imgact_elf.c#L721
719 if (phdr[i].p_type == PT_INTERP) {
720 /* Path to interpreter */
721 if (phdr[i].p_filesz > MAXPATHLEN ||
722 phdr[i].p_offset + phdr[i].p_filesz > PAGE_SIZE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
723 return (ENOEXEC);
724 interp = imgp->image_header + phdr[i].p_offset;
725 break;
726 }
727 }
(gdb) p/x phdr[1].p_offset
$11 = 0x1174
(gdb) p/x phdr[1].p_filesz
$12 = 0x15
(gdb)
So it seems our kernel expects this data (path of the `image activator'
aka shared linker aka /libexec/ld-elf.so.1) to be in the first page of
the executable... There is code to print this header in jkoshy's libelf
article,
http://people.freebsd.org/~jkoshy/download/libelf/article.html#SEC.ELF-PHDR
(4.1 Reading a Program Header Table using gelf(3), Figure 13. Printing
the Program Header Table), running that on the above executable gives:
PHDR 2:
p_type 0x6 "PHDR"
p_offset 0x40
p_vaddr 0x400040
p_paddr 0x400040
p_filesz 0x150
p_memsz 0x150
p_flags 0x4 [ read ]
p_align 0x8
PHDR 2:
p_type 0x3 "INTERP"
p_offset 0x1174
^^^^^^ here is the problem
p_vaddr 0x401174
p_paddr 0x401174
p_filesz 0x15
p_memsz 0x15
p_flags 0x4 [ read ]
p_align 0x1
PHDR 2:
p_type 0x1 "LOAD"
p_offset 0x0
p_vaddr 0x400000
p_paddr 0x400000
p_filesz 0x11f8
p_memsz 0x11f8
p_flags 0x5 [ execute read ]
p_align 0x1000
PHDR 2:
p_type 0x1 "LOAD"
p_offset 0x11f8
p_vaddr 0x4021f8
p_paddr 0x4021f8
p_filesz 0x220
p_memsz 0x230
p_flags 0x6 [ read write ]
p_align 0x1000
PHDR 2:
p_type 0x2 "DYNAMIC"
p_offset 0x1238
p_vaddr 0x402238
p_paddr 0x402238
p_filesz 0x140
p_memsz 0x140
p_flags 0x6 [ read write ]
p_align 0x8
PHDR 2:
p_type 0x6474e550 "unknown"
p_offset 0xae8
p_vaddr 0x400ae8
p_paddr 0x400ae8
p_filesz 0x8
p_memsz 0x8
p_flags 0x4 [ read ]
p_align 0x4
HTH,
Juergen
PS: I added the gold author, Ian Lance Taylor, to the Cc, hope thats ok...
More information about the cvs-ports
mailing list