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

arm platform contructor stub across segmentation fault #33

Open
wuyao721 opened this issue Apr 13, 2023 · 2 comments
Open

arm platform contructor stub across segmentation fault #33

wuyao721 opened this issue Apr 13, 2023 · 2 comments

Comments

@wuyao721
Copy link

arm platform contructor stub across segmentation fault

test for windows + docker, success
test for mac(arm) + docker, fails, segment fault when contructor called

I guess function get_dtor_addr may have bug.

@wuyao721
Copy link
Author

`template
void * get_dtor_addr(bool start = true)
{
//the start vairable must be true, or the compiler will optimize out.
if(start) goto Start;
//This line of code will not be executed.
//The purpose of the code is to allow the compiler to generate the assembly code that calls the constructor.
{
T();
Call_dtor:
;;
}

Start:
//The address of the line of code T() obtained by assembly
char * p = (char*)&&Call_dtor;//https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
//CALL rel32
void * ret = 0;
char pos;
char call = 0xe8;
do{
pos = p;
if(pos == call)
{
ret = p + 5 + (
(int*)(p+1));
}

}while(!ret&&(--p));

return ret;

}
`

这只支持x86是吧。arm的call指令不是0xe8吧。

@coolxv
Copy link
Owner

coolxv commented Apr 16, 2023

是的,只支持x86 @wuyao721

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

No branches or pull requests

2 participants