1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[DebugInfo] Respect relocations when decoding DW_EH_PE_sdata4 & DW_EH_PE_sdata8 and support R_ARM_REL32

The addresses in llvm-dwarfdump --eh-frame output for object files are closer to readelf -wf output now.
This commit is contained in:
Fangrui Song 2020-07-18 08:59:05 -07:00
parent 85de6c0e87
commit 512d666f40
10 changed files with 30 additions and 19 deletions

View File

@ -104,10 +104,10 @@ DWARFDataExtractor::getEncodedPointer(uint64_t *Offset, uint8_t Encoding,
Result = getSigned(Offset, 2);
break;
case dwarf::DW_EH_PE_sdata4:
Result = getSigned(Offset, 4);
Result = SignExtend64<32>(getRelocatedValue(4, Offset));
break;
case dwarf::DW_EH_PE_sdata8:
Result = getSigned(Offset, 8);
Result = getRelocatedValue(8, Offset);
break;
default:
return None;

View File

@ -521,9 +521,9 @@ Error DWARFDebugFrame::parse(DWARFDataExtractor Data) {
"parsing FDE data at 0x%" PRIx64
" failed due to missing CIE",
StartOffset);
if (auto Val = Data.getEncodedPointer(
&Offset, Cie->getFDEPointerEncoding(),
EHFrameAddress ? EHFrameAddress + Offset : 0)) {
if (auto Val =
Data.getEncodedPointer(&Offset, Cie->getFDEPointerEncoding(),
EHFrameAddress + Offset)) {
InitialLocation = *Val;
}
if (auto Val = Data.getEncodedPointer(

View File

@ -291,12 +291,22 @@ static uint64_t resolvePPC32(RelocationRef R, uint64_t S, uint64_t A) {
}
static bool supportsARM(uint64_t Type) {
return Type == ELF::R_ARM_ABS32;
switch (Type) {
case ELF::R_ARM_ABS32:
case ELF::R_ARM_REL32:
return true;
default:
return false;
}
}
static uint64_t resolveARM(RelocationRef R, uint64_t S, uint64_t A) {
if (R.getType() == ELF::R_ARM_ABS32)
switch (R.getType()) {
case ELF::R_ARM_ABS32:
return (S + A) & 0xFFFFFFFF;
case ELF::R_ARM_REL32:
return (S + A - R.getOffset()) & 0xFFFFFFFF;
}
llvm_unreachable("Invalid relocation type");
}

View File

@ -7,8 +7,7 @@
; CHECK-NOT: warning:
; CHECK: FDE cie=00000000 pc=00000000...00000004
;; TODO Take relocation into consideration
; CHECK: FDE cie=00000000 pc=00000000...00000004
; CHECK: FDE cie=00000000 pc=00000004...00000008
define void @foo() {
entry:

View File

@ -7,8 +7,7 @@
; PPC-NOT: warning:
; PPC: FDE cie=00000000 pc=00000000...00000004
;; TODO Take relocation into consideration
; PPC: FDE cie=00000000 pc=00000000...00000004
; PPC: FDE cie=00000000 pc=00000004...00000008
; RUN: llc -filetype=obj -mtriple=ppc64 %s -o %t64.o
; RUN: llvm-readobj -r %t64.o | FileCheck %s --check-prefix=PPC64_REL
@ -19,7 +18,7 @@
; PPC64-NOT: warning:
; PPC64: FDE cie=00000000 pc=00000000...00000010
; PPC64: FDE cie=00000000 pc=00000000...00000010
; PPC64: FDE cie=00000000 pc=00000010...00000020
; RUN: llc -filetype=obj -mtriple=ppc64le -code-model=large %s -o %t64l.o
; RUN: llvm-readobj -r %t64l.o | FileCheck %s --check-prefix=PPC64L_REL

View File

@ -68,7 +68,8 @@ func:
// DWARF32-EMPTY:
// DWARF32-NEXT: DW_CFA_def_cfa_register: reg29
//
// DWARF32: 00000014 00000010 00000018 FDE cie=00000000 pc=00000000...00000000
// DWARF32_ABS: 00000014 00000010 00000018 FDE cie=00000000 pc=00000000...00000000
// DWARF32_PIC: 00000014 00000010 00000018 FDE cie=00000000 pc=0000001c...0000001c
// DWARF32-NEXT: Format: DWARF32
// DWARF32-NEXT: DW_CFA_nop:
// DWARF32-NEXT: DW_CFA_nop:

View File

@ -9,7 +9,7 @@ CHECK-NOT: pc
RUN: llvm-dwarfdump %p/../../dsymutil/Inputs/basic1.macho.x86_64.o \
RUN: -eh-frame=0x00000018 | FileCheck %s --check-prefix=EH
EH: .eh_frame contents:
EH-NEXT: 00000018 00000024 0000001c FDE cie=00000000 pc=fffffffffffffd00...fffffffffffffd24
EH-NEXT: 00000018 00000024 0000001c FDE cie=00000000 pc=fffffffffffffd20...fffffffffffffd44
EH-NEXT: Format: DWARF32
EH-NEXT: DW_CFA_advance_loc: 1
EH-NOT: pc

View File

@ -12,7 +12,7 @@
# CHECK: DW_CFA_def_cfa: reg31 +0
# CHECK: 00000014 00000020 00000018 FDE cie=00000000 pc=ffffffffffffffe4...00000004
# CHECK: 00000014 00000020 00000018 FDE cie=00000000 pc=00000000...00000020
# CHECK: DW_CFA_advance_loc: 8
# CHECK: DW_CFA_def_cfa_offset: +16
# CHECK: DW_CFA_offset: reg30 -8

View File

@ -10,9 +10,10 @@
# CHECK: Program:
# CHECK-NEXT: DW_CFA_def_cfa: reg31 +0
## FIXME Use getEHFrameSection() so that the address is decoded correctly.
# CHECK: [0x14] FDE length=16 cie=[0x0]
# CHECK-NEXT: initial_location: 0x0
# CHECK-NEXT: address_range: 0x4 (end : 0x4)
# CHECK-NEXT: initial_location: 0x1c
# CHECK-NEXT: address_range: 0x4 (end : 0x20)
# CHECK: Program:
# CHECK-NEXT: DW_CFA_nop:

View File

@ -10,9 +10,10 @@
# CHECK: Program:
# CHECK-NEXT: DW_CFA_def_cfa: reg13 +0
## FIXME Use getEHFrameSection() so that the address is decoded correctly.
# CHECK: [0x14] FDE length=16 cie=[0x0]
# CHECK-NEXT: initial_location: 0x0
# CHECK-NEXT: address_range: 0x4 (end : 0x4)
# CHECK-NEXT: initial_location: 0x1c
# CHECK-NEXT: address_range: 0x4 (end : 0x20)
# CHECK: Program:
# CHECK-NEXT: DW_CFA_nop: