1# REQUIRES: mips 2## Check that we ignore R_MIPS_JALR relocations agains non-function symbols. 3## Older versions of clang were erroneously generating them for function pointers 4## loaded from any table (not just the GOT) as well as against TLS function 5## pointers (when using the local-dynamic model), so we need to ignore these 6## relocations to avoid generating binaries that crash when executed. 7 8# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o 9## Link in another object file with a .bss as a regression test: 10## Previously LLD asserted when skipping over .bss sections when determining the 11## location for a warning/error message. By adding another file with a .bss 12## section before the actual %t.o we can reproduce this case. 13# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %S/Inputs/common.s -o %t-common.o 14# RUN: ld.lld -shared %t-common.o %t.o -o %t.so 2>&1 | FileCheck %s -check-prefix WARNING-MESSAGE 15# RUN: llvm-objdump --no-show-raw-insn --no-leading-addr -d %t.so | FileCheck %s 16 17.set noreorder 18test: 19 .reloc .Ltmp1, R_MIPS_JALR, tls_obj 20.Ltmp1: 21 jr $t9 22 nop 23# 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. 24 25 .reloc .Ltmp2, R_MIPS_JALR, reg_obj 26.Ltmp2: 27 jr $t9 28 nop 29# 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. 30 31 .reloc .Ltmp3, R_MIPS_JALR, untyped 32.Ltmp3: 33 jr $t9 34 nop 35 36## However, we do perform the optimization for untyped symbols: 37untyped: 38 nop 39 40 .type tls_obj,@object 41 .section .tbss,"awT",@nobits 42tls_obj: 43 .word 0 44 45 .type reg_obj,@object 46 .data 47reg_obj: 48 .word 0 49 50# CHECK-LABEL: Disassembly of section .text: 51# CHECK-EMPTY: 52# CHECK-NEXT: <test>: 53# CHECK-NEXT: jr $25 54# CHECK-NEXT: nop 55# CHECK-NEXT: jr $25 56# CHECK-NEXT: nop 57# CHECK-NEXT: b 8 <untyped> 58# CHECK-NEXT: nop 59