[PATCH] D79339: [llvm-objcopy][ELF] Allow --dump-section to dump an empty non-SHT_NOBITS section
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 5 08:37:14 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32b19334da14: [llvm-objcopy][ELF] Allow --dump-section to dump an empty non-SHT_NOBITS section (authored by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79339/new/
https://reviews.llvm.org/D79339
Files:
llvm/test/tools/llvm-objcopy/ELF/dump-section.test
llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
Index: llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -288,7 +288,7 @@
Object &Obj) {
for (auto &Sec : Obj.sections()) {
if (Sec.Name == SecName) {
- if (Sec.OriginalData.empty())
+ if (Sec.Type == SHT_NOBITS)
return createStringError(object_error::parse_failed,
"cannot dump section '%s': it has no contents",
SecName.str().c_str());
Index: llvm/test/tools/llvm-objcopy/ELF/dump-section.test
===================================================================
--- llvm/test/tools/llvm-objcopy/ELF/dump-section.test
+++ llvm/test/tools/llvm-objcopy/ELF/dump-section.test
@@ -4,9 +4,11 @@
# RUN: llvm-objcopy --dump-section .text=%t4 %t %t5
# RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7
# RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS -DINPUT=%t
+# RUN: llvm-objcopy --dump-section .empty=%t.empty %t /dev/null
# RUN: od -t x1 %t2 | FileCheck %s --ignore-case
# RUN: od -t x1 %t6 | FileCheck %s --ignore-case --check-prefix=NON-ALLOC
# RUN: wc -c %t2 | FileCheck %s --check-prefix=SIZE
+# RUN: wc -c %t.empty | FileCheck %s --check-prefix=EMPTY
# RUN: diff %t2 %t3
# RUN: diff %t4 %t3
@@ -26,6 +28,9 @@
Type: SHT_PROGBITS
Flags: [ SHF_WRITE ]
Content: "CAFE"
+ - Name: .empty
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
- Name: .bar
Type: SHT_NOBITS
Flags: [ SHF_WRITE ]
@@ -42,3 +47,5 @@
# SIZE: 4
# NOBITS: error: '[[INPUT]]': cannot dump section '.bar': it has no contents
+
+# EMPTY: 0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79339.262126.patch
Type: text/x-patch
Size: 1873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200505/c86ed29d/attachment.bin>
More information about the llvm-commits
mailing list