Commit 85a9e246 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Run ctors initializers backwards, see #5435.


Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@mit.edu>
parent ea831740
......@@ -4218,11 +4218,11 @@ ocRunInit_PEi386 ( ObjectCode *oc )
char *secname = cstring_from_section_name(sectab_i->Name, strtab);
if (0 == strcmp(".ctors", (char*)secname)) {
UChar *init_startC = (UChar*)(oc->image) + sectab_i->PointerToRawData;
init_t *init = (init_t*)init_startC;
init_t *init_end = (init_t*)(init_startC + sectab_i->SizeOfRawData);
// I heard that .ctors might need to be run backwards, but
// if that is true then the MinGW toolchain ignores that.
for (; init < init_end; init++) {
init_t *init_start, *init_end, *init;
init_start = (init_t*)init_startC;
init_end = (init_t*)(init_startC + sectab_i->SizeOfRawData);
// ctors are run *backwards*!
for (init = init_end - 1; init >= init_start; init--) {
(*init)(argc, argv, envv);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment