-
Notifications
You must be signed in to change notification settings - Fork 390
Open
Labels
A-windowsArea: affects only Windows targetsArea: affects only Windows targetsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement
Description
#4459 implements handling for global ctor functions, but it's missing some details on Windows (I believe it only handles the default link section as-is).
All sections from .CRT$XIA
… .CRT$XIZ
should be called in order, then the functions from .CRT$XCA
… .CRT$XCZ
should be called.
If a link section is in the range of .CRT$XIA
… .CRT$XIZ
, the function must return a usize with zero indicating success. If a function in the section returns non-zero, the process must exit.
If the link section is in any part of the XC*
range it should not return a usize.
initterm
is defined like this in the ReactOS project:
_INITTERMFUN* current = start;
TRACE("(%p,%p)\n",start,end);
while (current<end)
{
if (*current)
{
TRACE("Call init function %p\n",*current);
(**current)();
TRACE("returned\n");
}
current++;
}
}
initterm_e
is defined like so:
{
int res = 0;
TRACE("(%p, %p)\n", table, end);
while (!res && table < end) {
if (*table) {
TRACE("calling %p\n", **table);
res = (**table)();
if (res)
TRACE("function %p failed: 0x%x\n", *table, res);
}
table++;
}
return res;
}
Metadata
Metadata
Assignees
Labels
A-windowsArea: affects only Windows targetsArea: affects only Windows targetsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement