Date: Fri, 06 Nov 2009 15:52:37 -0800 From: Ian Lance Taylor <iant@google.com> To: Juergen Lock <nox@jelal.kn-bremen.de> Cc: Dirk Meyer <dinoex@freebsd.org>, cvs-ports@freebsd.org, sprewell@jaggeri.com, cvs-all@freebsd.org, ports-committers@freebsd.org Subject: Re: cvs commit: ports/devel/gold Makefile Message-ID: <mcr639nw6re.fsf@dhcp-172-17-9-151.mtv.corp.google.com> In-Reply-To: <20091103213538.GA61624@triton8.kn-bremen.de> (Juergen Lock's message of "Tue\, 3 Nov 2009 22\:35\:38 %2B0100") References: <200909211911.n8LJBlUK002650@repoman.freebsd.org> <20091103213538.GA61624@triton8.kn-bremen.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Juergen Lock <nox@jelal.kn-bremen.de> writes: > 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... Technically an ELF executable is permitted to have the PT_INTERP segment anywhere it likes, so I think the kernel is in error here. However, it is good practice to put PT_INTERP in the first page of the executable, and I have made that change to gold. So this issue should be fixed in the next release of the GNU binutils. Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?mcr639nw6re.fsf>