Is there a way to build a non-PIC shared library with l4env?

Valery V. Sedletski _valerius at
Thu Oct 6 09:43:38 CEST 2011

On Sun, 2 Oct 2011 23:00:11 +0200, Adam Lackorzynski wrote:

>On Thu Sep 29, 2011 at 07:01:50 +1300, Valery V. Sedletski wrote:
>No, but adding an extra rule to a Makefile should be easy.

Yes, I copied the rules for compiling *.s.o objects and linking them to * PIC shared  objects
to the local makefile, and changed .s.o to .ss.o and to to make the build system happy,
and deleted $(PICFLAGS) from the rules. Also, I added -Ttext ... to the linker command line. Now it builds 
at a predefined address. 

>> I also hope the 'loader' server will load the shared library at
>> pre-compiled address. Maybe, also the PIC ones could be loaded at
>> desired address (I know that, at least, is loaded at
>> fixed address, but maybe, this is a single hardcoded case)
>Yes, this address is predefined. I'm not sure if it does load such libs,
>just try it.

I then linked my program with a just buillt shared library using -Bdynamic linker option. But when I'm trying
to start the program, it fails when loading the shared library, the error from ldso is "can't map". 
I searched for that string in ldso sources and it appears that the failed fragment is:

preload = (caddr_t) _dl_mmap(0, st.st_size, + 1, PROT_READ | PROT_WRITE | MAP_PRIVATE, fd, 0);

So,  as I understood, it can't load the binary by mmap'ing it at random address. So, does it mean that only loading
at random addresses is supported? What could I do? -- I need this library to be loaded at known address, because
I need it to be the same in all programs' address spaces to have possibility to link to a single copy of this library from
other programs. 

Any suggestions? What could I do? Fork


More information about the l4-hackers mailing list