mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibELF: Allow (but ignore) PT_LOAD headers with zero size
GNU ld sometimes generates zero-sized PT_LOAD headers when running with the "-z separate-code" option. Let's not choke on such headers, we can just ignore them and move along.
This commit is contained in:
parent
c853bc2ba6
commit
0819f0a3fd
2 changed files with 2 additions and 6 deletions
|
@ -260,6 +260,8 @@ void DynamicLoader::load_program_headers()
|
||||||
VERIFY(!tls_region.has_value());
|
VERIFY(!tls_region.has_value());
|
||||||
tls_region = region;
|
tls_region = region;
|
||||||
} else if (region.is_load()) {
|
} else if (region.is_load()) {
|
||||||
|
if (region.size_in_memory() == 0)
|
||||||
|
return;
|
||||||
load_regions.append(region);
|
load_regions.append(region);
|
||||||
if (region.is_executable()) {
|
if (region.is_executable()) {
|
||||||
text_regions.append(region);
|
text_regions.append(region);
|
||||||
|
|
|
@ -230,12 +230,6 @@ bool validate_program_headers(const ElfW(Ehdr) & elf_header, size_t file_size, c
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (program_header.p_memsz <= 0 && (program_header.p_type == PT_TLS || program_header.p_type == PT_LOAD)) {
|
|
||||||
if (verbose)
|
|
||||||
dbgln("Program header ({}) has invalid size in memory ({})", header_index, program_header.p_memsz);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (elf_header.e_type != ET_CORE) {
|
if (elf_header.e_type != ET_CORE) {
|
||||||
if (program_header.p_type == PT_LOAD && program_header.p_align == 0) {
|
if (program_header.p_type == PT_LOAD && program_header.p_align == 0) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue