--- Begin Message ---
When asking a complex question please *also* post your patch to the
code. This allows the reviewer to read the patch, read your question,
and see if anything is missing.
Sorry for not submitting the patch... :-).
Actually the patch for glibc is now rather simple. I separate the system
call, say sigaction, to shift_sigaction; I also separate the helper
functions memcpy and memset to shift_* ones (for these function should
not have instrumentation; however, _dl_start will be compiled with shift
option, which means, it will be instrumented for taint tracking).
Then in rtld.c, at the very start of _dl_start, I use shift_sigaction to
register the special handler. the code is shown below - here
B_hook_shift_sigaction_handler is just a function which calls
shift_sigaction to register a special handler for SIGSEGV:
static ElfW(Addr) __attribute_used__ internal_function
_dl_start (void *arg)
{
/* SHIFT project start */
GEN_NAT_ZERO;
B_hook_shift_sigaction_handler();
/* SHIFT project end */
...
Yes. You should not be making function calls into libc *before* the
dynamic loader has relocated itself.
very interesting, I want to know more details here, I roughly read the
code - here relocation means loading dynamic load into the address
space, right? (on IA64, I found the address of code will change from X
to 0x2000000000000000+X)
You must only install a signal handler after
elf/rtld.c (_dl_start) line 539 in libc cvs head
e.g. bootstrap_map.l_relocated = 1;
Before this line it is not safe to make function calls into libc.
OK, I shall not instrument _dl_start, and put the call to sigaction
after this line.
Thanks again for your help :-)
yours sincerely
Andrew
--- End Message ---