[PATCH] D106783: [AIX][XCOFF][llvm-readobj] Replace unwrapOrError with reportUniqueWarning
Maryam via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 30 04:07:38 PDT 2021
MaryamBen updated this revision to Diff 363028.
MaryamBen marked an inline comment as done.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106783/new/
https://reviews.llvm.org/D106783
Files:
llvm/test/tools/llvm-readobj/XCOFF/relocations32.yaml
llvm/tools/llvm-readobj/XCOFFDumper.cpp
Index: llvm/tools/llvm-readobj/XCOFFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -134,16 +134,27 @@
if (Sec.Flags != XCOFF::STYP_TEXT && Sec.Flags != XCOFF::STYP_DATA &&
Sec.Flags != XCOFF::STYP_TDATA && Sec.Flags != XCOFF::STYP_DWARF)
continue;
- auto Relocations = unwrapOrError(Obj.getFileName(), Obj.relocations(Sec));
+ auto ErrOrRelocations = Obj.relocations(Sec);
+ if (Error E = ErrOrRelocations.takeError()) {
+ reportUniqueWarning(std::move(E));
+ continue;
+ }
+
+ auto Relocations = *ErrOrRelocations;
if (Relocations.empty())
continue;
W.startLine() << "Section (index: " << Index << ") " << Sec.getName()
<< " {\n";
for (auto Reloc : Relocations) {
- StringRef SymbolName = unwrapOrError(
- Obj.getFileName(), Obj.getSymbolNameByIndex(Reloc.SymbolIndex));
+ Expected<StringRef> ErrOrSymbolName =
+ Obj.getSymbolNameByIndex(Reloc.SymbolIndex);
+ if (Error E = ErrOrSymbolName.takeError()) {
+ reportUniqueWarning(std::move(E));
+ continue;
+ }
+ StringRef SymbolName = *ErrOrSymbolName;
DictScope RelocScope(W, "Relocation");
W.printHex("Virtual Address", Reloc.VirtualAddress);
W.printNumber("Symbol", SymbolName, Reloc.SymbolIndex);
Index: llvm/test/tools/llvm-readobj/XCOFF/relocations32.yaml
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-readobj/XCOFF/relocations32.yaml
@@ -0,0 +1,32 @@
+## Test that we can explicitly specify all the fields.
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj --relocs --expand-relocs %t 2>&1 | FileCheck %s
+
+# CHECK: File: {{.*}}relocations32.yaml.tmp
+# CHECK-NEXT: Format: aixcoff-rs6000
+# CHECK-NEXT: Arch: powerpc
+# CHECK-NEXT: AddressSize: 32bit
+# CHECK-NEXT: Relocations [
+# CHECK-NEXT: Section (index: 2) .data {
+# CHECK-NEXT: {{.*}} warning: {{.*}} Invalid symbol index
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+--- !XCOFF
+FileHeader:
+ MagicNumber: 0x1DF
+Sections:
+ - Name: .text
+ Flags: [ STYP_TEXT ]
+ - Name: .data
+ Flags: [ STYP_DATA ]
+ Relocations:
+ - Address: 0x80
+ Symbol: 0x21
+Symbols:
+ - Name: .text
+ Section: .text
+ NumberOfAuxEntries: 1
+ - Name: .data
+ Section: .data
+ NumberOfAuxEntries: 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106783.363028.patch
Type: text/x-patch
Size: 2633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210730/10f2244d/attachment.bin>
More information about the llvm-commits
mailing list