Port-powerpc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

LINUX_COMPAT: ld-2.1.3.so fixed, but it's a ugly hack



Dynamic executables now work with Linux's ld-2.1.3.so.

That's cool, but I was not able to fully understand the problem and to
make a nice workaround. I now have an ugly hack.

The program expects its arguments at address &argc. We shift everything
that is needed on the stack so that it is satisfied with it, and it
works fine with statically linked programs and with dynamically linked
programs linked by ld-1.7.0.so.

With ld-2.1.3.so, there is a new problem: ld.so expects the arguments at
&argc, and it will not link if they are not there, and it seems it
transfers to the program a stack pointer 16 bytes lower than it should.
The program then tries to get its arguments at &argc - 16 bytes, and of
course it fails.

The hack is to get control between ld.so and the executable, and add 16
to the stack pointer. This is done by a small piece of assembly language
that is loaded by the kernel on the stack. We fool ld.so into thinking
this code is the real entry point of the program by modifying the
AT_ENTRY entry in the ELF auxilliary table. 

ld.so does its job, transfer control to our piece of code that adjust
the stack pointer, and then we transfer control to the real program.

It seems to work for my small tests programs, I hope it does not break
anything else.

Now Netscape dumps a core because llseek has a problem. 

-- 
Emmanuel Dreyfus.  
Avec Windows 3.1 ils etaient au bord du gouffre...
Avec Windows 95 ils ont fait un grand bon en avant.
p99dreyf%criens.u-psud.fr@localhost    



Home | Main Index | Thread Index | Old Index