[PATCH] D139807: [lld][ELF] Support relocation R_AVR_LDS_STS_16 on AVRTiny devices.

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 11 20:02:09 PST 2022


benshi001 added inline comments.


================
Comment at: lld/ELF/Arch/AVR.cpp:175
+  case R_AVR_LDS_STS_16: {
+    if ((calcEFlags() & EF_AVR_ARCH_MASK) != EF_AVR_ARCH_AVRTINY)
+      error(getErrorLocation(loc) + "relocation 'R_AVR_LDS_STS_16' is only "
----------------
The assembler won't emit `R_AVR_LDS_STS_16` for AVRTiny devices. And this check is hard to be tested in the unit tests.


================
Comment at: lld/test/ELF/avr-reloc.s:84
+; HEX:         {{.*}} 40911e00 50931e00
+lds r20, b  ; R_AVR_LDS_STS_16
+sts b, r21  ; R_AVR_LDS_STS_16
----------------
`lds/sts` are 32-bit instructions on non avrtiny devices.


================
Comment at: lld/test/ELF/avrtiny-reloc.s:2
+; REQUIRES: avr
+; RUN: llvm-mc -filetype=obj -triple=avr -mcpu=attiny10 %s -o %t.o
+; RUN: ld.lld %t.o --defsym=a=0x12345678 --defsym=b=30 -o %t
----------------
The reasons why I create a new avrtiny-reloc.s, other than add my tests into the existing avr-reloc.s, are 
1. Some instructions in avr-reloc.s are not supported on avrtiny devices, and the assembler will emit errors.
2. AVRTiny devices have their special relocations which will not be emitted on ordinary avr devices.


================
Comment at: lld/test/ELF/avrtiny-reloc.s:58
+; HEX-LABEL:   section .LDSSTS:
+; HEX:         {{.*}} 4ea15ea9
+lds r20, b  ; R_AVR_LDS_STS_16
----------------
lds/sts are 16-bit instructions on avrtiny devices, while they are 32-bit on ordinary avr devices.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139807/new/

https://reviews.llvm.org/D139807



More information about the llvm-commits mailing list