How to build glibc with modified malloc which uses shm_open()?

201 Views Asked by At

I am modifying the malloc.c and hooks.c file in glibc library and my modification uses shm_open().

Now to build glibc, the Man page of shm_open() says that I need to link with -lrt.

The problem that I am facing is, as far as I know, librt is produced during the build process of glibc. How can I modify the makefile(s) to build glibc and also link librt?

Or is there any other way to achieve this?

1

There are 1 best solutions below

3
On

Please check if you have to recompile glibc at all. Usually, this is not necessary for replacing malloc. You can interposed glibc's malloc implementation from a DSO if you implement a certain set of functions:

This mechanism relies on ELF symbol interposition (perhaps via LD_PRELOAD).