[lld] 504df55 - [lld][ELF] Support relocations R_AVR_8_LO8/R_AVR_8_HI8/R_AVR_8_HLO8
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 28 19:34:04 PDT 2023
Author: Ben Shi
Date: 2023-03-29T10:33:47+08:00
New Revision: 504df554d2ccd86b1d11d25a8e20134f2ad3a43f
URL: https://github.com/llvm/llvm-project/commit/504df554d2ccd86b1d11d25a8e20134f2ad3a43f
DIFF: https://github.com/llvm/llvm-project/commit/504df554d2ccd86b1d11d25a8e20134f2ad3a43f.diff
LOG: [lld][ELF] Support relocations R_AVR_8_LO8/R_AVR_8_HI8/R_AVR_8_HLO8
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D147100
Added:
Modified:
lld/ELF/Arch/AVR.cpp
lld/test/ELF/avr-reloc.s
Removed:
################################################################################
diff --git a/lld/ELF/Arch/AVR.cpp b/lld/ELF/Arch/AVR.cpp
index f0bb8efc4c51..8a5087df4934 100644
--- a/lld/ELF/Arch/AVR.cpp
+++ b/lld/ELF/Arch/AVR.cpp
@@ -56,6 +56,9 @@ RelExpr AVR::getRelExpr(RelType type, const Symbol &s,
case R_AVR_6:
case R_AVR_6_ADIW:
case R_AVR_8:
+ case R_AVR_8_LO8:
+ case R_AVR_8_HI8:
+ case R_AVR_8_HLO8:
case R_AVR_16:
case R_AVR_16_PM:
case R_AVR_32:
@@ -99,6 +102,18 @@ void AVR::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
checkUInt(loc, val, 8, rel);
*loc = val;
break;
+ case R_AVR_8_LO8:
+ checkUInt(loc, val, 32, rel);
+ *loc = val & 0xff;
+ break;
+ case R_AVR_8_HI8:
+ checkUInt(loc, val, 32, rel);
+ *loc = (val >> 8) & 0xff;
+ break;
+ case R_AVR_8_HLO8:
+ checkUInt(loc, val, 32, rel);
+ *loc = (val >> 16) & 0xff;
+ break;
case R_AVR_16:
// Note: this relocation is often used between code and data space, which
// are 0x800000 apart in the output ELF file. The bitmask cuts off the high
diff --git a/lld/test/ELF/avr-reloc.s b/lld/test/ELF/avr-reloc.s
index 9d435137a257..36904f80dabb 100644
--- a/lld/test/ELF/avr-reloc.s
+++ b/lld/test/ELF/avr-reloc.s
@@ -96,8 +96,11 @@ sts b, r21
.section .DATA,"ax", at progbits
; HEX-LABEL: section .DATA:
-; HEX-NEXT: {{.*}} 1e1e000f 00785634 12
+; HEX-NEXT: {{.*}} 1e1e000f 00785634 12785634
.byte b ; R_AVR_8
.short b ; R_AVR_16
.short gs(b) ; R_AVR_16_PM
.long a ; R_AVR_32
+.byte lo8(a) ; R_AVR_8_LO8
+.byte hi8(a) ; R_AVR_8_HI8
+.byte hlo8(a) ; R_AVR_8_HLO8
More information about the llvm-commits
mailing list