Closed CuriousTommy closed 1 year ago
@facekapow
Now that we have access to basically all of the host libc (since it's loaded implicitly by mldr), we could just add elfcalls for the host's malloc and free and use those instead.
Is there an example I can look at on how I should do this? Am I suppose to use wrap_elf
and dlopen
?
@CuriousTommy A fairly simple example would be 176375e9345c4499c0970b496d956516fd7bed0b (minus the changes to src/kernel/emulation/linux/misc/proc_info.c
, of course). No, you don't need wrap_elf
or dlopen
. You basically just need to add entries for malloc
and free
to the struct elf_calls
structure (in src/startup/mldr/elfcalls/elfcalls.h
) and initialize those members in elfcalls_make
(in src/startup/mldr/elfcalls/elfcalls.c
).
Since this is just for xtrace to use them, you don't even need to add the corresponding wrappers in libsystem_kernel; just include <elfcalls.h>
and add an extern struct elf_calls* _elfcalls
declaration.
Tasks
std::string
&std::vector
Test Cases
Single Thread
```c // single_thread_test.c #includeMulti-threaded
```c // multithreaded_thread_test.c #include