Displaying 3 results from an estimated 3 matches for "__real_malloc".
2017 Dec 27
1
Wrapper functions for standard library functions
Hi,
I would like to wrap some of the library functions such as malloc() into
for example:
malloc_wrapper(int size) {
malloc(size+4); //call the real malloc here
}
and have all uses of malloc replaced with malloc_wrapper. Is there a way to
do that?
--
----------------
Barbora Murinová
The University of Edinburgh
SK: +421905718390 <+421%20905%20718%20390>
UK: +447477833795
2013 Sep 13
0
[LLVMdev] [lld] Implementing the aliasing feature
...ou are wrapping malloc. There will be a malloc seen at build time from libc, and all references to malloc will bind to it. Adding alternate names won’t stop that binding.
Another way to do wrapping (using malloc as the example) is to:
1) introduce (pre-Resolver) an atom (call it X) that is named __real_malloc and has references: 1)to undefined _malloc and 2)undefined __wrap_malloc.
2) add a Pass which get X and looks at the reference to finds what the two references now point to (malloc and __wrap_malloc). It then walks the whole graph and changes references that point to malloc to point to __wrap_mall...
2013 Sep 13
2
[LLVMdev] [lld] Implementing the aliasing feature
Hi Nick,
This would work only if an alias is another name for the same
symbol(weak symbols).
If what is being aliased is another function definition, which is a non
zero sized atom, aliasing will not work.
I was thinking to model this for ELF for the below functionalities :-
a) __wrap
For example : --wrap fn
What I plan to do here is,
create a undefined function fn atom
create a defined