[PATCH] D69192: llvm-objdump can error out with an unexpected EOF error if .bss is larger than the file being dumped.
Sid Manning via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 12:32:24 PDT 2019
sidneym updated this revision to Diff 226073.
sidneym added a comment.
Rename and update test.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69192/new/
https://reviews.llvm.org/D69192
Files:
llvm/include/llvm/Object/ELFObjectFile.h
llvm/test/tools/llvm-objdump/X86/elf-disassemble-bss.test
Index: llvm/test/tools/llvm-objdump/X86/elf-disassemble-bss.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/X86/elf-disassemble-bss.test
@@ -0,0 +1,24 @@
+## Check that when BSS is larger than the file llvm-objdump doesn't
+## assert with an unexpected end of file error.
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objdump -D %t | FileCheck %s
+
+# CHECK: Disassembly of section .bss:
+# CHECK: .bss:
+# CHECK-NEXT: ...
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+ Entry: 0x00000000004003E0
+Sections:
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ Address: 0x0000000000601040
+ AddressAlign: 0x0000000000000010
+ Size: 0x0000000000001000
+...
Index: llvm/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/include/llvm/Object/ELFObjectFile.h
+++ llvm/include/llvm/Object/ELFObjectFile.h
@@ -723,6 +723,8 @@
Expected<ArrayRef<uint8_t>>
ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec) const {
const Elf_Shdr *EShdr = getSection(Sec);
+ if (EShdr->sh_type == ELF::SHT_NOBITS)
+ return makeArrayRef((const uint8_t *)base() + EShdr->sh_offset, 0);
if (std::error_code EC =
checkOffset(getMemoryBufferRef(),
(uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69192.226073.patch
Type: text/x-patch
Size: 1550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191022/0b124967/attachment.bin>
More information about the llvm-commits
mailing list