Skip to content

Commit 174a38f

Browse files
committed
[LLDB][ObjectFileELF] Correct the return type of RelocOffset64 and RelocAddend64
According to `/usr/include/elf.h` and `lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h`. For ELF64 relocation, types of `offset` and `addend` should be `elf_addr` and `elf_sxword`. Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D145550
1 parent c2c9387 commit 174a38f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ class ELFRelocation {
116116

117117
static unsigned RelocOffset32(const ELFRelocation &rel);
118118

119-
static unsigned RelocOffset64(const ELFRelocation &rel);
119+
static elf_addr RelocOffset64(const ELFRelocation &rel);
120120

121121
static unsigned RelocAddend32(const ELFRelocation &rel);
122122

123-
static unsigned RelocAddend64(const ELFRelocation &rel);
123+
static elf_sxword RelocAddend64(const ELFRelocation &rel);
124124

125125
bool IsRela() { return (reloc.is<ELFRela *>()); }
126126

@@ -192,7 +192,7 @@ unsigned ELFRelocation::RelocOffset32(const ELFRelocation &rel) {
192192
return rel.reloc.get<ELFRela *>()->r_offset;
193193
}
194194

195-
unsigned ELFRelocation::RelocOffset64(const ELFRelocation &rel) {
195+
elf_addr ELFRelocation::RelocOffset64(const ELFRelocation &rel) {
196196
if (rel.reloc.is<ELFRel *>())
197197
return rel.reloc.get<ELFRel *>()->r_offset;
198198
else
@@ -206,7 +206,7 @@ unsigned ELFRelocation::RelocAddend32(const ELFRelocation &rel) {
206206
return rel.reloc.get<ELFRela *>()->r_addend;
207207
}
208208

209-
unsigned ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
209+
elf_sxword ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
210210
if (rel.reloc.is<ELFRel *>())
211211
return 0;
212212
else

lldb/test/Shell/ObjectFile/ELF/loongarch64-relocations.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# CHECK: Name: .debug_info
77
# CHECK: Data: (
88
## Before relocation:
9-
## 0000: 00000000 00000000 00000000
9+
## 0000: 00000000 00000000 00000000 00000000 00000000
1010
## After relocation:
11-
# CHECK-NEXT: 0000: 34120000 78560000 00000000
11+
# CHECK-NEXT: 0000: 34120000 88776655 44332211 8899AABB CCDDEEFF
1212
# CHECK-NEXT: )
1313

1414
--- !ELF
@@ -22,7 +22,7 @@ Sections:
2222
Type: SHT_PROGBITS
2323
- Name: .debug_info
2424
Type: SHT_PROGBITS
25-
Content: 000000000000000000000000
25+
Content: 0000000000000000000000000000000000000000
2626
- Name: .rela.debug_info
2727
Type: SHT_RELA
2828
Info: .debug_info
@@ -34,7 +34,11 @@ Sections:
3434
- Offset: 0x0000000000000004
3535
Symbol: .debug_str
3636
Type: R_LARCH_64
37-
Addend: 0x5678
37+
Addend: 0x1122334455667788
38+
- Offset: 0x000000000000000C
39+
Symbol: .debug_str
40+
Type: R_LARCH_64
41+
Addend: 0xFFEEDDCCBBAA9988
3842
Symbols:
3943
- Name: .debug_str
4044
Type: STT_SECTION

0 commit comments

Comments
 (0)