xref: /llvm-project/lld/test/ELF/avr-thunk-ldi-gs.s (revision 229fcad7fc41bf4d1fcf106456bc429f85b37eab)
1; REQUIRES: avr
2; RUN: llvm-mc -filetype=obj -triple=avr -mcpu=atmega2560 %s -o %t.o
3; RUN: ld.lld %t.o --defsym=a=0x1fffe --defsym=b=0x20000 -o %t
4; RUN: llvm-objdump -d --print-imm-hex --no-show-raw-insn --mcpu=atmega2560 %t \
5; RUN:     | FileCheck %s
6
7.section .LDI,"ax",@progbits
8
9;; CHECK-LABEL: <__AVRThunk_b>:
10;; CHECK-NEXT:  110b4: jmp  0x20000
11;; CHECK-LABEL: <__init>:
12;; CHECK-NEXT:  110b8:  ldi r30, 0xff
13;; CHECK-NEXT:  110ba:  ldi r31, 0xff
14;; CHECK-NEXT:  110bc:  eicall
15;; The destination of the following two LDI instructions is
16;; __AVRThunk_b == 0x110b4, so they actually are
17;;                      ldi r30, ((0x110b4) >> 1) & 0xff
18;;                      ldi r31, ((0x110b4) >> 9)
19;; CHECK-NEXT:  110be:  ldi r30, 0x5a
20;; CHECK-NEXT:  110c0:  ldi r31, 0x88
21;; CHECK-NEXT:  110c2:  eicall
22;; CHECK-NOT:   __AVRThunk_a
23
24.globl __init
25__init:
26;; No thunk is needed, since the destination is in range [0, 0x1ffff].
27ldi r30, lo8_gs(a)  ; R_AVR_LO8_LDI_GS
28ldi r31, hi8_gs(a)  ; R_AVR_HI8_LDI_GS
29eicall
30;; A thunk is needed, since the destination is out of range.
31ldi r30, lo8_gs(b)  ; R_AVR_LO8_LDI_GS
32ldi r31, hi8_gs(b)  ; R_AVR_HI8_LDI_GS
33eicall
34