diff options
Diffstat (limited to 'courgette')
-rw-r--r-- | courgette/disassembler_elf_32.cc | 5 | ||||
-rw-r--r-- | courgette/disassembler_elf_32_x86.cc | 3 | ||||
-rw-r--r-- | courgette/encode_decode_unittest.cc | 5 | ||||
-rwxr-xr-x | courgette/testdata/elf-32-high-bss | bin | 0 -> 7160 bytes |
4 files changed, 11 insertions, 2 deletions
diff --git a/courgette/disassembler_elf_32.cc b/courgette/disassembler_elf_32.cc index ff2b9e0..02a31eb 100644 --- a/courgette/disassembler_elf_32.cc +++ b/courgette/disassembler_elf_32.cc @@ -262,6 +262,9 @@ CheckBool DisassemblerElf32::ParseFile(AssemblyProgram* program) { const Elf32_Shdr *section_header = SectionHeader(section_id); + if (section_header->sh_type == SHT_NOBITS) + continue; + if (!ParseSimpleRegion(file_offset, section_header->sh_offset, program)) @@ -282,8 +285,6 @@ CheckBool DisassemblerElf32::ParseFile(AssemblyProgram* program) { return false; file_offset = section_header->sh_offset + section_header->sh_size; break; - case SHT_NOBITS: - // Fall through case SHT_INIT_ARRAY: // Fall through case SHT_FINI_ARRAY: diff --git a/courgette/disassembler_elf_32_x86.cc b/courgette/disassembler_elf_32_x86.cc index 74496d3..d2c1c86 100644 --- a/courgette/disassembler_elf_32_x86.cc +++ b/courgette/disassembler_elf_32_x86.cc @@ -91,6 +91,9 @@ CheckBool DisassemblerElf32X86::ParseRelocationSection( uint32 section_relocs_count = section_header->sh_size / section_header->sh_entsize; + if (abs32_locations_.empty()) + match = false; + if (abs32_locations_.size() > section_relocs_count) match = false; diff --git a/courgette/encode_decode_unittest.cc b/courgette/encode_decode_unittest.cc index 0e121d6..a3161ce 100644 --- a/courgette/encode_decode_unittest.cc +++ b/courgette/encode_decode_unittest.cc @@ -82,3 +82,8 @@ TEST_F(EncodeDecodeTest, Elf_Small) { std::string file = FileContents("elf-32-1"); TestAssembleToStreamDisassemble(file, 135988); } + +TEST_F(EncodeDecodeTest, Elf_HighBSS) { + std::string file = FileContents("elf-32-high-bss"); + TestAssembleToStreamDisassemble(file, 7308); +} diff --git a/courgette/testdata/elf-32-high-bss b/courgette/testdata/elf-32-high-bss Binary files differnew file mode 100755 index 0000000..b9445c8 --- /dev/null +++ b/courgette/testdata/elf-32-high-bss |