You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example program:
-------------------------
#include <stdio.h>
int met_you = 0;
void call_me_maybe() {
met_you = 1;
}
typedef void (*FPTR)();
#pragma data_seg(".CRT$XIB")
// Put a global callback in the right section
// to be invoked before the CRT initializers.
FPTR run_on_startup = call_me_maybe;
#pragma data_seg()
// Back to normal compilation.
// __xi_a and __xi_z are defined in VC/crt/src/crt0dat.c
// and are located in .CRT$XIA and .CRT$XIZ respectively.
extern "C" FPTR __xi_a, __xi_z;
int main() {
if (!met_you) {
printf("this is crazy\n");
return 1;
}
// Helps debugging.
printf("&run_on_startup = %p, call_me_maybe = %p\n",
&run_on_startup, call_me_maybe);
// Iterate through CRT initializers.
for (FPTR* it = &__xi_a; it < &__xi_z; ++it)
printf(".CRT$XI*: %p => %p\n", it, *it);
}
-------------------------
Background:
.CRT$XIA...XIZ sections are arrays of callbacks to be invoked at CRT initialization
time in a for loop (unless an entry is zero). One can add an extra initialization
callback simply by defining a global function pointer in the appropriate section.
The problem is that ASan happily adds redzones after these globals, thus breaks typical
traversal of the list of callbacks. We should probably just disable adding redzones
for globals in ".CRT*$*" sections.
Reported by timurrrr@google.com on 2014-05-05 13:11:24
The text was updated successfully, but these errors were encountered:
Originally reported on Google Code with ID 305
Reported by
timurrrr@google.com
on 2014-05-05 13:11:24The text was updated successfully, but these errors were encountered: