Subject: Re: Linux binaries compiled with libc-5.2.16
To: Randy Terbush <randy@zyzzyva.com>
From: Frank van der Linden <frank@fwi.uva.nl>
List: port-i386
Date: 12/12/1995 22:27:37
Quoting Randy Terbush,

> Has anyone else been able to run binaries with this library
> dependency?  I am not having any problem with 5.0.9 requirements,
> but the latest Linux Java fails to run with the 5.2.16 requirement.


This is a problem not with the libraries, but with the binaries themselves.
The problem is this: in ELF there are no 'text' and 'data' segments in a binary;
there is just a collection of loadable sections. To fit this to the kernel's
idea of an executable as present in memory, you need to find exactly one
section that qualifies as a text segment, and one that qualifies as a data
segment.

Currently, this is done by assuming that r-x is meant a text segment, and
rw- or rwx specifies a data segment. Not unlogical assumptions, looking
at other formats.

Unfortunately, the Linux ELF binaries you are talking about have 2 segments:
one rwx and one rw-. The one with rwx protection is meant as the text segment..
This defeats the exec_elf code. I have no idea how this braindamage occured,
(whee, back to the days of OMAGIC), I just hope someone in the Linux camp will
fix it.

If you really need those binaries to work, apply the following hack to
exec_elf.c:

-------------------------------------------------------------------------------
*** exec_elf.c.orig	Tue Sep 19 15:28:06 1995
--- exec_elf.c	Tue Dec 12 22:09:38 1995
***************
*** 279,284 ****
--- 279,291 ----
           * to two and hope :-(
           * We also assume that the text is r-x, and data is rwx or rw-.
           */
+ 
+ 	extern struct emul emul_linux_elf;
+ 
+ 	if (epp->ep_emul == &emul_linux_elf &&
+ 	    prot == (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE))
+ 		prot &= ~VM_PROT_WRITE;
+ 
  	switch (prot) {
  	case (VM_PROT_READ | VM_PROT_EXECUTE):
  		if (epp->ep_tsize != ELF32_NO_ADDR)

-------------------------------------------------------------------------------
- Frank