cpp-stub icon indicating copy to clipboard operation
cpp-stub copied to clipboard

arm platform contructor stub across segmentation fault

Open wuyao721 opened this issue 2 years ago • 2 comments

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 avatar Apr 13 '23 13:04 wuyao721

`template<class T> 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吧。

wuyao721 avatar Apr 13 '23 13:04 wuyao721

是的,只支持x86 @wuyao721

coolxv avatar Apr 16 '23 04:04 coolxv