[RFC] Memory allocation functions for TLS support in ld-uClibc.so...

Joakim Tjernlund joakim.tjernlund at transmode.se
Wed Sep 28 15:47:54 UTC 2005


> 
> Greetings.
> 
> I wanted some comments and sanity check for some new allocation
> schemes that I need for TLS support in the linker. Specifically
> I need calloc, realloc and free, yes free.
> 
> calloc - I can implement this with normal _dl_malloc and then
>          use _dl_memset. Not a big deal.
> 
> realloc - Again, I should be able to use _dl_malloc and just
>           do some pointer arithmetic to allocate the additional
> 	  space.
> 
> free - Yeah, this is the big one. I am going to be doing a lot
>        of TLS debugging this weekend, so the code that actually
>        calls this may not get exercised for my test cases, but
>        it is need in the case of some failing TLS allocations.
>        Any ideas are welcome.
> 
> I will be implementing these functions and after linking, I will
> use the libc versions of these. I assume that weak functions are
> not used in the linker due to bootstrap relocations? _dl_malloc
> is a function pointer, but it is called so early before any
> linking or relocation takes place that there is not other choice.
> The functions above are called after the linker itself has already
> been relocated, so I would think weak functions would be okay.
> Comments and insights welcome. Thanks.

_dl_malloc_function is a function pointer to avoid running a second
reloc pass of ldso just
to get at libc malloc. Instead ldso just looks up malloc and reassigns
_dl_malloc_function
to point to libc's malloc.

free(), you could define a dummy function and set _dl_free_function to
point at that function
and then let _dl_free do the same as _dl_malloc does.

That said, the dl_malloc and friends could use a big cleanup.

 Jocke 




More information about the uClibc mailing list