Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Dec 1997 19:58:33 -0800
From:      John Polstra <jdp@polstra.com>
To:        Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc:        current@FreeBSD.ORG
Subject:   Re: Heads up: recent ld.so changes broke emacs 
Message-ID:  <199712050358.TAA17097@austin.polstra.com>
In-Reply-To: Your message of "Thu, 04 Dec 1997 10:19:30 %2B0100." <7661.881227170@critter.freebsd.dk> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Emacs may think that it has a monopoly on calling sbrk() that would
> be bad :-(

Luckily, that's not it.  The problem, essentially, is that the emacs
executable is invalid.

When emacs is built, first the Makefile builds a virgin version named
"temacs" using normal cc commands.  Then it runs temacs in batch
mode, telling it to load all the common built-in lisp modules.  After
loading them into memory, temacs then "unexec"s itself.  What does
that mean?  It copies its address space out to a file, and fakes up an
a.out header at the beginning of it so that the file can be executed
directly.  That file becomes the emacs that is installed.

Unfortunately, the file isn't quite a valid executable.  The special
symbols "_edata" and "_end", which would normally be be be generated
by the linker, have incorrect values.

The dynamic linker was using the value of "_end" to set the initial
break level that sbrk uses.  Since the value was wrong, the memory
allocations were trampling on emacs data, thereby causing it to
coredump.

To work around the bug, I changed the dynamic linker to calculate its
break level based on the segment sizes in the a.out header.  Luckily,
it can access the header, because under FreeBSD the a.out header is
mapped into memory near the beginning of the program's address space.

Xemacs has a better unexec package, which sets the values of the
special symbols correctly.  That's why it worked but GNU emacs didn't.

I committed the workaround this evening, and everything should
function fine again.

John
--
   John Polstra                                       jdp@polstra.com
   John D. Polstra & Co., Inc.                Seattle, Washington USA
   "Self-knowledge is always bad news."                 -- John Barth



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712050358.TAA17097>