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 byte of variable def 16-bit address to r24 + ldi r25, hi8(def) ; Load higher byte of variable def 16-bit address 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,20 @@ +# REQUIRES: avr + +# RUN: llvm-mc -filetype=obj -triple=avr -mcpu=atmega328 %p/Inputs/avr5.s -o %t +# RUN: ld.lld %t -T %s -o %t1 +# RUN: llvm-objdump --mcpu=atmega328 -d %t1 | FileCheck %s +# RUN: ld.lld %t -Ttext=0 -Tdata=0x800 -e _start -o %t2 +# RUN: llvm-objdump -d %t2 | 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,25 @@ +# REQUIRES: avr + +# RUN: llvm-mc -filetype=obj -triple=avr -mcpu=atmega328 %p/Inputs/avr5.s -o %t +# RUN: ld.lld %t -T %s -o %t1 +# RUN: llvm-readelf --headers %t1 | FileCheck %s +# RUN: ld.lld %t -Ttext=0 -Tdata=0x800 -e _start -o %t2 +# RUN: llvm-readelf --headers %t2 | FileCheck %s + +# CHECK: Atmel AVR 8-bit microcontroller +# CHECK: 0x5, EF_AVR_ARCH_AVR5 + +# 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*) } +}