Add a new function to dlfcn.h?

Y.D. qcloud1014@gmail.com
Sun Aug 16 12:52:00 GMT 2020


Hi all,
I'm trying to add a new function to glibc-2.32, and I'm working on getting
the memory size allocated to a shared object.
To achieve this, I want to use the private fields(l_map_start and
l_map_end) in struct link_map, which is said to be internal to dynamic
linker, so I want to add a function to dlfcn.h, just like dlopen() and
dlclose().

The question is, when I want to imitate the way dlopen works, I find that
the dlopen first calls functions in dlfcn/dlopen.c, and then functions in
elf/dl-open.c, which makes me very confused.
If I want to add a new function in dlfcn.h, what should I do? Do I have to
write a new file under dlfcn/ called dlusage.c, and another called
dl-usage.c under elf/? If this is the case, how should I modify the
Makefile in both directories?
Or can I just append one function in a few existing c files and headers?

Any help will be highly appreciated.

Best,
Fengkai


More information about the Libc-help mailing list