[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / avr-reloc.s
blob49f78044068b97703a42208782149fd1aea3cbcc
1 ; REQUIRES: avr
2 ; RUN: llvm-mc -filetype=obj -triple=avr -mcpu=atmega328p %s -o %t.o
3 ; RUN: ld.lld %t.o --defsym=a=0x12345678 --defsym=b=30 -o %t
4 ; RUN: llvm-objdump -d --print-imm-hex %t | FileCheck %s
5 ; RUN: llvm-objdump -s %t | FileCheck --check-prefix=HEX %s
7 .section .LDI,"ax",@progbits
8 ; CHECK-LABEL: section .LDI:
9 ; CHECK: ldi r20, 0x78
10 ; CHECK-NEXT: ldi r20, 0x56
11 ; CHECK-NEXT: ldi r20, 0x34
12 ; CHECK-NEXT: ldi r20, 0x12
13 ; CHECK-NEXT: ldi r20, 0x3c
14 ; CHECK-NEXT: ldi r20, 0x2b
15 ; CHECK-NEXT: ldi r20, 0x1a
16 ; CHECK-NEXT: ldi r20, 0xff
17 ldi r20, lo8(a) ; R_AVR_LO8_LDI
18 ldi r20, hi8(a) ; R_AVR_HI8_LDI
19 ldi r20, hh8(a) ; R_AVR_HH8_LDI
20 ldi r20, hhi8(a) ; R_AVR_MS8_LDI
22 ldi r20, pm_lo8(a) ; R_AVR_LO8_LDI_PM
23 ldi r20, pm_hi8(a) ; R_AVR_HI8_LDI_PM
24 ldi r20, pm_hh8(a) ; R_AVR_HH8_LDI_PM
26 ldi r20, b+225
28 .section .LDI_NEG,"ax",@progbits
29 ; CHECK-LABEL: section .LDI_NEG:
30 ; CHECK: ldi r20, 0x88
31 ; CHECK-NEXT: ldi r20, 0xa9
32 ; CHECK-NEXT: ldi r20, 0xcb
33 ; CHECK-NEXT: ldi r20, 0xed
34 ; CHECK-NEXT: ldi r20, 0xc4
35 ; CHECK-NEXT: ldi r20, 0xd4
36 ; CHECK-NEXT: ldi r20, 0xe5
37 ldi r20, lo8(-(a)) ; R_AVR_LO8_LDI_NEG
38 ldi r20, hi8(-(a)) ; R_AVR_HI8_LDI_NEG
39 ldi r20, hh8(-(a)) ; R_AVR_HH8_LDI_NEG
40 ldi r20, hhi8(-(a)) ; R_AVR_MS8_LDI_NEG
42 ldi r20, pm_lo8(-(a)) ; R_AVR_LO8_LDI_PM_NEG
43 ldi r20, pm_hi8(-(a)) ; R_AVR_HI8_LDI_PM_NEG
44 ldi r20, pm_hh8(-(a)) ; R_AVR_HH8_LDI_PM_NEG
46 ;; The disassembler is not yet able to decode those opcodes
47 ;; 9e 8e std Y+30, r9
48 ;; 9e 8c ldd r9, Y+30
49 ;; 4e 96 adiw r24, 0x1e
50 .section .SIX,"ax",@progbits
51 ; HEX-LABEL: section .SIX:
52 ; HEX-NEXT: 9e8e9e8c 4e96
53 std Y+b, r9 ; R_AVR_6
54 ldd r9, Y+b ; R_AVR_6
55 adiw r24, b ; R_AVR_6_ADIW
57 .section .PORT,"ax",@progbits
58 ; CHECK-LABEL: section .PORT:
59 ; CHECK: in r20, 0x1e
60 ; CHECK-NEXT: sbic 0x1e, 0x1
61 in r20, b ; R_AVR_PORT6
62 sbic b, 1 ; R_AVR_PORT5
64 ;; The disassembler is not yet able to decode those opcodes
65 ;; 0f c0 rjmp .+30
66 ;; ee cf rjmp .-36
67 ;; 69 f0 breq .+26
68 ;; 61 f3 breq .-40
69 .section .PCREL,"ax",@progbits
70 ; HEX-LABEL: section .PCREL:
71 ; HEX-NEXT: 0fc0eecf 69f061f3
72 foo:
73 rjmp foo + 32 ; R_AVR_13_PCREL
74 rjmp foo - 32 ; R_AVR_13_PCREL
75 breq foo + 32 ; R_AVR_7_PCREL
76 breq foo - 32 ; R_AVR_7_PCREL
78 .section .DATA,"ax",@progbits
79 ; HEX-LABEL: section .DATA:
80 ; HEX-NEXT: {{.*}} 1e1e000f 00785634 12
81 .byte b ; R_AVR_8
82 .short b ; R_AVR_16
83 .short gs(b) ; R_AVR_16_PM
84 .long a ; R_AVR_32