summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorAnusha Basana <anusha.basana@gmail.com>2019-08-05 19:06:55 +0000
committerAnusha Basana <anusha.basana@gmail.com>2019-08-05 19:06:55 +0000
commitff2c59b3f5f10c0a956d24cdf2a952fac73df09d (patch)
tree32720932f5a9c9f91fa4a68dd48100927d7ea6dc /llvm/test
parentd67c90a8c4a686de85c69801843a1074ef8c63ec (diff)
downloadbcm5719-llvm-ff2c59b3f5f10c0a956d24cdf2a952fac73df09d.tar.gz
bcm5719-llvm-ff2c59b3f5f10c0a956d24cdf2a952fac73df09d.zip
[llvm-lipo] Implement -segalign
Sets section alignments of the specified architecture slices to the alignment values. Alignment values are hexadecimal values that are powers of 2. Differential Revision: https://reviews.llvm.org/D65420 llvm-svn: 367908
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/tools/llvm-lipo/segalign-invalid-input.test29
-rw-r--r--llvm/test/tools/llvm-lipo/segalign.test113
2 files changed, 142 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-lipo/segalign-invalid-input.test b/llvm/test/tools/llvm-lipo/segalign-invalid-input.test
new file mode 100644
index 00000000000..3556ddfc856
--- /dev/null
+++ b/llvm/test/tools/llvm-lipo/segalign-invalid-input.test
@@ -0,0 +1,29 @@
+# RUN: yaml2obj %p/Inputs/arm64-slice.yaml > %t-arm64.o
+# RUN: yaml2obj %p/Inputs/armv7-slice.yaml > %t-armv7.o
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign a 2>&1 | FileCheck --check-prefix=MISSING_ARG %s
+# MISSING_ARG: error: segalign is missing an argument: expects -segalign arch_type alignment_value
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -o %t.o -segalign arm64 10 2>&1 | FileCheck --check-prefix=MISSING_ACTION %s
+# MISSING_ACTION: error: at least one action should be specified
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign arm6 10 2>&1 | FileCheck --check-prefix=INVALID_ARCH %s
+# INVALID_ARCH: error: Invalid architecture: arm6
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign arm64 15.7 2>&1 | FileCheck --check-prefix=INVALID_ALIGN_NOT_HEX %s
+# INVALID_ALIGN_NOT_HEX: error: argument to -segalign <arch_type> 15.7 (hex) is not a proper hexadecimal number
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign arm64 15 2>&1 | FileCheck --check-prefix=INVALID_ALIGN_HEX %s
+# INVALID_ALIGN_HEX: error: argument to -segalign <arch_type> 15 (hex) must be a non-zero power of two
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign arm64 0 2>&1 | FileCheck --check-prefix=INVALID_ALIGN_ZERO %s
+# INVALID_ALIGN_ZERO: error: argument to -segalign <arch_type> 0 (hex) must be a non-zero power of two
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign arm64 10000 2>&1 | FileCheck --check-prefix=INVALID_ALIGN_BIG %s
+# INVALID_ALIGN_BIG: error: argument to -segalign <arch_type> 10000 (hex) must be less than or equal to the maximum section align 2^15
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign arm64 100 -segalign arm64 200 2>&1 | FileCheck --check-prefix=DUPLICATE_ALIGN %s
+# DUPLICATE_ALIGN: error: -segalign arm64 <alignment_value> specified multiple times: 256, 512
+
+# RUN: not llvm-lipo %t-armv7.o %t-arm64.o -create -o %t.o -segalign i386 100 2>&1 | FileCheck --check-prefix=EXCLUDED_ALIGN %s
+# EXCLUDED_ALIGN: error: -segalign i386 <value> specified but resulting fat file does not contain that architecture
diff --git a/llvm/test/tools/llvm-lipo/segalign.test b/llvm/test/tools/llvm-lipo/segalign.test
new file mode 100644
index 00000000000..30fc43ad01f
--- /dev/null
+++ b/llvm/test/tools/llvm-lipo/segalign.test
@@ -0,0 +1,113 @@
+# RUN: yaml2obj %p/Inputs/arm64-slice.yaml > %t-arm64.o
+# RUN: yaml2obj %p/Inputs/armv7-slice.yaml > %t-armv7.o
+# RUN: yaml2obj %p/Inputs/i386-x86_64-universal.yaml > %t-universal.o
+
+# segalign expects an architecture type followed by a hexadecimal value for alignment
+
+# RUN: llvm-lipo %t-universal.o %t-arm64.o -create -o %t.o -segalign arm64 100
+# RUN: llvm-objdump %t.o -m --universal-headers | FileCheck --check-prefix=CHECK_SMALL_ARM64 %s
+# CHECK_SMALL_ARM64: nfat_arch 3
+# CHECK_SMALL_ARM64-NEXT: architecture i386
+# CHECK_SMALL_ARM64: offset 4096
+# CHECK_SMALL_ARM64-NEXT: size 432
+# CHECK_SMALL_ARM64-NEXT: align 2^12 (4096)
+# CHECK_SMALL_ARM64-NEXT: architecture x86_64
+# CHECK_SMALL_ARM64: offset 8192
+# CHECK_SMALL_ARM64-NEXT: size 488
+# CHECK_SMALL_ARM64-NEXT: align 2^12 (4096)
+# CHECK_SMALL_ARM64-NEXT: architecture arm64
+# CHECK_SMALL_ARM64: offset 8704
+# CHECK_SMALL_ARM64-NEXT: size 516
+# CHECK_SMALL_ARM64-NEXT: align 2^8 (256)
+###### WITHOUT SEGALIGN ######
+# RUN: llvm-lipo %t-universal.o %t-arm64.o -create -o %t-nosegalign.o
+# RUN: llvm-objdump %t-nosegalign.o -m --universal-headers | FileCheck --check-prefix=CHECK_SMALL_ARM64_NO_SEGALIGN %s
+# CHECK_SMALL_ARM64_NO_SEGALIGN: architecture arm64
+# CHECK_SMALL_ARM64_NO_SEGALIGN: offset 16384
+# CHECK_SMALL_ARM64_NO_SEGALIGN-NEXT: size 516
+# CHECK_SMALL_ARM64_NO_SEGALIGN-NEXT: align 2^14 (16384)
+
+# RUN: llvm-lipo %t.o -thin arm64 -o %thin-arm64.o
+# RUN: cmp %thin-arm64.o %t-arm64.o
+
+# RUN: llvm-lipo %t-universal.o %t-armv7.o -create -o %t2.o -segalign armv7 100
+# RUN: llvm-objdump %t2.o -m --universal-headers | FileCheck --check-prefix=CHECK_SMALL_ARMV7 %s
+# CHECK_SMALL_ARMV7: nfat_arch 3
+# CHECK_SMALL_ARMV7-NEXT: architecture armv7
+# CHECK_SMALL_ARMV7: offset 256
+# CHECK_SMALL_ARMV7-NEXT: size 304
+# CHECK_SMALL_ARMV7-NEXT: align 2^8 (256)
+# CHECK_SMALL_ARMV7-NEXT: architecture i386
+# CHECK_SMALL_ARMV7: offset 4096
+# CHECK_SMALL_ARMV7-NEXT: size 432
+# CHECK_SMALL_ARMV7-NEXT: align 2^12 (4096)
+# CHECK_SMALL_ARMV7-NEXT: architecture x86_64
+# CHECK_SMALL_ARMV7: offset 8192
+# CHECK_SMALL_ARMV7-NEXT: size 488
+# CHECK_SMALL_ARMV7-NEXT: align 2^12 (4096)
+###### WITHOUT SEGALIGN ######
+# RUN: llvm-lipo %t-universal.o %t-armv7.o -create -o %t2-nosegalign.o
+# RUN: llvm-objdump %t2-nosegalign.o -m --universal-headers | FileCheck --check-prefix=CHECK_SMALL_ARMV7_NO_SEGALIGN %s
+# CHECK_SMALL_ARMV7_NO_SEGALIGN: nfat_arch 3
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: architecture i386
+# CHECK_SMALL_ARMV7_NO_SEGALIGN: offset 4096
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: size 432
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: align 2^12 (4096)
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: architecture x86_64
+# CHECK_SMALL_ARMV7_NO_SEGALIGN: offset 8192
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: size 488
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: align 2^12 (4096)
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: architecture armv7
+# CHECK_SMALL_ARMV7_NO_SEGALIGN: offset 16384
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: size 304
+# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: align 2^14 (16384)
+
+# RUN: llvm-lipo %t2.o -thin armv7 -o %thin-armv7.o
+# RUN: cmp %thin-armv7.o %t-armv7.o
+
+# RUN: yaml2obj %p/Inputs/armv7-slice-big.yaml > %t-armv7-big.o
+# RUN: yaml2obj %p/Inputs/i386-x86_64-armv7-arm64-universal.yaml > %t-universal-big.o
+
+# RUN: llvm-lipo %t-universal-big.o -replace armv7 %t-armv7-big.o -o %t3.o -segalign armv7 4
+# RUN: llvm-objdump %t3.o -m --universal-headers | FileCheck --check-prefix=CHECK_REPLACE_ARMV7 %s
+# CHECK_REPLACE_ARMV7: nfat_arch 4
+# CHECK_REPLACE_ARMV7-NEXT: architecture armv7
+# CHECK_REPLACE_ARMV7: offset 88
+# CHECK_REPLACE_ARMV7-NEXT: size 88128
+# CHECK_REPLACE_ARMV7-NEXT: align 2^2 (4)
+# CHECK_REPLACE_ARMV7-NEXT: architecture i386
+# CHECK_REPLACE_ARMV7: offset 90112
+# CHECK_REPLACE_ARMV7-NEXT: size 432
+# CHECK_REPLACE_ARMV7-NEXT: align 2^12 (4096)
+# CHECK_REPLACE_ARMV7-NEXT: architecture x86_64
+# CHECK_REPLACE_ARMV7: offset 94208
+# CHECK_REPLACE_ARMV7-NEXT: size 488
+# CHECK_REPLACE_ARMV7-NEXT: align 2^12 (4096)
+# CHECK_REPLACE_ARMV7-NEXT: architecture arm64
+# CHECK_REPLACE_ARMV7: offset 98304
+# CHECK_REPLACE_ARMV7-NEXT: size 516
+# CHECK_REPLACE_ARMV7-NEXT: align 2^14 (16384)
+###### WITHOUT SEGALIGN ######
+# RUN: llvm-lipo %t-universal-big.o -replace armv7 %t-armv7-big.o -o %t3-nosegalign.o
+# RUN: llvm-objdump %t3-nosegalign.o -m --universal-headers | FileCheck --check-prefix=CHECK_REPLACE_ARMV7_NO_SEGALGIN %s
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN: nfat_arch 4
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: architecture i386
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN: offset 4096
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: size 432
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: align 2^12 (4096)
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: architecture x86_64
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN: offset 8192
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: size 488
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: align 2^12 (4096)
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: architecture armv7
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN: offset 16384
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: size 88128
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: align 2^14 (16384)
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: architecture arm64
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN: offset 114688
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: size 516
+# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: align 2^14 (16384)
+
+
+# RUN: llvm-lipo %t3.o -thin armv7 -o %thin-armv7-big.o
+# RUN: cmp %thin-armv7-big.o %t-armv7-big.o
OpenPOWER on IntegriCloud