diff options
author | Nico Weber <nicolasweber@gmx.de> | 2019-06-07 13:24:34 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2019-06-07 13:24:34 +0000 |
commit | d546b5052bb71ad90230fa572101730d4c0246a3 (patch) | |
tree | a729217488254eec81f25a3de28ed392c2be886a /llvm/test/tools/llvm-lib | |
parent | 6880bceda2df17f68e319c86a78642125086e0b8 (diff) | |
download | bcm5719-llvm-d546b5052bb71ad90230fa572101730d4c0246a3.tar.gz bcm5719-llvm-d546b5052bb71ad90230fa572101730d4c0246a3.zip |
llvm-lib: Disallow mixing object files with different machine types
lib.exe doesn't allow creating .lib files with object files that have
differing machine types. Update llvm-lib to match.
The motivation is to make it possible to infer the machine type of a
.lib file in lld, so that it can warn when e.g. a 32-bit .lib file is
passed to a 64-bit link (PR38965).
Fixes PR38782.
Differential Revision: https://reviews.llvm.org/D62913
llvm-svn: 362798
Diffstat (limited to 'llvm/test/tools/llvm-lib')
-rw-r--r-- | llvm/test/tools/llvm-lib/Inputs/arm64.ll | 18 | ||||
-rw-r--r-- | llvm/test/tools/llvm-lib/Inputs/i386.ll | 19 | ||||
-rw-r--r-- | llvm/test/tools/llvm-lib/Inputs/x86_64.ll | 19 | ||||
-rw-r--r-- | llvm/test/tools/llvm-lib/machine-mismatch.test | 38 |
4 files changed, 94 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-lib/Inputs/arm64.ll b/llvm/test/tools/llvm-lib/Inputs/arm64.ll new file mode 100644 index 00000000000..db082095276 --- /dev/null +++ b/llvm/test/tools/llvm-lib/Inputs/arm64.ll @@ -0,0 +1,18 @@ +; ModuleID = 'test2.cc' +source_filename = "test2.cc" +target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128" +target triple = "arm64-pc-windows-msvc19.11.0" + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @"?f@@YAXXZ"() #0 { +entry: + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 2} +!1 = !{!"clang version 9.0.0 "} diff --git a/llvm/test/tools/llvm-lib/Inputs/i386.ll b/llvm/test/tools/llvm-lib/Inputs/i386.ll new file mode 100644 index 00000000000..268022262f7 --- /dev/null +++ b/llvm/test/tools/llvm-lib/Inputs/i386.ll @@ -0,0 +1,19 @@ +; ModuleID = 'test2.cc' +source_filename = "test2.cc" +target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" +target triple = "i386-pc-windows-msvc19.11.0" + +; Function Attrs: noinline nounwind optnone +define dso_local void @"?f@@YAXXZ"() #0 { +entry: + ret void +} + +attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"NumRegisterParameters", i32 0} +!1 = !{i32 1, !"wchar_size", i32 2} +!2 = !{!"clang version 9.0.0 "} diff --git a/llvm/test/tools/llvm-lib/Inputs/x86_64.ll b/llvm/test/tools/llvm-lib/Inputs/x86_64.ll new file mode 100644 index 00000000000..6a94068a903 --- /dev/null +++ b/llvm/test/tools/llvm-lib/Inputs/x86_64.ll @@ -0,0 +1,19 @@ +; ModuleID = 'test2.cc' +source_filename = "test2.cc" +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.11.0" + +; Function Attrs: noinline nounwind optnone uwtable +define dso_local void @"?f@@YAXXZ"() #0 { +entry: + ret void +} + +attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 2} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{!"clang version 9.0.0 "} diff --git a/llvm/test/tools/llvm-lib/machine-mismatch.test b/llvm/test/tools/llvm-lib/machine-mismatch.test new file mode 100644 index 00000000000..b1a6ca93c09 --- /dev/null +++ b/llvm/test/tools/llvm-lib/machine-mismatch.test @@ -0,0 +1,38 @@ +Prepare inputs: + +RUN: rm -rf %t && mkdir -p %t +RUN: llvm-mc -triple=i386-pc-windows-msvc -filetype=obj -o %t/i386.obj %S/Inputs/a.s +RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t/x86_64.obj %S/Inputs/a.s +RUN: llvm-as -o %t/i386.bc %S/Inputs/i386.ll +RUN: llvm-as -o %t/x86_64.bc %S/Inputs/x86_64.ll +RUN: llvm-as -o %t/arm64.bc %S/Inputs/arm64.ll + + +Mixing bitcode and normal object files with the same machine type is ok: + +RUN: llvm-lib %t/i386.obj %t/i386.bc +RUN: llvm-lib %t/x86_64.obj %t/x86_64.bc + + +As is including resource files: + +RUN: llvm-lib %S/Inputs/resource.res %t/i386.obj %t/i386.bc +RUN: llvm-lib %t/x86_64.obj %S/Inputs/resource.res %t/x86_64.bc + + +Mixing object files with different machine type is not ok: + +RUN: not llvm-lib %t/x86_64.obj %t/i386.obj 2>&1 | \ +RUN: FileCheck --check-prefix=OBJ32 %s +OBJ32: i386.obj: file machine type x86 conflicts with library machine type x64 + + +Neither is mixing object and bitcode files with different machine type: + +RUN: not llvm-lib %t/x86_64.obj %t/i386.bc 2>&1 | \ +RUN: FileCheck --check-prefix=BC32 %s +BC32: i386.bc: file machine type x86 conflicts with library machine type x64 + +RUN: not llvm-lib %t/arm64.bc %t/x86_64.bc 2>&1 | \ +RUN: FileCheck --check-prefix=BC64 %s +BC64: x86_64.bc: file machine type x64 conflicts with library machine type arm64 |