2 ;; LTO-generated relocatable files may reference _GLOBAL_OFFSET_TABLE_ while
3 ;; the IR does not mention _GLOBAL_OFFSET_TABLE_.
4 ;; Test that there is no spurious "undefined symbol" error.
6 ; RUN: rm -rf %t && split-file %s %t && cd %t
7 ; RUN: opt -module-summary b.ll -o b.bc
10 ; RUN: cat a.ll medium.ll | opt -module-summary - -o medium.bc
11 ; RUN: ld.lld -pie --no-relax medium.bc b.bc -o medium
12 ; RUN: llvm-objdump -dt medium | FileCheck %s
15 ; RUN: cat a.ll large.ll | llvm-as - -o large.bc
16 ; RUN: ld.lld -pie large.bc b.bc -o large
17 ; RUN: llvm-objdump -dt large | FileCheck %s
19 ;; Explicit reference of _GLOBAL_OFFSET_TABLE_ is fine.
20 ; RUN: cat a.ll medium.ll ref.ll | opt -module-summary - -o ref.bc
21 ; RUN: ld.lld -pie -u ref ref.bc b.bc -y _GLOBAL_OFFSET_TABLE_ -o ref 2>&1 | FileCheck %s --check-prefix=TRACE
22 ; RUN: llvm-objdump -dt ref | FileCheck %s
24 ; TRACE: ref.bc: reference to _GLOBAL_OFFSET_TABLE_
25 ; TRACE-NEXT: ref.bc: reference to _GLOBAL_OFFSET_TABLE_
26 ; TRACE-NEXT: <internal>: definition of _GLOBAL_OFFSET_TABLE_
27 ; TRACE-NEXT: ref.lto.ref.o: reference to _GLOBAL_OFFSET_TABLE_
29 ;; The IR symbol table references _GLOBAL_OFFSET_TABLE_, which causes lld to define the symbol.
30 ; CHECK: .got.plt 0000000000000000 .hidden _GLOBAL_OFFSET_TABLE_
34 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
35 target triple = "x86_64-unknown-linux-gnu"
37 @i = external global i32
39 define dso_local void @_start() {
42 %inc = add nsw i32 %0, 1
43 store i32 %inc, ptr @i
47 !llvm.module.flags = !{!0, !1, !2, !3}
49 !0 = !{i32 8, !"PIC Level", i32 2}
50 !1 = !{i32 7, !"PIE Level", i32 2}
51 !2 = !{i32 1, !"Large Data Threshold", i64 0}
54 !3 = !{i32 1, !"Code Model", i32 3}
57 !3 = !{i32 1, !"Code Model", i32 4}
60 @_GLOBAL_OFFSET_TABLE_ = external global [0 x i8]
62 define dso_local ptr @ref() {
64 ret ptr @_GLOBAL_OFFSET_TABLE_
68 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
69 target triple = "x86_64-unknown-linux-gnu"