1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

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.
This commit is contained in:
Andrew Kaster 2022-03-04 18:02:23 -07:00 committed by Andreas Kling
parent 1a8b5ef80a
commit 435a263998
Notes: sideshowbarker 2024-07-17 11:25:37 +09:00

View file

@ -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;
}