File: arm-undefined-weak.s

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (49 lines) | stat: -rw-r--r-- 1,464 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// REQUIRES: arm
// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: ld.lld --image-base=0x10000000 %t -o %t2
// RUN: llvm-objdump --triple=armv7a-none-linux-gnueabi --no-show-raw-insn -d %t2 | FileCheck %s

/// Check that the ARM ABI rules for undefined weak symbols are applied.
/// Branch instructions are resolved to the next instruction. Undefined
/// Symbols in relative are resolved to the place so S - P + A = A.
/// We place the image-base at 0x10000000 to test that a range extensions thunk
/// is not generated.

 .syntax unified

 .weak target
 .type target, %function
 .weak undefweak2
 .hidden undefweak2
 .type undefweak2, %function

 .text
 .global _start
_start:
/// R_ARM_JUMP24
 b target
/// R_ARM_CALL
 bl target
/// R_ARM_CALL with exchange
 blx target
/// R_ARM_MOVT_PREL
 movt r0, :upper16:target - .
/// R_ARM_MOVW_PREL_NC
 movw r0, :lower16:target - .
/// R_ARM_REL32
 .word target - .

bl_undefweak2:
 bl undefweak2

// CHECK: Disassembly of section .text:
// CHECK-EMPTY:
// CHECK-NEXT: 100100b4 <_start>:
// CHECK-NEXT: 100100b4: b       {{.+}} @ imm = #-4
// CHECK-NEXT: 100100b8: bl      {{.+}} @ imm = #-4
// CHECK-NEXT: 100100bc: bl      {{.+}} @ imm = #-4
// CHECK-NEXT: 100100c0: movt    r0, #0
// CHECK-NEXT: 100100c4: movw    r0, #0
// CHECK:      100100c8: 00 00 00 00     .word   0x00000000
// CHECK-LABEL: <bl_undefweak2>
// CHECK-NEXT:    bl {{.*}} <bl_undefweak2+0x4>