mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-15 23:57:48 +00:00
Right now all of the relocations are 32-bit dwarf, and the relocation
information doesn't return an addend for Rel relocations. Go ahead and use this information to fix relocation handling inside dwarfdump for 32-bit ELF REL. llvm-svn: 171126
This commit is contained in:
parent
4cad811734
commit
c6fa1e95a2
@ -64,6 +64,18 @@ public:
|
|||||||
HasError = true;
|
HasError = true;
|
||||||
return RelocToApply();
|
return RelocToApply();
|
||||||
}
|
}
|
||||||
|
} else if (FileFormat == "ELF32-i386") {
|
||||||
|
switch (RelocType) {
|
||||||
|
case llvm::ELF::R_386_NONE:
|
||||||
|
return visitELF_386_NONE(R);
|
||||||
|
case llvm::ELF::R_386_32:
|
||||||
|
return visitELF_386_32(R, Value);
|
||||||
|
case llvm::ELF::R_386_PC32:
|
||||||
|
return visitELF_386_PC32(R, Value, SecAddr);
|
||||||
|
default:
|
||||||
|
HasError = true;
|
||||||
|
return RelocToApply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return RelocToApply();
|
return RelocToApply();
|
||||||
}
|
}
|
||||||
@ -76,6 +88,28 @@ private:
|
|||||||
|
|
||||||
/// Operations
|
/// Operations
|
||||||
|
|
||||||
|
/// 386-ELF
|
||||||
|
RelocToApply visitELF_386_NONE(RelocationRef R) {
|
||||||
|
return RelocToApply(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ideally the Addend here will be the addend in the data for
|
||||||
|
// the relocation. It's not actually the case for Rel relocations.
|
||||||
|
RelocToApply visitELF_386_32(RelocationRef R, uint64_t Value) {
|
||||||
|
int64_t Addend;
|
||||||
|
R.getAdditionalInfo(Addend);
|
||||||
|
return RelocToApply(Value + Addend, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
RelocToApply visitELF_386_PC32(RelocationRef R, uint64_t Value,
|
||||||
|
uint64_t SecAddr) {
|
||||||
|
int64_t Addend;
|
||||||
|
R.getAdditionalInfo(Addend);
|
||||||
|
uint64_t Address;
|
||||||
|
R.getAddress(Address);
|
||||||
|
return RelocToApply(Value + Addend - Address, 4);
|
||||||
|
}
|
||||||
|
|
||||||
/// X86-64 ELF
|
/// X86-64 ELF
|
||||||
RelocToApply visitELF_X86_64_NONE(RelocationRef R) {
|
RelocToApply visitELF_X86_64_NONE(RelocationRef R) {
|
||||||
return RelocToApply(0, 0);
|
return RelocToApply(0, 0);
|
||||||
|
@ -108,8 +108,8 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
|||||||
= cu->getContext().relocMap().find(*offset_ptr);
|
= cu->getContext().relocMap().find(*offset_ptr);
|
||||||
if (AI != cu->getContext().relocMap().end()) {
|
if (AI != cu->getContext().relocMap().end()) {
|
||||||
const std::pair<uint8_t, int64_t> &R = AI->second;
|
const std::pair<uint8_t, int64_t> &R = AI->second;
|
||||||
Value.uval = R.second;
|
Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize()) +
|
||||||
*offset_ptr += R.first;
|
R.second;
|
||||||
} else
|
} else
|
||||||
Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize());
|
Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize());
|
||||||
break;
|
break;
|
||||||
@ -156,8 +156,7 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
|||||||
= cu->getContext().relocMap().find(*offset_ptr);
|
= cu->getContext().relocMap().find(*offset_ptr);
|
||||||
if (AI != cu->getContext().relocMap().end()) {
|
if (AI != cu->getContext().relocMap().end()) {
|
||||||
const std::pair<uint8_t, int64_t> &R = AI->second;
|
const std::pair<uint8_t, int64_t> &R = AI->second;
|
||||||
Value.uval = R.second;
|
Value.uval = data.getU32(offset_ptr) + R.second;
|
||||||
*offset_ptr += R.first;
|
|
||||||
} else
|
} else
|
||||||
Value.uval = data.getU32(offset_ptr);
|
Value.uval = data.getU32(offset_ptr);
|
||||||
break;
|
break;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
; RUN: llc -mtriple=i686-linux -O0 < %s | FileCheck %s
|
; RUN: llc -mtriple=i686-linux -O0 -filetype=obj -o %t %s
|
||||||
; CHECK: DW_TAG_constant
|
; RUN: llvm-dwarfdump %t | FileCheck %s
|
||||||
; CHECK-NEXT: .long .Lstring3 #{{#?}} DW_AT_name
|
; CHECK: DW_TAG_constant [4]
|
||||||
|
; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000002c] = "ro")
|
||||||
|
|
||||||
define void @foo() nounwind ssp {
|
define void @foo() nounwind ssp {
|
||||||
entry:
|
entry:
|
||||||
|
Loading…
Reference in New Issue
Block a user