From a7fe4aefa93275e1985c75e97f59570b075d2128 Mon Sep 17 00:00:00 2001 From: Dmitrii Kuvaiskii Date: Wed, 22 Apr 2020 23:14:38 +0000 Subject: [PATCH] [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. --- Pal/src/pal_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pal/src/pal_internal.h b/Pal/src/pal_internal.h index 16d934bb..ba3ff85f 100644 --- a/Pal/src/pal_internal.h +++ b/Pal/src/pal_internal.h @@ -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);