Patch: 2.2.13 breaks a.out ZMAGIC libraries

Vincent Zweije (zweije@xs4all.nl)
29 Oct 1999 18:29:28 +0200


--==

* Crossposted to comp.os.linux.development.system and comp.os.linux.misc

* Followups to comp.os.linux.development.system

* CC David Ronis and linux kernel mailing list

In article <g3jR3.3999$6y2.102538@carnaval.risq.qc.ca>, David Ronis
<ronis@gibbs.chem.mcgill.ca> wrote:

|| I've been getting messages like:
||
|| fd_offset is not page aligned. Please convert program: ls
||
|| since I upgraded to 2.2.13 (from .12) on both i586-linux-gnu and
|| i486-linux-libgnu1 boxes. The i486 has a lot of non-elf code, and
|| most of the messages seemed to pertain to them, and indeed, when I
|| replaced them with elf versions, the messages stopped.
||
|| The message about ls happened on the i586 (which is a mixture of libc5
|| and libc6) programs and makes it clear that I don't understand what's
|| going on.
||
|| 1. What is causing the message?

The message is caused by a change in the code to load a.out (specifically,
ZMAGIC) binaries and libraries. The new code requires segments in the
binary format to be (memory-)page aligned, i.e on 4k boundaries, in the
file. This seems to be caused by an alignment change in memory mapping
code. However, the text segment in a ZMAGIC is always 1024-byte aligned.

For non-aligned aout binaries, the kernel now has a compatibility mode.
In principle, nothing is lost, but the code for the binary isn't shared
any more (through mmap).

|| 2. Since it seems to cause no trouble, can I turn it off?

You can locate the warnings in linux/fs/binfmt_aout.c and comment
them out.

|| 3. How do I convert the programs?

I guess by recompiling to QMAGIC a.out or ELF.

In article <7v6slm$ebg@love.sense.znet>, Vincent Zweije <zweije@xs4all.nl>
wrote:

>> When trying to run one aout program, the kernel reports:
>>
>> Oct 24 23:36:22 love kernel: N_TXTOFF is not page aligned. Please convert library: libX11.so.6.0
>>
>> Subsequently, the program aborts with a SIGSEGV where it would run nicely
>> and without warnings on 2.2.12. I don't know if I can convert the
>> library as requested (it is from the now disappeared Debian "xcompat"
>> package), but I can convert the programs that use it to ELF. This is
>> a pain, though.

It turns out that the compatibility code for loading a.out ZMAGIC
libraries (not binaries) forgets to initialise the bss segment. I found
this after some hard searching and fixed it. It seems to work well on my
home machine, which now happily runs a.out ZMAGIC libraries under 2.2.13.

The patch for an unmodified 2.2.13 kernel is appended to this message.
It actually seems to make the kernel smaller. :-) Disclaimer: only
tested on my machine, which is a simple P100/16Mb/partly heavily upgraded
Debian-1.0(?) linux-2.2.13 system.

Ciao. Vincent.

-- 
Vincent Zweije <zweije@xs4all.nl>    | "If you're flamed in a group you
<http://www.xs4all.nl/~zweije/>      | don't read, does anybody get burnt?"
[Xhost should be taken out and shot] |            -- Paul Tomblin on a.s.r.

--== Content-Disposition: attachment; filename="load-zmagic-lib.patch"

--- linux-2.2.13/fs/binfmt_aout.c.nomod Sun Oct 24 09:26:39 1999 +++ linux-2.2.13/fs/binfmt_aout.c Fri Oct 29 14:14:02 1999 @@ -547,17 +547,16 @@ (char *)start_addr, ex.a_text + ex.a_data, 0); flush_icache_range((unsigned long) start_addr, (unsigned long) start_addr + ex.a_text + ex.a_data); - retval = 0; - goto out_putf; + } else { + /* Now use mmap to map the library into memory. */ + error = do_mmap(file, start_addr, ex.a_text + ex.a_data, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE, + N_TXTOFF(ex)); + retval = error; + if (error != start_addr) + goto out_putf; } - /* Now use mmap to map the library into memory. */ - error = do_mmap(file, start_addr, ex.a_text + ex.a_data, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE, - N_TXTOFF(ex)); - retval = error; - if (error != start_addr) - goto out_putf; len = PAGE_ALIGN(ex.a_text + ex.a_data); bss = ex.a_text + ex.a_data + ex.a_bss;

--==--

-- 
Vincent Zweije <zweije@xs4all.nl>    | "If you're flamed in a group you
<http://www.xs4all.nl/~zweije/>      | don't read, does anybody get burnt?"
[Xhost should be taken out and shot] |            -- Paul Tomblin on a.s.r.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/