- fixed incorrect autosegs section addresses on macOS

It appeared that getsectbyname() returns address stored in executable header as is, i.e. without adjusting it for ASLR
This commit is contained in:
alexey.lysiuk 2020-11-14 12:16:51 +02:00
parent 18b5928f49
commit 38d29c235b

View file

@ -49,6 +49,7 @@
#include <dbghelp.h>
#elif defined __MACH__
#include <mach-o/getsect.h>
#include <mach-o/ldsyms.h>
#endif
@ -101,10 +102,12 @@ void FAutoSeg::Initialize()
#elif defined __MACH__
if (const struct section_64 *const section = getsectbyname(AUTOSEG_MACH_SEGMENT, name))
unsigned long size;
if (uint8_t *const section = getsectiondata(&_mh_execute_header, AUTOSEG_MACH_SEGMENT, name, &size))
{
begin = reinterpret_cast<void **>(section->addr);
end = reinterpret_cast<void **>(section->addr + section->size);
begin = reinterpret_cast<void **>(section);
end = reinterpret_cast<void **>(section + size);
}
#else // Linux and others with ELF executables