Received: from PACIFIC-CARRIER-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA19020; Tue, 12 Dec 95 19:00:20 EST
Received: from pain.lcs.mit.edu by MIT.EDU with SMTP
	id AA12807; Tue, 12 Dec 95 19:00:17 EST
Received: (from daemon@localhost) by pain.lcs.mit.edu (8.6.12/8.6.9) id QAA09480; Tue, 12 Dec 1995 16:28:19 -0500
Received: from mail.fwi.uva.nl by pain.lcs.mit.edu (8.6.12/8.6.9) with ESMTP id QAA09477 for <port-i386@netbsd.org>; Tue, 12 Dec 1995 16:28:14 -0500
Received: from atlas.fwi.uva.nl
          by mail.fwi.uva.nl with ESMTP (sendmail 8.6.12/config 5.15).
          id WAA03903; Tue, 12 Dec 1995 22:28:08 +0100
Received: from localhost
          by atlas.fwi.uva.nl (sendmail 8.6.12/config 5.12).
          id WAA17401; Tue, 12 Dec 1995 22:27:38 +0100
Message-Id: <199512122127.WAA17401@atlas.fwi.uva.nl>
From: frank@fwi.uva.nl (Frank van der Linden)
X-Organisation: Faculty of Mathematics, Computer Science, Physics & Astronomy
                University of Amsterdam
                Kruislaan 403
                NL-1098 SJ Amsterdam
                The Netherlands
X-Phone:        +31 20 525 7463
X-Fax:          +31 20 525 7490
Subject: Re: Linux binaries compiled with libc-5.2.16
To: randy@zyzzyva.com (Randy Terbush)
Date: Tue, 12 Dec 1995 22:27:37 +0100 (MET)
Cc: port-i386@NetBSD.ORG
In-Reply-To: <199512102224.QAA24932@sierra.zyzzyva.com> from "Randy Terbush" at Dec 10, 95 04:24:02 pm
X-Mailer: ELM [version 2.4 PL23]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 1893      
Sender: owner-port-i386@NetBSD.ORG
Precedence: list
X-Loop: port-i386@NetBSD.ORG

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
