llvm-readobj: fix off-by-one error in COFFDumper
It printed out base relocation table header as table entry. This patch also makes llvm-readobj to not skip ABSOLUTE entries becuase it was confusing. llvm-svn: 222299
This commit is contained in:
@@ -1491,7 +1491,7 @@ void BaseRelocRef::moveNext() {
|
|||||||
// Header->BlockSize is the size of the current block, including the
|
// Header->BlockSize is the size of the current block, including the
|
||||||
// size of the header itself.
|
// size of the header itself.
|
||||||
uint32_t Size = sizeof(*Header) +
|
uint32_t Size = sizeof(*Header) +
|
||||||
sizeof(coff_base_reloc_block_entry) * Index;
|
sizeof(coff_base_reloc_block_entry) * (Index + 1);
|
||||||
if (Size == Header->BlockSize) {
|
if (Size == Header->BlockSize) {
|
||||||
// .reloc contains a list of base relocation blocks. Each block
|
// .reloc contains a list of base relocation blocks. Each block
|
||||||
// consists of the header followed by entries. The header contains
|
// consists of the header followed by entries. The header contains
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
RUN: llvm-readobj -coff-basereloc %p/Inputs/basereloc.obj.coff-i386 | FileCheck %s
|
RUN: llvm-readobj -coff-basereloc %p/Inputs/basereloc.obj.coff-i386 | FileCheck %s
|
||||||
|
|
||||||
CHECK: Format: COFF-i386
|
CHECK: Format: COFF-i386
|
||||||
CHECK: Arch: i386
|
CHECK-NEXT: Arch: i386
|
||||||
CHECK: AddressSize: 32bit
|
CHECK-NEXT: AddressSize: 32bit
|
||||||
CHECK: BaseReloc [
|
CHECK-NEXT: BaseReloc [
|
||||||
CHECK: Entry {
|
CHECK-NEXT: Entry {
|
||||||
CHECK: Type: HIGHLOW
|
CHECK-NEXT: Type: HIGHLOW
|
||||||
CHECK: Address: 0x1004
|
CHECK-NEXT: Address: 0x1004
|
||||||
CHECK: }
|
CHECK-NEXT: }
|
||||||
CHECK: Entry {
|
CHECK-NEXT: Entry {
|
||||||
CHECK: Type: HIGHLOW
|
CHECK-NEXT: Type: HIGHLOW
|
||||||
CHECK: Address: 0x100A
|
CHECK-NEXT: Address: 0x100A
|
||||||
CHECK: }
|
CHECK-NEXT: }
|
||||||
CHECK: Entry {
|
CHECK-NEXT: Entry {
|
||||||
CHECK: Type: HIGHLOW
|
CHECK-NEXT: Type: HIGHLOW
|
||||||
CHECK: Address: 0x1010
|
CHECK-NEXT: Address: 0x1010
|
||||||
CHECK: }
|
CHECK-NEXT: }
|
||||||
CHECK: ]
|
CHECK-NEXT: Entry {
|
||||||
|
CHECK-NEXT: Type: ABSOLUTE
|
||||||
|
CHECK-NEXT: Address: 0x1000
|
||||||
|
CHECK-NEXT: }
|
||||||
|
CHECK-NEXT: ]
|
||||||
|
|
||||||
|
|||||||
@@ -1086,7 +1086,7 @@ static StringRef getBaseRelocTypeName(uint8_t Type) {
|
|||||||
case COFF::IMAGE_REL_BASED_HIGHLOW: return "HIGHLOW";
|
case COFF::IMAGE_REL_BASED_HIGHLOW: return "HIGHLOW";
|
||||||
case COFF::IMAGE_REL_BASED_HIGHADJ: return "HIGHADJ";
|
case COFF::IMAGE_REL_BASED_HIGHADJ: return "HIGHADJ";
|
||||||
case COFF::IMAGE_REL_BASED_DIR64: return "DIR64";
|
case COFF::IMAGE_REL_BASED_DIR64: return "DIR64";
|
||||||
default: return "unknown";
|
default: return "unknown (" + std::to_string(Type) + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1099,9 +1099,6 @@ void COFFDumper::printCOFFBaseReloc() {
|
|||||||
continue;
|
continue;
|
||||||
if (error(I.getType(Type)))
|
if (error(I.getType(Type)))
|
||||||
continue;
|
continue;
|
||||||
// IMAGE_REL_BASED_ABSOLUTE is a NOP entry.
|
|
||||||
if (Type == COFF::IMAGE_REL_BASED_ABSOLUTE)
|
|
||||||
continue;
|
|
||||||
DictScope Import(W, "Entry");
|
DictScope Import(W, "Entry");
|
||||||
W.printString("Type", getBaseRelocTypeName(Type));
|
W.printString("Type", getBaseRelocTypeName(Type));
|
||||||
W.printHex("Address", RVA);
|
W.printHex("Address", RVA);
|
||||||
|
|||||||
Reference in New Issue
Block a user