Skip to content

Not all Windows ctor sections are supported #4520

@mmastrac

Description

@mmastrac

#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

No one assigned

    Labels

    A-windowsArea: affects only Windows targetsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions