Index: lld/ELF/ScriptParser.cpp =================================================================== --- lld/ELF/ScriptParser.cpp +++ lld/ELF/ScriptParser.cpp @@ -415,6 +415,7 @@ static std::pair parseBfdName(StringRef s) { return StringSwitch>(s) .Case("elf32-i386", {ELF32LEKind, EM_386}) + .Case("elf32-avr", {ELF32LEKind, EM_AVR}) .Case("elf32-iamcu", {ELF32LEKind, EM_IAMCU}) .Case("elf32-littlearm", {ELF32LEKind, EM_ARM}) .Case("elf32-x86-64", {ELF32LEKind, EM_X86_64}) Index: lld/test/ELF/linkerscript/Inputs/avr5.s =================================================================== --- /dev/null +++ lld/test/ELF/linkerscript/Inputs/avr5.s @@ -0,0 +1,17 @@ + .text + .globl _start + .p2align 1 +_start: + ldi r24, lo8(def) ; Load lower 8-bit address of variable def to r24 + ldi r25, hi8(def) ; Load higher 8-bit address of variable def to r25 + rjmp _start + + .section .data + .type abc, @object + .type def, @object + .globl abc + .globl def +abc: + .short 100 +def: + .short 200 Index: lld/test/ELF/linkerscript/avr5-relocs.test =================================================================== --- /dev/null +++ lld/test/ELF/linkerscript/avr5-relocs.test @@ -0,0 +1,18 @@ +# REQUIRES: avr + +# RUN: llvm-mc -filetype=obj -triple=avr -mattr=+avr5 %p/Inputs/avr5.s -o %t +# RUN: ld.lld %t --script %s -o %t1 +# RUN: llvm-objdump --mattr=+avr5 -d %t1 | FileCheck %s + +# CHECK: ldi r24, 2 +# CHECK-NEXT: ldi r25, 8 + +OUTPUT_FORMAT("elf32-avr", "elf32-avr", "elf32-avr") +OUTPUT_ARCH(avr:5) + +ENTRY(_start) + +SECTIONS { + .text 0x000: { *(.text*) } + .data 0x800: { *(.data*) } +} Index: lld/test/ELF/linkerscript/avr5-sections.test =================================================================== --- /dev/null +++ lld/test/ELF/linkerscript/avr5-sections.test @@ -0,0 +1,20 @@ +# REQUIRES: avr + +# RUN: llvm-mc -filetype=obj -triple=avr -mattr=+avr5 %p/Inputs/avr5.s -o %t +# RUN: ld.lld %t --script %s -o %t1 +# RUN: llvm-readelf --sections %t1 | FileCheck %s + +# CHECK: Name Type Address Off Size +# CHECK-NEXT: NULL 00000000 000000 000000 +# CHECK-NEXT: .text PROGBITS 00000000 001000 000006 +# CHECK-NEXT: .data PROGBITS 00000800 001800 000004 + +OUTPUT_FORMAT("elf32-avr", "elf32-avr", "elf32-avr") +OUTPUT_ARCH(avr:5) + +ENTRY(_start) + +SECTIONS { + .text 0x000: { *(.text*) } + .data 0x800: { *(.data*) } +}