[llvm] r212332 - llvm-readobj: fix MachO relocatoin printing a bit.
Tim Northover
tnorthover at apple.com
Fri Jul 4 03:57:56 PDT 2014
Author: tnorthover
Date: Fri Jul 4 05:57:56 2014
New Revision: 212332
URL: http://llvm.org/viewvc/llvm-project?rev=212332&view=rev
Log:
llvm-readobj: fix MachO relocatoin printing a bit.
There were two issues here:
1. At the very least, scattered relocations cannot use the same code to
determine the corresponding symbol being referred to. For some reason we
pretend there is no symbol, even when one actually exists in the symtab, so to
match this behaviour getRelocationSymbol should simply return symbols_end for
scattered relocations.
2. Printing "-" when we can't get a symbol (including the scattered case, but
not exclusively), isn't that helpful. In both cases there *is* interesting
information in that field, so we should print it. As hex will do.
Small part of rdar://problem/17553104
Modified:
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/test/CodeGen/PowerPC/hello-reloc.s
llvm/trunk/test/MC/AArch64/arm64-leaf-compact-unwind.s
llvm/trunk/test/MC/MachO/eh-frame-reloc.s
llvm/trunk/test/tools/llvm-readobj/relocations.test
llvm/trunk/test/tools/llvm-readobj/sections-ext.test
llvm/trunk/tools/llvm-readobj/MachODumper.cpp
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=212332&r1=212331&r2=212332&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Fri Jul 4 05:57:56 2014
@@ -868,6 +868,9 @@ std::error_code MachOObjectFile::getRelo
symbol_iterator
MachOObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
MachO::any_relocation_info RE = getRelocation(Rel);
+ if (isRelocationScattered(RE))
+ return symbol_end();
+
uint32_t SymbolIdx = getPlainRelocationSymbolNum(RE);
bool isExtern = getPlainRelocationExternal(RE);
if (!isExtern)
Modified: llvm/trunk/test/CodeGen/PowerPC/hello-reloc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/hello-reloc.s?rev=212332&r1=212331&r2=212332&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/hello-reloc.s (original)
+++ llvm/trunk/test/CodeGen/PowerPC/hello-reloc.s Fri Jul 4 05:57:56 2014
@@ -62,17 +62,17 @@ L_.str:
; DARWIN-G4-DUMP:AddressSize: 32bit
; DARWIN-G4-DUMP:Relocations [
; DARWIN-G4-DUMP: Section __text {
-; DARWIN-G4-DUMP: 0x34 1 2 0 PPC_RELOC_BR24 0 -
-; DARWIN-G4-DUMP: 0x30 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 _main
-; DARWIN-G4-DUMP: 0x0 0 2 n/a PPC_RELOC_PAIR 1 _main
-; DARWIN-G4-DUMP: 0x2C 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 _main
-; DARWIN-G4-DUMP: 0x60 0 2 n/a PPC_RELOC_PAIR 1 _main
+; DARWIN-G4-DUMP: 0x34 1 2 0 PPC_RELOC_BR24 0 0x3
+; DARWIN-G4-DUMP: 0x30 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 0x74
+; DARWIN-G4-DUMP: 0x0 0 2 n/a PPC_RELOC_PAIR 1 0x14
+; DARWIN-G4-DUMP: 0x2C 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 0x74
+; DARWIN-G4-DUMP: 0x60 0 2 n/a PPC_RELOC_PAIR 1 0x14
; DARWIN-G4-DUMP: }
; DARWIN-G4-DUMP: Section __picsymbolstub1 {
-; DARWIN-G4-DUMP: 0x14 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 _main
-; DARWIN-G4-DUMP: 0x0 0 2 n/a PPC_RELOC_PAIR 1 _main
-; DARWIN-G4-DUMP: 0xC 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 _main
-; DARWIN-G4-DUMP: 0x18 0 2 n/a PPC_RELOC_PAIR 1 _main
+; DARWIN-G4-DUMP: 0x14 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 0x70
+; DARWIN-G4-DUMP: 0x0 0 2 n/a PPC_RELOC_PAIR 1 0x58
+; DARWIN-G4-DUMP: 0xC 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 0x70
+; DARWIN-G4-DUMP: 0x18 0 2 n/a PPC_RELOC_PAIR 1 0x58
; DARWIN-G4-DUMP: }
; DARWIN-G4-DUMP: Section __la_symbol_ptr {
; DARWIN-G4-DUMP: 0x0 0 2 1 PPC_RELOC_VANILLA 0 dyld_stub_binding_helper
Modified: llvm/trunk/test/MC/AArch64/arm64-leaf-compact-unwind.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/arm64-leaf-compact-unwind.s?rev=212332&r1=212331&r2=212332&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/arm64-leaf-compact-unwind.s (original)
+++ llvm/trunk/test/MC/AArch64/arm64-leaf-compact-unwind.s Fri Jul 4 05:57:56 2014
@@ -23,10 +23,10 @@
// CHECK-NEXT: Reserved1:
// CHECK-NEXT: Reserved2:
// CHECK-NEXT: Relocations [
-// CHECK-NEXT: 0x60 0 3 0 ARM64_RELOC_UNSIGNED 0 -
-// CHECK-NEXT: 0x40 0 3 0 ARM64_RELOC_UNSIGNED 0 -
-// CHECK-NEXT: 0x20 0 3 0 ARM64_RELOC_UNSIGNED 0 -
-// CHECK-NEXT: 0x0 0 3 0 ARM64_RELOC_UNSIGNED 0 -
+// CHECK-NEXT: 0x60 0 3 0 ARM64_RELOC_UNSIGNED 0 0x1
+// CHECK-NEXT: 0x40 0 3 0 ARM64_RELOC_UNSIGNED 0 0x1
+// CHECK-NEXT: 0x20 0 3 0 ARM64_RELOC_UNSIGNED 0 0x1
+// CHECK-NEXT: 0x0 0 3 0 ARM64_RELOC_UNSIGNED 0 0x1
// CHECK-NEXT: ]
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 00000000 00000000 08000000 00000002
Modified: llvm/trunk/test/MC/MachO/eh-frame-reloc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/eh-frame-reloc.s?rev=212332&r1=212331&r2=212332&view=diff
==============================================================================
--- llvm/trunk/test/MC/MachO/eh-frame-reloc.s (original)
+++ llvm/trunk/test/MC/MachO/eh-frame-reloc.s Fri Jul 4 05:57:56 2014
@@ -17,8 +17,8 @@ _bar:
// OLD32: Relocations [
// OLD32-NEXT: Section __eh_frame {
-// OLD32-NEXT: 0x20 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 -
-// OLD32-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 -
+// OLD32-NEXT: 0x20 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 0x0
+// OLD32-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x20
// OLD32-NEXT: }
// OLD32-NEXT: ]
Modified: llvm/trunk/test/tools/llvm-readobj/relocations.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/relocations.test?rev=212332&r1=212331&r2=212332&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/relocations.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/relocations.test Fri Jul 4 05:57:56 2014
@@ -34,8 +34,8 @@ MACHO-I386: Relocations [
MACHO-I386-NEXT: Section __text {
MACHO-I386-NEXT: 0x18 1 2 1 GENERIC_RELOC_VANILLA 0 _SomeOtherFunction
MACHO-I386-NEXT: 0x13 1 2 1 GENERIC_RELOC_VANILLA 0 _puts
-MACHO-I386-NEXT: 0xB 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 -
-MACHO-I386-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 -
+MACHO-I386-NEXT: 0xB 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 0x22
+MACHO-I386-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x8
MACHO-I386-NEXT: }
MACHO-I386-NEXT: ]
@@ -49,17 +49,17 @@ MACHO-X86-64-NEXT:]
MACHO-PPC: Relocations [
MACHO-PPC-NEXT: Section __text {
-MACHO-PPC-NEXT: 0x24 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 -
-MACHO-PPC-NEXT: 0x0 0 2 n/a PPC_RELOC_PAIR 1 -
-MACHO-PPC-NEXT: 0x1C 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 -
-MACHO-PPC-NEXT: 0x58 0 2 n/a PPC_RELOC_PAIR 1 -
-MACHO-PPC-NEXT: 0x18 1 2 0 PPC_RELOC_BR24 0 -
+MACHO-PPC-NEXT: 0x24 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 0x64
+MACHO-PPC-NEXT: 0x0 0 2 n/a PPC_RELOC_PAIR 1 0xC
+MACHO-PPC-NEXT: 0x1C 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 0x64
+MACHO-PPC-NEXT: 0x58 0 2 n/a PPC_RELOC_PAIR 1 0xC
+MACHO-PPC-NEXT: 0x18 1 2 0 PPC_RELOC_BR24 0 0x2
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Section __picsymbolstub1 {
-MACHO-PPC-NEXT: 0x14 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 -
-MACHO-PPC-NEXT: 0x0 0 2 n/a PPC_RELOC_PAIR 1 -
-MACHO-PPC-NEXT: 0xC 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 -
-MACHO-PPC-NEXT: 0x20 0 2 n/a PPC_RELOC_PAIR 1 -
+MACHO-PPC-NEXT: 0x14 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 0x68
+MACHO-PPC-NEXT: 0x0 0 2 n/a PPC_RELOC_PAIR 1 0x48
+MACHO-PPC-NEXT: 0xC 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 0x68
+MACHO-PPC-NEXT: 0x20 0 2 n/a PPC_RELOC_PAIR 1 0x48
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Section __la_symbol_ptr {
MACHO-PPC-NEXT: 0x0 0 2 1 PPC_RELOC_VANILLA 0 dyld_stub_binding_helper
@@ -68,17 +68,17 @@ MACHO-PPC-NEXT: ]
MACHO-PPC64: Relocations [
MACHO-PPC64-NEXT: Section __text {
-MACHO-PPC64-NEXT: 0x24 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x0 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x1C 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x58 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x18 1 2 0 0 -
+MACHO-PPC64-NEXT: 0x24 0 2 n/a 1 0x64
+MACHO-PPC64-NEXT: 0x0 0 2 n/a 1 0xC
+MACHO-PPC64-NEXT: 0x1C 0 2 n/a 1 0x64
+MACHO-PPC64-NEXT: 0x58 0 2 n/a 1 0xC
+MACHO-PPC64-NEXT: 0x18 1 2 0 0 0x2
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Section __picsymbolstub1 {
-MACHO-PPC64-NEXT: 0x14 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x0 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0xC 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x24 0 2 n/a 1 -
+MACHO-PPC64-NEXT: 0x14 0 2 n/a 1 0x6C
+MACHO-PPC64-NEXT: 0x0 0 2 n/a 1 0x48
+MACHO-PPC64-NEXT: 0xC 0 2 n/a 1 0x6C
+MACHO-PPC64-NEXT: 0x24 0 2 n/a 1 0x48
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Section __la_symbol_ptr {
MACHO-PPC64-NEXT: 0x0 0 3 1 0 dyld_stub_binding_helper
@@ -94,7 +94,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Extern: N/A
MACHO-ARM-NEXT: Type: ARM_RELOC_SECTDIFF (2)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0x40
MACHO-ARM-NEXT: Scattered: 1
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -103,7 +103,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Extern: N/A
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0x28
MACHO-ARM-NEXT: Scattered: 1
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -130,7 +130,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 1
MACHO-ARM-NEXT: Extern: 0
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0xFFFFFF
MACHO-ARM-NEXT: Scattered: 0
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -148,7 +148,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 0
MACHO-ARM-NEXT: Extern: 0
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0xFFFFFF
MACHO-ARM-NEXT: Scattered: 0
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -157,7 +157,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Extern: N/A
MACHO-ARM-NEXT: Type: ARM_RELOC_SECTDIFF (2)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0x44
MACHO-ARM-NEXT: Scattered: 1
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -166,7 +166,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Extern: N/A
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0x4
MACHO-ARM-NEXT: Scattered: 1
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: }
Modified: llvm/trunk/test/tools/llvm-readobj/sections-ext.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/sections-ext.test?rev=212332&r1=212331&r2=212332&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/sections-ext.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/sections-ext.test Fri Jul 4 05:57:56 2014
@@ -183,8 +183,8 @@ MACHO-I386-NEXT: Reserved2: 0x0
MACHO-I386-NEXT: Relocations [
MACHO-I386-NEXT: 0x18 1 2 1 GENERIC_RELOC_VANILLA 0 _SomeOtherFunction
MACHO-I386-NEXT: 0x13 1 2 1 GENERIC_RELOC_VANILLA 0 _puts
-MACHO-I386-NEXT: 0xB 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 -
-MACHO-I386-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 -
+MACHO-I386-NEXT: 0xB 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 0x22
+MACHO-I386-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x8
MACHO-I386-NEXT: ]
MACHO-I386-NEXT: Symbols [
MACHO-I386-NEXT: Symbol {
@@ -299,11 +299,11 @@ MACHO-PPC-NEXT: ]
MACHO-PPC-NEXT: Reserved1: 0x0
MACHO-PPC-NEXT: Reserved2: 0x0
MACHO-PPC-NEXT: Relocations [
-MACHO-PPC-NEXT: 0x24 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 -
-MACHO-PPC-NEXT: 0x0 0 2 n/a PPC_RELOC_PAIR 1 -
-MACHO-PPC-NEXT: 0x1C 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 -
-MACHO-PPC-NEXT: 0x58 0 2 n/a PPC_RELOC_PAIR 1 -
-MACHO-PPC-NEXT: 0x18 1 2 0 PPC_RELOC_BR24 0 -
+MACHO-PPC-NEXT: 0x24 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 0x64
+MACHO-PPC-NEXT: 0x0 0 2 n/a PPC_RELOC_PAIR 1 0xC
+MACHO-PPC-NEXT: 0x1C 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 0x64
+MACHO-PPC-NEXT: 0x58 0 2 n/a PPC_RELOC_PAIR 1 0xC
+MACHO-PPC-NEXT: 0x18 1 2 0 PPC_RELOC_BR24 0 0x2
MACHO-PPC-NEXT: ]
MACHO-PPC-NEXT: Symbols [
MACHO-PPC-NEXT: Symbol {
@@ -342,10 +342,10 @@ MACHO-PPC-NEXT: ]
MACHO-PPC-NEXT: Reserved1: 0x0
MACHO-PPC-NEXT: Reserved2: 0x20
MACHO-PPC-NEXT: Relocations [
-MACHO-PPC-NEXT: 0x14 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 -
-MACHO-PPC-NEXT: 0x0 0 2 n/a PPC_RELOC_PAIR 1 -
-MACHO-PPC-NEXT: 0xC 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 -
-MACHO-PPC-NEXT: 0x20 0 2 n/a PPC_RELOC_PAIR 1 -
+MACHO-PPC-NEXT: 0x14 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 0x68
+MACHO-PPC-NEXT: 0x0 0 2 n/a PPC_RELOC_PAIR 1 0x48
+MACHO-PPC-NEXT: 0xC 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 0x68
+MACHO-PPC-NEXT: 0x20 0 2 n/a PPC_RELOC_PAIR 1 0x48
MACHO-PPC-NEXT: ]
MACHO-PPC-NEXT: Symbols [
MACHO-PPC-NEXT: ]
@@ -456,11 +456,11 @@ MACHO-PPC64-NEXT: ]
MACHO-PPC64-NEXT: Reserved1: 0x0
MACHO-PPC64-NEXT: Reserved2: 0x0
MACHO-PPC64-NEXT: Relocations [
-MACHO-PPC64-NEXT: 0x24 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x0 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x1C 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x58 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x18 1 2 0 0 -
+MACHO-PPC64-NEXT: 0x24 0 2 n/a 1 0x64
+MACHO-PPC64-NEXT: 0x0 0 2 n/a 1 0xC
+MACHO-PPC64-NEXT: 0x1C 0 2 n/a 1 0x64
+MACHO-PPC64-NEXT: 0x58 0 2 n/a 1 0xC
+MACHO-PPC64-NEXT: 0x18 1 2 0 0 0x2
MACHO-PPC64-NEXT: ]
MACHO-PPC64-NEXT: Symbols [
MACHO-PPC64-NEXT: Symbol {
@@ -499,10 +499,10 @@ MACHO-PPC64-NEXT: ]
MACHO-PPC64-NEXT: Reserved1: 0x0
MACHO-PPC64-NEXT: Reserved2: 0x20
MACHO-PPC64-NEXT: Relocations [
-MACHO-PPC64-NEXT: 0x14 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x0 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0xC 0 2 n/a 1 -
-MACHO-PPC64-NEXT: 0x24 0 2 n/a 1 -
+MACHO-PPC64-NEXT: 0x14 0 2 n/a 1 0x6C
+MACHO-PPC64-NEXT: 0x0 0 2 n/a 1 0x48
+MACHO-PPC64-NEXT: 0xC 0 2 n/a 1 0x6C
+MACHO-PPC64-NEXT: 0x24 0 2 n/a 1 0x48
MACHO-PPC64-NEXT: ]
MACHO-PPC64-NEXT: Symbols [
MACHO-PPC64-NEXT: ]
@@ -618,7 +618,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Extern: N/A
MACHO-ARM-NEXT: Type: ARM_RELOC_SECTDIFF (2)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0x40
MACHO-ARM-NEXT: Scattered: 1
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -627,7 +627,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Extern: N/A
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0x28
MACHO-ARM-NEXT: Scattered: 1
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -654,7 +654,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 1
MACHO-ARM-NEXT: Extern: 0
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0xFFFFFF
MACHO-ARM-NEXT: Scattered: 0
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -672,7 +672,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 0
MACHO-ARM-NEXT: Extern: 0
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0xFFFFFF
MACHO-ARM-NEXT: Scattered: 0
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -681,7 +681,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Extern: N/A
MACHO-ARM-NEXT: Type: ARM_RELOC_SECTDIFF (2)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0x44
MACHO-ARM-NEXT: Scattered: 1
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
@@ -690,7 +690,7 @@ MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Extern: N/A
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
-MACHO-ARM-NEXT: Symbol: -
+MACHO-ARM-NEXT: Symbol: 0x4
MACHO-ARM-NEXT: Scattered: 1
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: ]
Modified: llvm/trunk/tools/llvm-readobj/MachODumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/MachODumper.cpp?rev=212332&r1=212331&r2=212332&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/MachODumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/MachODumper.cpp Fri Jul 4 05:57:56 2014
@@ -16,6 +16,7 @@
#include "ObjDumper.h"
#include "StreamWriter.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/Object/MachO.h"
#include "llvm/Support/Casting.h"
@@ -309,18 +310,29 @@ void MachODumper::printRelocation(const
const RelocationRef &Reloc) {
uint64_t Offset;
SmallString<32> RelocName;
- StringRef SymbolName;
if (error(Reloc.getOffset(Offset)))
return;
if (error(Reloc.getTypeName(RelocName)))
return;
- symbol_iterator Symbol = Reloc.getSymbol();
- if (Symbol != Obj->symbol_end() && error(Symbol->getName(SymbolName)))
- return;
DataRefImpl DR = Reloc.getRawDataRefImpl();
MachO::any_relocation_info RE = Obj->getRelocation(DR);
bool IsScattered = Obj->isRelocationScattered(RE);
+ SmallString<32> SymbolNameOrOffset("0x");
+ if (IsScattered) {
+ // Scattered relocations don't really have an associated symbol
+ // for some reason, even if one exists in the symtab at the correct address.
+ SymbolNameOrOffset += utohexstr(Obj->getScatteredRelocationValue(RE));
+ } else {
+ symbol_iterator Symbol = Reloc.getSymbol();
+ if (Symbol != Obj->symbol_end()) {
+ StringRef SymbolName;
+ if (error(Symbol->getName(SymbolName)))
+ return;
+ SymbolNameOrOffset = SymbolName;
+ } else
+ SymbolNameOrOffset += utohexstr(Obj->getPlainRelocationSymbolNum(RE));
+ }
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
@@ -332,7 +344,7 @@ void MachODumper::printRelocation(const
else
W.printNumber("Extern", Obj->getPlainRelocationExternal(RE));
W.printNumber("Type", RelocName, Obj->getAnyRelocationType(RE));
- W.printString("Symbol", SymbolName.size() > 0 ? SymbolName : "-");
+ W.printString("Symbol", SymbolNameOrOffset);
W.printNumber("Scattered", IsScattered);
} else {
raw_ostream& OS = W.startLine();
@@ -345,7 +357,7 @@ void MachODumper::printRelocation(const
OS << " " << Obj->getPlainRelocationExternal(RE);
OS << " " << RelocName
<< " " << IsScattered
- << " " << (SymbolName.size() > 0 ? SymbolName : "-")
+ << " " << SymbolNameOrOffset
<< "\n";
}
}
More information about the llvm-commits
mailing list