SixWeining created this revision.
SixWeining added reviewers: DavidSpickett, labath, davide, xen0n, wangleiat,
MaskRay.
Herald added a subscriber: emaste.
Herald added a project: All.
SixWeining requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
According to `/usr/include/elf.h` and
`lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h`.
For ELF64 relocation, types of `offset` and `addend` should be `uint64_t` and
`int64_t`.
Depends on D145462 <https://reviews.llvm.org/D145462>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145550
Files:
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/test/Shell/ObjectFile/ELF/loongarch64-relocations.yaml
Index: lldb/test/Shell/ObjectFile/ELF/loongarch64-relocations.yaml
===================================================================
--- lldb/test/Shell/ObjectFile/ELF/loongarch64-relocations.yaml
+++ lldb/test/Shell/ObjectFile/ELF/loongarch64-relocations.yaml
@@ -8,7 +8,7 @@
## Before relocation:
## 0000: 00000000 00000000 00000000
## After relocation:
-# CHECK-NEXT: 0000: 34120000 78560000 00000000
+# CHECK-NEXT: 0000: 34120000 88776655 44332211
# CHECK-NEXT: )
--- !ELF
@@ -34,7 +34,7 @@
- Offset: 0x0000000000000004
Symbol: .debug_str
Type: R_LARCH_64
- Addend: 0x5678
+ Addend: 0x1122334455667788
Symbols:
- Name: .debug_str
Type: STT_SECTION
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -116,11 +116,11 @@
static unsigned RelocOffset32(const ELFRelocation &rel);
- static unsigned RelocOffset64(const ELFRelocation &rel);
+ static uint64_t RelocOffset64(const ELFRelocation &rel);
static unsigned RelocAddend32(const ELFRelocation &rel);
- static unsigned RelocAddend64(const ELFRelocation &rel);
+ static int64_t RelocAddend64(const ELFRelocation &rel);
bool IsRela() { return (reloc.is<ELFRela *>()); }
@@ -192,7 +192,7 @@
return rel.reloc.get<ELFRela *>()->r_offset;
}
-unsigned ELFRelocation::RelocOffset64(const ELFRelocation &rel) {
+uint64_t ELFRelocation::RelocOffset64(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return rel.reloc.get<ELFRel *>()->r_offset;
else
@@ -206,7 +206,7 @@
return rel.reloc.get<ELFRela *>()->r_addend;
}
-unsigned ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
+int64_t ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return 0;
else
Index: lldb/test/Shell/ObjectFile/ELF/loongarch64-relocations.yaml
===================================================================
--- lldb/test/Shell/ObjectFile/ELF/loongarch64-relocations.yaml
+++ lldb/test/Shell/ObjectFile/ELF/loongarch64-relocations.yaml
@@ -8,7 +8,7 @@
## Before relocation:
## 0000: 00000000 00000000 00000000
## After relocation:
-# CHECK-NEXT: 0000: 34120000 78560000 00000000
+# CHECK-NEXT: 0000: 34120000 88776655 44332211
# CHECK-NEXT: )
--- !ELF
@@ -34,7 +34,7 @@
- Offset: 0x0000000000000004
Symbol: .debug_str
Type: R_LARCH_64
- Addend: 0x5678
+ Addend: 0x1122334455667788
Symbols:
- Name: .debug_str
Type: STT_SECTION
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -116,11 +116,11 @@
static unsigned RelocOffset32(const ELFRelocation &rel);
- static unsigned RelocOffset64(const ELFRelocation &rel);
+ static uint64_t RelocOffset64(const ELFRelocation &rel);
static unsigned RelocAddend32(const ELFRelocation &rel);
- static unsigned RelocAddend64(const ELFRelocation &rel);
+ static int64_t RelocAddend64(const ELFRelocation &rel);
bool IsRela() { return (reloc.is<ELFRela *>()); }
@@ -192,7 +192,7 @@
return rel.reloc.get<ELFRela *>()->r_offset;
}
-unsigned ELFRelocation::RelocOffset64(const ELFRelocation &rel) {
+uint64_t ELFRelocation::RelocOffset64(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return rel.reloc.get<ELFRel *>()->r_offset;
else
@@ -206,7 +206,7 @@
return rel.reloc.get<ELFRela *>()->r_addend;
}
-unsigned ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
+int64_t ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return 0;
else
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits