1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:57:35 +00:00

LibELF: Ignore RISC-V attribute section program header

We have to skip our usual validations, as the checks might not hold for
this program header type (and the checks wouldn't really make sense for
PT_RISCV_ATTRIBUTES either).

PT_RISCV_ATTRIBUTES is defined here:
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/v1.0/riscv-elf.adoc#program-header-table
This commit is contained in:
Sönke Holz 2024-01-04 17:23:37 +01:00 committed by Andrew Kaster
parent bdd92e881f
commit 8b14056adb
2 changed files with 20 additions and 12 deletions

View file

@ -231,6 +231,12 @@ ErrorOr<bool> validate_program_headers(Elf_Ehdr const& elf_header, size_t file_s
for (size_t header_index = 0; header_index < num_program_headers; ++header_index) {
auto& program_header = program_header_begin[header_index];
if (elf_header.e_machine == EM_RISCV && program_header.p_type == PT_RISCV_ATTRIBUTES) {
// TODO: Handle RISC-V attribute section.
// We have to continue here, as `p_memsz` is 0 when using the GNU toolchain
continue;
}
if (program_header.p_filesz > program_header.p_memsz) {
if (verbose)
dbgln("Program header ({}) has p_filesz ({}) larger than p_memsz ({})", header_index, program_header.p_filesz, program_header.p_memsz);