-
Notifications
You must be signed in to change notification settings - Fork 83
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
Question about relocations and static local variables #17
Comments
Hey! Thank you, I've read that issue, but my question is more about this. static int localStaticVariable = 0;
int getAndIncrement()
{
return localStaticVariable++;
} If we compile it to the object file, we will have smth like this: |
blink handles this by allocating the memory region for the new object file sections as close as possible to the existing code in memory. This way the relative offset should still fit into a 32-bit value. Windows has APIs to allocate memory at a specific virtual address which allow this: Line 40 in 55f2534
Line 199 in 55f2534
|
I see, thank you very much! |
Hi.
Suppose we have this
StaticVar.cpp
file:We're calling
printAndIncrement
each frame. We want to reload this file for some reason. We're expecting to get this output:On linux we cannot use relocation data from the
StaticVar.cpp.o
because such a relocations are 32-bit (probably compiler takes into account the "locality" oflocalStaticVar
relative toprintAndIncrement
), and in general we cannot insert the address of oldlocalStaticVar
into the new version ofprintAndIncrement
. How blink deal with such cases?Thank you!
The text was updated successfully, but these errors were encountered: