Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations for CRT init function pointers #37

Open
disinvite opened this issue Dec 15, 2024 · 1 comment
Open

Annotations for CRT init function pointers #37

disinvite opened this issue Dec 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@disinvite
Copy link
Collaborator

Back in November, @madebr asked:

Does reccmp have a way to verify global initializations/destructions?
__attribute((constructor))/__attribute((destructor)) for gcc, and function pointers in the .CRT$XC(V|T) section?
https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-initialization
This is usually done by _initterm.

And:

Let's consider this global:

// GLOBAL: LEGO1 0x0123467
std::string g_actor_name = "brickster";

The global only tells us where g_actor_name lives, but we want to also check whether the (non-c++) constructor call is identical.
So I think it also needs a // CONSTRUCTOR: LEGO1 ... annotation.
So is this a combination of decomplint and reccmp?
Do PDB's have information about this?

In LEGO1, there are 7 of these pointers between xc_a and xc_z in .data. The first sets an exit callback with atexit and calls KERNEL32.DLL::SetUnhandledExceptionFilter. No name in the PDB.

The other 6 are thunks that point to the constructor functions. All 12 of those appear to correspond to the S_LPROC32 symbols in cvdump output.

The 6 constructor functions have a corresponding line reference in the LINES section, so it would be possible to add a new CONSTRUCTOR marker type that could run alongside variables and match these up.

@disinvite disinvite added the enhancement New feature or request label Dec 15, 2024
@jonschz
Copy link
Collaborator

jonschz commented Dec 15, 2024

We have already collected a bunch of those references, but they aren't checked - see e.g. https://github.com/isledecomp/isle/blob/2d74f14de09b94f41d2d6bbb47537163b35146a1/LEGO1/lego/legoomni/src/race/legoracers.cpp#L170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants