[PATCH] D125544: [lld][ELF] Support linking 'elf32-avr' with linker scripts
Ben Shi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 13 06:43:24 PDT 2022
benshi001 created this revision.
benshi001 added a reviewer: MaskRay.
Herald added subscribers: StephenFan, Jim, arichardson, emaste, dylanmckay.
Herald added a project: All.
benshi001 requested review of this revision.
Herald added subscribers: llvm-commits, jacquesguan.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125544
Files:
lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/Inputs/avr5.s
lld/test/ELF/linkerscript/avr5.test
Index: lld/test/ELF/linkerscript/avr5.test
===================================================================
--- /dev/null
+++ lld/test/ELF/linkerscript/avr5.test
@@ -0,0 +1,28 @@
+# 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-prefix=SEC
+# RUN: llvm-objdump --mattr=+avr5 -d %t1 | FileCheck %s --check-prefix=ASM
+
+# SEC: Name Type Address Off Size
+# SEC-NEXT: NULL 00000000 000000 000000
+# SEC-NEXT: .text PROGBITS 00000000 001000 00000e
+# SEC-NEXT: .data PROGBITS 00000100 001100 000002
+
+# ASM: ldi r24, 10
+# ASM-NEXT: ldi r25, 20
+# ASM-NEXT: sts 257, r25
+# ASM-NEXT: sts 256, r24
+
+OUTPUT_FORMAT("elf32-avr", "elf32-avr", "elf32-avr")
+OUTPUT_ARCH(avr:5)
+
+ENTRY(_start)
+
+SECTIONS {
+ . = 0;
+ .text : { *(.text*) }
+ . = 256;
+ .data : { *(.data*) }
+}
Index: lld/test/ELF/linkerscript/Inputs/avr5.s
===================================================================
--- /dev/null
+++ lld/test/ELF/linkerscript/Inputs/avr5.s
@@ -0,0 +1,15 @@
+ .text
+ .globl _start
+ .p2align 1
+_start:
+ ldi r24, 10
+ ldi r25, 20
+ sts abc+1, r25
+ sts abc, r24
+ rjmp _start
+
+ .type abc, @object
+ .section .data
+ .globl abc
+abc:
+ .short 100
Index: lld/ELF/ScriptParser.cpp
===================================================================
--- lld/ELF/ScriptParser.cpp
+++ lld/ELF/ScriptParser.cpp
@@ -436,6 +436,7 @@
.Case("elf64-littleriscv", {ELF64LEKind, EM_RISCV})
.Case("elf64-sparc", {ELF64BEKind, EM_SPARCV9})
.Case("elf32-msp430", {ELF32LEKind, EM_MSP430})
+ .Case("elf32-avr", {ELF32LEKind, EM_AVR})
.Default({ELFNoneKind, EM_NONE});
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125544.429226.patch
Type: text/x-patch
Size: 1813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220513/4a1f4933/attachment.bin>
More information about the llvm-commits
mailing list