[llvm-branch-commits] [lld] f2bbbad - [ELF] Fix relocation-model.ll

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 4 19:38:01 PST 2020


Author: Fangrui Song
Date: 2020-12-04T19:33:19-08:00
New Revision: f2bbbad1413ba88cb091d5aa531d8b1bd6b1393a

URL: https://github.com/llvm/llvm-project/commit/f2bbbad1413ba88cb091d5aa531d8b1bd6b1393a
DIFF: https://github.com/llvm/llvm-project/commit/f2bbbad1413ba88cb091d5aa531d8b1bd6b1393a.diff

LOG: [ELF] Fix relocation-model.ll

Added: 
    lld/test/ELF/lto/relocation-model-pic.ll
    lld/test/ELF/lto/relocation-model-static.ll

Modified: 
    

Removed: 
    lld/test/ELF/lto/Inputs/relocation-model-pic.ll
    lld/test/ELF/lto/relocation-model.ll


################################################################################
diff  --git a/lld/test/ELF/lto/Inputs/relocation-model-pic.ll b/lld/test/ELF/lto/Inputs/relocation-model-pic.ll
deleted file mode 100644
index d5c69a5e3dbb..000000000000
--- a/lld/test/ELF/lto/Inputs/relocation-model-pic.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
- at foo = external global i32
-define i32 @main() {
-  %t = load i32, i32* @foo
-  ret i32 %t
-}
-
-!llvm.module.flags = !{!0}
-!0 = !{i32 1, !"PIC Level", i32 2}

diff  --git a/lld/test/ELF/lto/relocation-model-pic.ll b/lld/test/ELF/lto/relocation-model-pic.ll
new file mode 100644
index 000000000000..f0eae4685392
--- /dev/null
+++ b/lld/test/ELF/lto/relocation-model-pic.ll
@@ -0,0 +1,25 @@
+; REQUIRE: x86
+; RUN: llvm-as %s -o %t.o
+
+; RUN: ld.lld %t.o -o %t -save-temps -shared
+; RUN: llvm-readobj -r %t.lto.o | FileCheck %s
+
+; RUN: ld.lld %t.o -o %t -save-temps --export-dynamic -pie -z undefs
+; RUN: llvm-readobj -r %t.lto.o | FileCheck %s
+
+; RUN: ld.lld %t.o -o %t -save-temps --export-dynamic -z undefs
+; RUN: llvm-readobj -r %t.lto.o | FileCheck %s
+
+; CHECK: R_X86_64_REX_GOTPCRELX foo
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at foo = external global i32
+define i32 @main() {
+  %t = load i32, i32* @foo
+  ret i32 %t
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"PIC Level", i32 2}

diff  --git a/lld/test/ELF/lto/relocation-model-static.ll b/lld/test/ELF/lto/relocation-model-static.ll
new file mode 100644
index 000000000000..2212b0940ce1
--- /dev/null
+++ b/lld/test/ELF/lto/relocation-model-static.ll
@@ -0,0 +1,19 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+
+; RUN: ld.lld %t.o -o %t -save-temps --export-dynamic --noinhibit-exec
+; RUN: llvm-readobj -r %t.lto.o | FileCheck %s --check-prefix=STATIC
+
+; RUN: ld.lld %t.o -o %t -save-temps -r -mllvm -relocation-model=static
+; RUN: llvm-readobj -r %t.lto.o | FileCheck %s --check-prefix=STATIC
+
+; STATIC: R_X86_64_PC32 foo
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at foo = external dso_local global i32
+define i32 @main() {
+  %t = load i32, i32* @foo
+  ret i32 %t
+}

diff  --git a/lld/test/ELF/lto/relocation-model.ll b/lld/test/ELF/lto/relocation-model.ll
deleted file mode 100644
index 45e21db64187..000000000000
--- a/lld/test/ELF/lto/relocation-model.ll
+++ /dev/null
@@ -1,49 +0,0 @@
-; REQUIRES: x86
-
-; RUN: llvm-as %s -o %t.o
-; RUN: llvm-as %p/Inputs/relocation-model-pic.ll -o %t.pic.o
-
-;; Non-PIC source.
-
-; RUN: ld.lld %t.o -o %t-out -save-temps -shared
-; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
-
-; RUN: ld.lld %t.o -o %t-out -save-temps --export-dynamic --noinhibit-exec -pie
-; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
-
-; RUN: ld.lld %t.o -o %t-out -save-temps --export-dynamic --noinhibit-exec
-; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
-
-
-;; PIC source.
-
-; RUN: ld.lld %t.pic.o -o %t-out -save-temps -shared
-; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
-
-; RUN: ld.lld %t.pic.o -o %t-out -save-temps --export-dynamic --noinhibit-exec -pie
-; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
-
-; RUN: ld.lld %t.pic.o -o %t-out -save-temps --export-dynamic --noinhibit-exec
-; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
-
-
-;; Explicit flag.
-
-; RUN: ld.lld %t.o -o %t-out -save-temps -r -mllvm -relocation-model=pic
-; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
-
-; RUN: ld.lld %t.o -o %t-out -save-temps -r -mllvm -relocation-model=static
-; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
-
-
-; PIC: R_X86_64_REX_GOTPCRELX foo
-; STATIC: R_X86_64_PC32 foo
-
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
- at foo = external global i32
-define i32 @main() {
-  %t = load i32, i32* @foo
-  ret i32 %t
-}


        


More information about the llvm-branch-commits mailing list