diff --git a/lld/ELF/Arch/AVR.cpp b/lld/ELF/Arch/AVR.cpp --- a/lld/ELF/Arch/AVR.cpp +++ b/lld/ELF/Arch/AVR.cpp @@ -56,6 +56,9 @@ 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 @@ 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 --- a/lld/test/ELF/avr-reloc.s +++ b/lld/test/ELF/avr-reloc.s @@ -96,8 +96,11 @@ .section .DATA,"ax",@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