[PATCH] D87503: [llvm-readobj/elf] - Don't use unwrapOrError when reporting errors about SHT_DYNAMIC sections.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 03:36:55 PDT 2020
grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added subscribers: rupprecht, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
grimar requested review of this revision.
This changes messages reported to stop using dynamic section names (use `describe()` instead).
This allows to avoid `unwrapOrError` and improves diagnostics.
https://reviews.llvm.org/D87503
Files:
llvm/test/tools/llvm-readobj/ELF/dynamic-not-in-pt-dynamic.test
llvm/test/tools/llvm-readobj/ELF/non-dynamic-in-pt-dynamic.test
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1881,19 +1881,17 @@
}
if (DynamicPhdr && DynamicSec) {
- StringRef Name =
- unwrapOrError(ObjF->getFileName(), Obj->getSectionName(DynamicSec));
if (DynamicSec->sh_addr + DynamicSec->sh_size >
DynamicPhdr->p_vaddr + DynamicPhdr->p_memsz ||
DynamicSec->sh_addr < DynamicPhdr->p_vaddr)
- reportWarning(createError("The SHT_DYNAMIC section '" + Name +
- "' is not contained within the "
+ reportWarning(createError(describe(*DynamicSec) +
+ " is not contained within the "
"PT_DYNAMIC segment"),
ObjF->getFileName());
if (DynamicSec->sh_addr != DynamicPhdr->p_vaddr)
- reportWarning(createError("The SHT_DYNAMIC section '" + Name +
- "' is not at the start of "
+ reportWarning(createError(describe(*DynamicSec) +
+ " is not at the start of "
"PT_DYNAMIC segment"),
ObjF->getFileName());
}
Index: llvm/test/tools/llvm-readobj/ELF/non-dynamic-in-pt-dynamic.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/non-dynamic-in-pt-dynamic.test
+++ llvm/test/tools/llvm-readobj/ELF/non-dynamic-in-pt-dynamic.test
@@ -10,7 +10,7 @@
# RUN: llvm-readelf --dynamic-table %t1.o 2>&1 \
# RUN: | FileCheck %s --DFILE=%t1.o --check-prefixes=WARNING,GNU
-# WARNING: warning: '[[FILE]]': The SHT_DYNAMIC section '.dynamic' is not at the start of PT_DYNAMIC segment
+# WARNING: warning: '[[FILE]]': SHT_DYNAMIC section with index 2 is not at the start of PT_DYNAMIC segment
# WARNING: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x21){{$}}
# WARNING: warning: '[[FILE]]': SHT_DYNAMIC section header and PT_DYNAMIC program header disagree about the location of the dynamic table
# WARNING: warning: '[[FILE]]': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used
Index: llvm/test/tools/llvm-readobj/ELF/dynamic-not-in-pt-dynamic.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/dynamic-not-in-pt-dynamic.test
+++ llvm/test/tools/llvm-readobj/ELF/dynamic-not-in-pt-dynamic.test
@@ -11,7 +11,7 @@
# RUN: llvm-readelf --dynamic-table %t1.o 2>&1 \
# RUN: | FileCheck -DFILE=%t1.o --check-prefixes=WARNING1,GNU1 %s
-# WARNING1: warning: '[[FILE]]': The SHT_DYNAMIC section '.dynamic' is not contained within the PT_DYNAMIC segment
+# WARNING1: warning: '[[FILE]]': SHT_DYNAMIC section with index 1 is not contained within the PT_DYNAMIC segment
# WARNING1: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x1){{$}}
# WARNING1: warning: '[[FILE]]': SHT_DYNAMIC section header and PT_DYNAMIC program header disagree about the location of the dynamic table
# WARNING1: warning: '[[FILE]]': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used
@@ -69,7 +69,7 @@
# RUN: llvm-readelf --dynamic-table %t2.o 2>&1 \
# RUN: | FileCheck -DFILE=%t2.o --check-prefixes=WARNING2,GNU2 %s
-# WARNING2: warning: '[[FILE]]': The SHT_DYNAMIC section '.dynamic' is not contained within the PT_DYNAMIC segment
+# WARNING2: warning: '[[FILE]]': SHT_DYNAMIC section with index 1 is not contained within the PT_DYNAMIC segment
# WARNING2: warning: '[[FILE]]': SHT_DYNAMIC section header and PT_DYNAMIC program header disagree about the location of the dynamic table
# LLVM2: DynamicSection [ (1 entries)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87503.291174.patch
Type: text/x-patch
Size: 3733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200911/cc5d473c/attachment.bin>
More information about the llvm-commits
mailing list