[lld] [lld][ELF][AVR] Add range check for R_AVR_13_PCREL (PR #67636)

Ben Shi via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 06:31:05 PDT 2023


================
@@ -0,0 +1,33 @@
+; REQUIRES: avr
+; RUN: llvm-mc -filetype=obj -triple=avr -mcpu=atmega328 %s -o %t.o
+; RUN: not ld.lld %t.o -o /dev/null -Ttext=0x1000 --defsym=callee=0xf00 2>&1 | \
+; RUN:     FileCheck %s --check-prefix=CHECKA --implicit-check-not=R_AVR_13_PCREL
+; RUN: not ld.lld %t.o -o /dev/null -Ttext=0x1000 --defsym=callee=0x2048 2>&1 | \
+; RUN:     FileCheck %s --check-prefix=CHECKB --implicit-check-not=R_AVR_CALL
+; RUN: not ld.lld %t.o -o /dev/null -Ttext=0x1000 --defsym=callee=0x100f 2>&1 | \
+; RUN:     FileCheck %s --check-prefix=CHECKC
+
+.section .LDI,"ax", at progbits
+
+.globl __init
+__init:
+
+; CHECKA: error: {{.*}} relocation R_AVR_7_PCREL out of range: {{.*}} is not in [-64, 63]; references 'callee'
+; CHECKB: error: {{.*}} relocation R_AVR_7_PCREL out of range: {{.*}} is not in [-64, 63]; references 'callee'
+; CHECKB: error: {{.*}} relocation R_AVR_13_PCREL out of range: {{.*}} is not in [-4096, 4095]; references 'callee'
+; CHECKC: error: {{.*}} improper alignment for relocation R_AVR_7_PCREL: {{.*}} is not aligned to 2 bytes
+; CHECKC: error: {{.*}} improper alignment for relocation R_AVR_13_PCREL: {{.*}} is not aligned to 2 bytes
+; CHECKC: error: {{.*}} improper alignment for relocation R_AVR_CALL: {{.*}} is not aligned to 2 bytes
+brne  callee
----------------
benshi001 wrote:

Done. Thanks.

https://github.com/llvm/llvm-project/pull/67636


More information about the llvm-commits mailing list