Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 537300 - dev-scheme/elk-3.99.8 - elk: require: no elf header in a.out file
Summary: dev-scheme/elk-3.99.8 - elk: require: no elf header in a.out file
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Scheme Project
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks: 537306
  Show dependency tree
 
Reported: 2015-01-21 22:53 UTC by cmuelle8
Modified: 2016-08-06 10:59 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
elk-3.99.8.ebuild.patch (elk-3.99.8.ebuild.patch,617 bytes, patch)
2015-01-21 22:54 UTC, cmuelle8
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cmuelle8 2015-01-21 22:53:12 UTC
SYMPTOM
Run elk and issue
  (require 'unix)

at the interpreter prompt. Instead of loading 'elk/unix.so' elk will issue the error message
  require: no elf header in a.out file

Other elk modules affected are
  cave contents elk | grep /elk.*so

/usr/lib64/elk/elk-eval.so
/usr/lib64/elk/xlib.so
/usr/lib64/elk/hack.so
/usr/lib64/elk/bitstring.so
/usr/lib64/elk/regexp.so
/usr/lib64/elk/debug.so
/usr/lib64/elk/gdbm.so
/usr/lib64/elk/record.so
/usr/lib64/elk/struct.so
/usr/lib64/elk/newhandler.so
/usr/lib64/elk/unix.so
/usr/lib64/elk/xaw.so
/usr/lib64/elk/motif.so


REASON
elk-3.99.8 # grep -ri elf32 src/*

src/dump-elf.c:    Elf32_Ehdr *ohdr, *nhdr;
src/dump-elf.c:    Elf32_Shdr *osecthdr, *nsecthdr;
src/dump-elf.c:    Elf32_Phdr *oproghdr, *nproghdr;
src/dump-elf.c:    Elf32_Shdr *obssp;
src/dump-elf.c:    Elf32_Shdr *nbssp, *ndatap;
src/dump-elf.c:    Elf32_Addr ndata;
src/dump-elf.c:    Elf32_Word ndatasize;
src/dump-elf.c:    Elf32_Off ndataoff;
src/dump-elf.c:    ohdr     = (Elf32_Ehdr *)(oaddr);
src/dump-elf.c:    osecthdr = (Elf32_Shdr *)(oaddr + ohdr->e_shoff);
src/dump-elf.c:    oproghdr = (Elf32_Phdr *)(oaddr + ohdr->e_phoff);
src/dump-elf.c:    ndatasize = (Elf32_Addr)((intptr_t)Brk_On_Dump - (intptr_t)ndata);
src/dump-elf.c:    nhdr     = (Elf32_Ehdr *)(naddr);
src/dump-elf.c:    nsecthdr = (Elf32_Shdr *)(naddr + ohdr->e_shoff + ndatasize);
src/dump-elf.c:    nproghdr = (Elf32_Phdr *)(naddr + ohdr->e_phoff);
src/dump-elf.c:        Elf32_Phdr *pp = nproghdr+i;
src/dump-elf.c:        Elf32_Addr ends_at = (pp->p_vaddr + pp->p_filesz + mask) & ~mask;
src/dump-elf.c:        Elf32_Addr bssend = (obssp->sh_addr + mask) & ~mask;
src/dump-elf.c:        Elf32_Phdr *pp = nproghdr+i;
src/dump-elf.c:        Elf32_Shdr *sp = nsecthdr+i;
src/dump-elf.c:        Elf32_Shdr *sp = nsecthdr+i;
src/dump-elf.c:            Elf32_Sym *p = (Elf32_Sym *)(naddr + sp->sh_offset),
src/stab-elf.c:    Elf32_Ehdr  *elf_ehdr_ptr = NULL;
src/stab-elf.c:    Elf32_Shdr  *elf_shdr_ptr = NULL,
src/stab-elf.c:    if ((elf_ehdr_ptr = elf32_getehdr (elf_ptr)) == NULL) {
src/stab-elf.c:        if ((elf_shdr_ptr = elf32_getshdr (elf_scn_ptr)) == NULL)
src/stab-elf.c:        Elf32_Sym *symbol_ptr = elf_data_ptr->d_buf;
src/stab-elf.c:        Elf32_Sym *current_symbol;
src/stab-elf.c:            if (ELF32_ST_TYPE(current_symbol->st_info) != STT_FUNC ||
src/stab-elf.c:                ELF32_ST_BIND(current_symbol->st_info) != STB_GLOBAL) {


CURE
Apply attached patch based on elk-3.99.8.ebuild in main tree.


SEE ALSO
https://www.freebsd.org/cgi/man.cgi?query=elf32_getehdr&sektion=3&manpath=FreeBSD+11-current


Ironically the ebuild is just keyworded ~amd64 when the source originally has been written to work only on 32bit archs.  The patch needs to be applied unconditionally on any 64bit arch/abi and it must not be applied on any 32bit arch/abi.  I have not tested non x86 archs, but suggest to change KEYWORDS to at least include ~x86 once this patch has been picked up.

Reproducible: Always
Comment 1 cmuelle8 2015-01-21 22:54:04 UTC
Created attachment 394552 [details, diff]
elk-3.99.8.ebuild.patch

--- gentoo/dev-scheme/elk/elk-3.99.8.ebuild	2012-11-07 15:05:32.000000000 +0100
+++ myrep/dev-scheme/elk/elk-3.99.8.ebuild	2015-01-21 23:19:46.000000000 +0100
@@ -4,6 +4,8 @@
 
 EAPI="4"
 
+inherit multilib
+
 DESCRIPTION="Scheme implementation designed to be embeddable extension to C/C++ applications"
 HOMEPAGE="http://sam.zoy.org/elk"
 SRC_URI="http://sam.zoy.org/elk/${P}.tar.bz2"
@@ -15,6 +17,12 @@
 
 DEPEND=""
 
+src_prepare() {
+	if has lib64 $(get_libdir); then
+		sed -i -e 's/\([eE][lL][fF]\)32/\164/g' src/*-elf.c
+	fi
+}
+
 src_compile() {
 	# parallel build is broken
 	emake -j1 || die "Make failed!"
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2015-01-22 08:17:59 UTC
Comment on attachment 394552 [details, diff]
elk-3.99.8.ebuild.patch

>+src_prepare() {
>+	if has lib64 $(get_libdir); then

That's a pretty awful test there. Why don't you go with the hidden USE=abi_x86_64 or even USE=amd64 instead?
Comment 3 cmuelle8 2015-01-22 14:36:27 UTC
(In reply to Jeroen Roovers from comment #2)
> Comment on attachment 394552 [details, diff] [details, diff]
> elk-3.99.8.ebuild.patch
> 
> >+src_prepare() {
> >+	if has lib64 $(get_libdir); then
> 
> That's a pretty awful test there. Why don't you go with the hidden
> USE=abi_x86_64 or even USE=amd64 instead?

Because it is for sure that this patch will be needed on all 64bit architectures using an 64bit abi, not just amd64.

I have looked for an eclass function like 'is_64bit_abi' but I did not find any.  Aside from that I presume that its implementation would be very much like that of the get_libdir() one, i.e. following the same logic.

Using get_libdir seems very ok to me, as we need this sed patch _exactly_ when libelk.so goes into lib64/ and _exactly not_ when libelk.so goes into lib32/

If you present a plausible case in which this will/might not work, I am willing to rethink though..

( Of course, if there is a profile with a 64bit abi not putting its libraries into lib64, we'll miss that.  But imho this should be fixed at a different place then, since according to gentoo specs and specifically to multilib spec, 64bit libs ought to be installed in lib64/ )