File: mips-jalr-non-functions.s

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (58 lines) | stat: -rw-r--r-- 1,987 bytes parent folder | download | duplicates (7)
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
50
51
52
53
54
55
56
57
58
# REQUIRES: mips
## Check that we ignore R_MIPS_JALR relocations agains non-function symbols.
## Older versions of clang were erroneously generating them for function pointers
## loaded from any table (not just the GOT) as well as against TLS function
## pointers (when using the local-dynamic model), so we need to ignore these
## relocations to avoid generating binaries that crash when executed.

# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o
## Link in another object file with a .bss as a regression test:
## Previously LLD asserted when skipping over .bss sections when determining the
## location for a warning/error message. By adding another file with a .bss
## section before the actual %t.o we can reproduce this case.
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %S/Inputs/common.s -o %t-common.o
# RUN: ld.lld -shared %t-common.o %t.o -o %t.so 2>&1 | FileCheck %s -check-prefix WARNING-MESSAGE
# RUN: llvm-objdump --no-show-raw-insn --no-leading-addr -d %t.so | FileCheck %s

.set	noreorder
test:
  .reloc .Ltmp1, R_MIPS_JALR, tls_obj
.Ltmp1:
  jr  $t9
  nop
# WARNING-MESSAGE: warning: {{.+}}.tmp.o:(.text+0x0): found R_MIPS_JALR relocation against non-function symbol tls_obj. This is invalid and most likely a compiler bug.

  .reloc .Ltmp2, R_MIPS_JALR, reg_obj
.Ltmp2:
  jr  $t9
  nop
# WARNING-MESSAGE: warning: {{.+}}.tmp.o:(.text+0x8): found R_MIPS_JALR relocation against non-function symbol reg_obj. This is invalid and most likely a compiler bug.

  .reloc .Ltmp3, R_MIPS_JALR, untyped
.Ltmp3:
  jr  $t9
  nop

## However, we do perform the optimization for untyped symbols:
untyped:
  nop

  .type  tls_obj,@object
  .section  .tbss,"awT",@nobits
tls_obj:
  .word 0

  .type  reg_obj,@object
  .data
reg_obj:
  .word 0

# CHECK-LABEL: Disassembly of section .text:
# CHECK-EMPTY:
# CHECK-NEXT: <test>:
# CHECK-NEXT: jr	$25
# CHECK-NEXT: nop
# CHECK-NEXT: jr	$25
# CHECK-NEXT: nop
# CHECK-NEXT: b	8 <untyped>
# CHECK-NEXT: nop