GP-2098 .bss sections don't need valid file offsets

The ELF loader incorrectly skips NOBITS sections that have invalid file
offsets, like .bss; however, the file offset is ignored for NOBITS
sections.

This is essentially applying #2136 to the file offset as well.
This commit is contained in:
Robert Xiao 2022-03-20 03:54:32 -06:00 committed by ghidra1
parent f718ff9f6f
commit 31f65b4607

View file

@ -2996,7 +2996,8 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
if (type != ElfSectionHeaderConstants.SHT_NULL &&
(includeOtherBlocks || elfSectionToLoad.isAlloc())) {
long fileOffset = elfSectionToLoad.getOffset();
if (fileOffset < 0 || fileOffset >= fileBytes.getSize()) {
if (type != ElfSectionHeaderConstants.SHT_NOBITS &&
(fileOffset < 0 || fileOffset >= fileBytes.getSize())) {
log("Skipping section [" + elfSectionToLoad.getNameAsString() +
"] with invalid file offset");
continue;