[Pal] Force PIE executable to be located at address 0x555555554000

Previously, we forced PIE executables to be located at address
0x00400000 (4MB). However, there is a bug in the ELF relocation code
in LibOS that leads to double-relocation. To circumvent this bug,
relocation code checks if the offset was already relocated. But if
the offset itself exceeds the base address of PIE executable (i.e.,
exceeds 4MB), then the offset is not relocated and segfaults follow.
This commit changes base address from 0x00400000 to 0x555555554000,
similar to what Linux does.
This commit is contained in:
Dmitrii Kuvaiskii
2020-04-22 23:56:38 +00:00
parent f1c65d92df
commit a7fe4aefa9
+2 -2
View File
@@ -316,8 +316,8 @@ int _DkAttestationQuote(PAL_PTR user_report_data, PAL_NUM user_report_data_size,
_DkProcessExit(exitcode); \
} while (0)
/* function and definition for loading binaries */
#define DEFAULT_OBJECT_EXEC_ADDR ((void*)0x00400000)
/* Loading ELF binaries */
#define DEFAULT_OBJECT_EXEC_ADDR ((void*)0x555555554000) /* Linux base location for PIE binaries */
enum object_type { OBJECT_RTLD, OBJECT_EXEC, OBJECT_PRELOAD, OBJECT_EXTERNAL };
bool has_elf_magic(const void* header, size_t len);