mapping shared libraries at fixed address...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

mapping shared libraries at fixed address...

John Reiser
François-René ÐVB Rideau asked:

> So as to be able to mmap BIG data files on i386, I would like to get
> the shared libraries out of the way.

http://bitwagon.com/tub.html  points to a hack that has worked at times.

> There are three problems:
> (1) ld.so itself is defined as a shared library with no load address
> specification, and the kernel loads it at TASK_UNMAPPED_BASE.

If you're really going for fixed addresses, then build ld.so as ET_EXEC
with some particular base.  On the gcc link commandline: omit "-shared",
then add "-Wl,-Ttext,ORG".  Or, you can change 0x08048000 in the output
of "ld --verbose", then use it as a linker script with argument
"-Wl,--script=SCRIPTFILE".

> (2) ld.so itself must load things at a lower address ...

> (3) the libc itself might use mmap(0,...) ...

Intercepting {mmap, mmap2, mremap} works if you can find them all.
Change the instruction stream to redirect control to your own code
that has its own versions of these routines.  The "tub" hack does this.

--