Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Dec 1995 23:10:32 +0800 (WST)
From:      Peter Wemm <peter@jhome.DIALix.COM>
To:        John Dyson <dyson@freefall.freebsd.org>
Cc:        winter@jurai.net, kato@eclogite.eps.nagoya-u.ac.jp, current@freebsd.org
Subject:   Re: Is the Linux emulator not working for you?
Message-ID:  <Pine.BSF.3.91.951216223053.5140F-100000@jhome.DIALix.COM>
In-Reply-To: <199512161409.GAA13508@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 16 Dec 1995, John Dyson wrote:
> > Oh, incidently, I glanced inside the Linux kernel while working on QMAGIC 
> > library support..  It makes reference to "Converting ZMAGIC binaries" if 
> > the file start offset is too small.
> > 
> > I got the impression that it would be possible to convert the 1K file 
> > offset in the Linux ZMAGIC stuff to (say) 4K file offset start so that we 
> > can do proper demand paging to files rather than reading them into swap 
> > immediately...
> > 
> > Then again, I should know better than to say things like this before 
> > checking them out...
> > 
> > -Peter
> > 
> I have been evaluating the possibility of the VM system properly supporting ill
> constructed a.out formats (like those with 1K offset) and it would not
> be too hard.  It would break coherency -- but would add maybe 25-50
> lines of code (very simple.)  Since it is bad (not allowed) to modify a running
> binary anyway, the cost (in functionality) is low.  I definitely plan
> to add it for 2.2.  But if someone has a better (easier) solution -- PLEASE
> go for it!!!
> 
> John
> dyson@freebsd.org


I was kinda thinking of defining a new executable magic number, say
#define LMAGIC 0414	/* Like Linux ZMAGIC(0413) but remapped to 4K */
and in the linux emulator parts of the kernel, add a case for LMAGIC, with 
file offset at 4096.

And run the following quick skeleton filter like program...
 ..
  struct exec hdr;
 ..
  read(infd, &hdr, sizeof(hdr)
  if (N_GETMAGIC(hdr) == ZMAGIC) && N_GETMID(hdr) & 0xff == 0x64) {
	hdr.a_midmag = (hdr.a_midmag & 0xffff0000) | LMAGIC;
	write(outfd, &hdr, sizeof(hdr));
	lseek(infd, 1024, SEEK_SET);	
	lseek(outfd, 4096, SEEK_SET);
  } else {
	write(outfd, &hdr, sizeof(hdr));
  }
  copyfile(infd, outfd);
 ..

Would a once-off optional pass over the ZMAGIC executables be an option for 
people so they can get the benefits of demand paging and shared text 
segments working for converted ZMAGIC binaries?

The ability to run unmodified ZMAGIC would not be affected..  they would 
still consume large amounts of swap space..

-Peter




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.951216223053.5140F-100000>