diff options
author | Andrew Kaster <akaster@serenityos.org> | 2022-03-04 18:02:23 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-05-01 12:42:01 +0200 |
commit | 435a263998440ea880ef1d20b7d3f1c8fb8a5a10 (patch) | |
tree | d3edd21cfa95513dd34c3450c5d91f31eaed6b84 /Userland/Libraries | |
parent | 1a8b5ef80a9c3360547c6817804642b680f2df84 (diff) | |
download | serenity-435a263998440ea880ef1d20b7d3f1c8fb8a5a10.zip |
LibELF: Relax restriction on allowed values of EI_OSABI to allow GNU
This check is here to make sure we only try to load serenity binaries.
However, with -fprofile-instr-generate -fcoverage-mapping, clang
sets the EI_OSABI field to 3, for GNU. The instrumentation uses a lot of
retained COMDAT sections for coverage instrumentation that get the
SHF_GNU_RETAINED section header flag set on them, forcing llvm to set
the ABI to GNU.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibELF/Validation.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibELF/Validation.cpp b/Userland/Libraries/LibELF/Validation.cpp index 24645f2336..c3d01f8dfe 100644 --- a/Userland/Libraries/LibELF/Validation.cpp +++ b/Userland/Libraries/LibELF/Validation.cpp @@ -46,9 +46,10 @@ bool validate_elf_header(ElfW(Ehdr) const& elf_header, size_t file_size, bool ve return false; } - if (ELFOSABI_SYSV != elf_header.e_ident[EI_OSABI]) { + // NOTE: With Clang, -fprofile-instr-generate -fcoverage-mapping sets our ELF ABI Version to 3 b/c of SHF_GNU_RETAIN + if (ELFOSABI_SYSV != elf_header.e_ident[EI_OSABI] && ELFOSABI_LINUX != elf_header.e_ident[EI_OSABI]) { if (verbose) - dbgln("File has unknown OS ABI ({}), expected SYSV(0)!", elf_header.e_ident[EI_OSABI]); + dbgln("File has unknown OS ABI ({}), expected SYSV(0) or GNU/Linux(3)!", elf_header.e_ident[EI_OSABI]); return false; } |