Subject: Re: Topdown UVM breaking COMPAT_IRIX?
To: Emmanuel Dreyfus <manu@netbsd.org>
From: Matt Thomas <matt@3am-software.com>
List: tech-kern
Date: 08/02/2003 14:55:53
On Saturday, August 2, 2003, at 02:17 PM, Emmanuel Dreyfus wrote:
> Hi
>
> COMPAT_IRIX has been broken for a few months, I'm not 100% sure, but I
> suspect it's related to this commit:
>
> http://cvsweb.netbsd.org/bsdweb.cgi/
> src/sys/kern/exec_elf32.c.diff?r1=1.82&r2=1.83&f=h
>
> When I run an IRIX program, the kernel loads the interpreter at a
> default address it chooses itself, and it prepare the user register so
> that control is transfered to the interpreter entry point, relocated to
> its actual position. That works, the interpreter starts up.
>
> But IRIX's dynamic linker does not seems to be relocatable. So quickly,
> the interpreter code does a jump at an absolute address, where it
> expects to find another dynamic linker routine. As we relocated it, it
> jumps in the middle of nowhere and crashes (memory fault: there is
> nothing mapped there).
>
> Program startup:
> 0xe0774 in ?? ()
> (gdb) x/4i $pc
> 0xe0774: bal 0xe077c
> 0xe0778: nop
> 0xe077c: lui gp,0x7
> 0xe0780: addiu gp,gp,31604
> [ok, this is the interpreter start code, as observed with objdump]
> (gdb) c
> Continuing.
>
> Program received signal SIGSEGV, Segmentation fault.
> 0xfa85850 in ?? ()
>
> In the ELF headers, interpreter's startup is at 0xfae0774. This is
> where
> IRIX starts it, and this is also what objdump tells me.
>
> First question: does that analysis seem right?
> Second question: if it's right, how to fix that?
>
> I see two ways of fising that. First way is to modify elf_load_file()
> so
> that it searches the ELF headers for the interpreter load address and
> use that address.
> Second way is to use the ability of elf_load_file') to get the
> interpreter load address from the probe function. I could look for the
> intepreter load address in irix_probe_{n,o}32(), and hand it to
> elf_load_file().
The solution is to have the probe function return the initial address
to load the interpeter at. If non zero, use it along with VMCMD_FIXED
to force the image to be loaded at the specified address. Everything
else will happen automagically.
--
Matt Thomas email: matt@3am-software.com
3am Software Foundry www:
http://3am-software.com/bio/matt/ Cupertino, CA
disclaimer: I avow all knowledge of this message.