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

Adam Lackorzynski adam at
Mon Oct 17 01:18:57 CEST 2011

On Thu Oct 13, 2011 at 21:46:34 +1300, Valery V. Sedletski wrote:
> On Thu, 13 Oct 2011 00:03:54 +0200, Adam Lackorzynski wrote:
> >> minicmd | mmap(): mmap, fd: 0, flags: 34
> >> 
> >> and then from 'loader' server:
> >> 
> >> loader  | os2app,#17: Not allowed to perform any I/O
> >> 
> >> Regarding the loader message, it seems that the app accessed a random region in an I/O memory because of uninitialized variables. But why mmap to
> >> fd: 0, I cannot say. fd=0 is stdin, but I know that malloc accesses the heap but why it uses a memory-mapped files I yet don't know. So, some
> >> troubles are still there, but I hope I'll work it out
> >
> >The flags indicates that anonymous memory is wanted, to the fd does not
> >play any role.
> >
> Thanks for the note! Yes, now I made it working. It really calls mmap() when I am calling malloc(). With malloc(), the pointer to l4env_get_default_dsm()
> was uninitialized. I fixed that and now it works.

> But another strange problem. I had the function which used the 'segments' feature. Now I moved that function from my application to the shared 
> library -- just copied it as is. -- And got an error when trying to compile it: 
> /mnt/data/src/l4env/l4/pkg/os3/pkg/lib/kal/start.c: In function 'trampoline':
> /mnt/data/src/l4env/obj/include/x86/l4v2/l4/sys/segment.h:24:3: error: can't find a register in class 'BREG' while reloading 'asm'

> -- When I comment out the last two lines with fiasco_gdt_set(); and
> fiasco_get_entry_offset(), the error disappears.
> These two functions are in <l4/sys/segment.h>. But what can cause such
> an error? It complains about two assembly
> language inline functions, which are ok. -- I used it as is in my app
> and just moved it in unmodified state
> to the library -- only paths to source files are changed. Maybe,
> anyone encountered such an error before?

The inline asm uses ebx which you cannot do in pic code. I think you
need to fix the asm, like push/pop ebx to/from stack or similar.

Adam                 adam at

More information about the l4-hackers mailing list