summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorShoaib Meenai <smeenai@fb.com>2019-07-15 22:29:30 +0000
committerShoaib Meenai <smeenai@fb.com>2019-07-15 22:29:30 +0000
commit67cee1dc7ee285b03372eb818a3894d35efa7394 (patch)
tree29c7da67274aab9e2685d6d262bfd81272870ecc /llvm/test
parent853813293aceafbca6a71ded2e95e83bd3a9027d (diff)
downloadbcm5719-llvm-67cee1dc7ee285b03372eb818a3894d35efa7394.tar.gz
bcm5719-llvm-67cee1dc7ee285b03372eb818a3894d35efa7394.zip
[llvm-lipo] Implement -create (with hardcoded alignments)
Creates universal binary output file from input files. Currently uses hard coded value for alignment. Want to get the create functionality approved before implementing the alignment function. Patch by Anusha Basana <anusha.basana@gmail.com> Differential Revision: https://reviews.llvm.org/D64102 llvm-svn: 366142
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/tools/llvm-lipo/Inputs/arm64-slice.yaml101
-rw-r--r--llvm/test/tools/llvm-lipo/Inputs/armv7-slice.yaml76
-rw-r--r--llvm/test/tools/llvm-lipo/Inputs/x86_64-slice.yaml89
-rw-r--r--llvm/test/tools/llvm-lipo/create-executable.test11
-rw-r--r--llvm/test/tools/llvm-lipo/create-invalid-input.test8
-rw-r--r--llvm/test/tools/llvm-lipo/create-without-alignment.test32
-rw-r--r--llvm/test/tools/llvm-lipo/thin-executable-universal-binary.test2
7 files changed, 318 insertions, 1 deletions
diff --git a/llvm/test/tools/llvm-lipo/Inputs/arm64-slice.yaml b/llvm/test/tools/llvm-lipo/Inputs/arm64-slice.yaml
new file mode 100644
index 00000000000..5dfd4502738
--- /dev/null
+++ b/llvm/test/tools/llvm-lipo/Inputs/arm64-slice.yaml
@@ -0,0 +1,101 @@
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x0100000C
+ cpusubtype: 0x00000000
+ filetype: 0x00000001
+ ncmds: 4
+ sizeofcmds: 352
+ flags: 0x00002000
+ reserved: 0x00000000
+LoadCommands:
+ - cmd: LC_SEGMENT_64
+ cmdsize: 232
+ segname: ''
+ vmaddr: 0
+ vmsize: 56
+ fileoff: 384
+ filesize: 56
+ maxprot: 7
+ initprot: 7
+ nsects: 2
+ flags: 0
+ Sections:
+ - sectname: __text
+ segname: __TEXT
+ addr: 0x0000000000000000
+ size: 20
+ offset: 0x00000180
+ align: 2
+ reloff: 0x00000000
+ nreloc: 0
+ flags: 0x80000400
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
+ - sectname: __compact_unwind
+ segname: __LD
+ addr: 0x0000000000000018
+ size: 32
+ offset: 0x00000198
+ align: 3
+ reloff: 0x000001B8
+ nreloc: 1
+ flags: 0x02000000
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
+ - cmd: LC_VERSION_MIN_IPHONEOS
+ cmdsize: 16
+ version: 327680
+ sdk: 0
+ - cmd: LC_SYMTAB
+ cmdsize: 24
+ symoff: 448
+ nsyms: 3
+ stroff: 496
+ strsize: 20
+ - cmd: LC_DYSYMTAB
+ cmdsize: 80
+ ilocalsym: 0
+ nlocalsym: 2
+ iextdefsym: 2
+ nextdefsym: 1
+ iundefsym: 3
+ nundefsym: 0
+ tocoff: 0
+ ntoc: 0
+ modtaboff: 0
+ nmodtab: 0
+ extrefsymoff: 0
+ nextrefsyms: 0
+ indirectsymoff: 0
+ nindirectsyms: 0
+ extreloff: 0
+ nextrel: 0
+ locreloff: 0
+ nlocrel: 0
+LinkEditData:
+ NameList:
+ - n_strx: 13
+ n_type: 0x0E
+ n_sect: 1
+ n_desc: 0
+ n_value: 0
+ - n_strx: 7
+ n_type: 0x0E
+ n_sect: 2
+ n_desc: 0
+ n_value: 24
+ - n_strx: 1
+ n_type: 0x0F
+ n_sect: 1
+ n_desc: 0
+ n_value: 0
+ StringTable:
+ - ''
+ - _main
+ - ltmp1
+ - ltmp0
+ - ''
+...
diff --git a/llvm/test/tools/llvm-lipo/Inputs/armv7-slice.yaml b/llvm/test/tools/llvm-lipo/Inputs/armv7-slice.yaml
new file mode 100644
index 00000000000..b2606293145
--- /dev/null
+++ b/llvm/test/tools/llvm-lipo/Inputs/armv7-slice.yaml
@@ -0,0 +1,76 @@
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACE
+ cputype: 0x0000000C
+ cpusubtype: 0x00000009
+ filetype: 0x00000001
+ ncmds: 4
+ sizeofcmds: 244
+ flags: 0x00002000
+LoadCommands:
+ - cmd: LC_SEGMENT
+ cmdsize: 124
+ segname: ''
+ vmaddr: 0
+ vmsize: 10
+ fileoff: 272
+ filesize: 10
+ maxprot: 7
+ initprot: 7
+ nsects: 1
+ flags: 0
+ Sections:
+ - sectname: __text
+ segname: __TEXT
+ addr: 0x0000000000000000
+ size: 10
+ offset: 0x00000110
+ align: 1
+ reloff: 0x00000000
+ nreloc: 0
+ flags: 0x80000400
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
+ - cmd: LC_VERSION_MIN_IPHONEOS
+ cmdsize: 16
+ version: 327680
+ sdk: 0
+ - cmd: LC_SYMTAB
+ cmdsize: 24
+ symoff: 284
+ nsyms: 1
+ stroff: 296
+ strsize: 8
+ - cmd: LC_DYSYMTAB
+ cmdsize: 80
+ ilocalsym: 0
+ nlocalsym: 0
+ iextdefsym: 0
+ nextdefsym: 1
+ iundefsym: 1
+ nundefsym: 0
+ tocoff: 0
+ ntoc: 0
+ modtaboff: 0
+ nmodtab: 0
+ extrefsymoff: 0
+ nextrefsyms: 0
+ indirectsymoff: 0
+ nindirectsyms: 0
+ extreloff: 0
+ nextrel: 0
+ locreloff: 0
+ nlocrel: 0
+LinkEditData:
+ NameList:
+ - n_strx: 1
+ n_type: 0x0F
+ n_sect: 1
+ n_desc: 8
+ n_value: 0
+ StringTable:
+ - ''
+ - _main
+ - ''
+...
diff --git a/llvm/test/tools/llvm-lipo/Inputs/x86_64-slice.yaml b/llvm/test/tools/llvm-lipo/Inputs/x86_64-slice.yaml
new file mode 100644
index 00000000000..27db6d7a131
--- /dev/null
+++ b/llvm/test/tools/llvm-lipo/Inputs/x86_64-slice.yaml
@@ -0,0 +1,89 @@
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x01000007
+ cpusubtype: 0x00000003
+ filetype: 0x00000001
+ ncmds: 4
+ sizeofcmds: 352
+ flags: 0x00002000
+ reserved: 0x00000000
+LoadCommands:
+ - cmd: LC_SEGMENT_64
+ cmdsize: 232
+ segname: ''
+ vmaddr: 0
+ vmsize: 80
+ fileoff: 384
+ filesize: 80
+ maxprot: 7
+ initprot: 7
+ nsects: 2
+ flags: 0
+ Sections:
+ - sectname: __text
+ segname: __TEXT
+ addr: 0x0000000000000000
+ size: 15
+ offset: 0x00000180
+ align: 4
+ reloff: 0x00000000
+ nreloc: 0
+ flags: 0x80000400
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
+ - sectname: __eh_frame
+ segname: __TEXT
+ addr: 0x0000000000000010
+ size: 64
+ offset: 0x00000190
+ align: 3
+ reloff: 0x00000000
+ nreloc: 0
+ flags: 0x6800000B
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
+ - cmd: LC_VERSION_MIN_MACOSX
+ cmdsize: 16
+ version: 656384
+ sdk: 0
+ - cmd: LC_SYMTAB
+ cmdsize: 24
+ symoff: 464
+ nsyms: 1
+ stroff: 480
+ strsize: 8
+ - cmd: LC_DYSYMTAB
+ cmdsize: 80
+ ilocalsym: 0
+ nlocalsym: 0
+ iextdefsym: 0
+ nextdefsym: 1
+ iundefsym: 1
+ nundefsym: 0
+ tocoff: 0
+ ntoc: 0
+ modtaboff: 0
+ nmodtab: 0
+ extrefsymoff: 0
+ nextrefsyms: 0
+ indirectsymoff: 0
+ nindirectsyms: 0
+ extreloff: 0
+ nextrel: 0
+ locreloff: 0
+ nlocrel: 0
+LinkEditData:
+ NameList:
+ - n_strx: 1
+ n_type: 0x0F
+ n_sect: 1
+ n_desc: 0
+ n_value: 0
+ StringTable:
+ - ''
+ - _main
+ - ''
+...
diff --git a/llvm/test/tools/llvm-lipo/create-executable.test b/llvm/test/tools/llvm-lipo/create-executable.test
new file mode 100644
index 00000000000..82aa69cfec5
--- /dev/null
+++ b/llvm/test/tools/llvm-lipo/create-executable.test
@@ -0,0 +1,11 @@
+# RUN: yaml2obj %p/Inputs/i386-slice.yaml > %t-i386.o
+# RUN: yaml2obj %p/Inputs/x86_64-slice.yaml > %t-x86_64.o
+
+# RUN: chmod -x %t-i386.o
+# RUN: chmod -x %t-x86_64.o
+# RUN: llvm-lipo %t-i386.o %t-x86_64.o -create -output %t-universal.o
+# RUN: ! test -x %t-universal.o
+
+# RUN: chmod +x %t-i386.o
+# RUN: llvm-lipo %t-i386.o %t-x86_64.o -create -output %t-universal.o
+# RUN: test -x %t-universal.o
diff --git a/llvm/test/tools/llvm-lipo/create-invalid-input.test b/llvm/test/tools/llvm-lipo/create-invalid-input.test
new file mode 100644
index 00000000000..4bb2e1a5666
--- /dev/null
+++ b/llvm/test/tools/llvm-lipo/create-invalid-input.test
@@ -0,0 +1,8 @@
+# RUN: yaml2obj %p/Inputs/i386-slice.yaml > %t-32.o
+# RUN: yaml2obj %p/Inputs/i386-x86_64-universal.yaml > %t-universal.o
+
+# RUN: not llvm-lipo %t-32.o -create 2>&1 | FileCheck --check-prefix=NO_OUTPUT %s
+# NO_OUTPUT: error: create expects a single output file to be specified
+
+# RUN: not llvm-lipo %t-universal.o %t-32.o -create -output %t.o 2>&1 | FileCheck --check-prefix=DUPLICATE_ARCHS %s
+# DUPLICATE_ARCHS: have the same architecture i386 and therefore cannot be in the same universal binary
diff --git a/llvm/test/tools/llvm-lipo/create-without-alignment.test b/llvm/test/tools/llvm-lipo/create-without-alignment.test
new file mode 100644
index 00000000000..813230a7e3c
--- /dev/null
+++ b/llvm/test/tools/llvm-lipo/create-without-alignment.test
@@ -0,0 +1,32 @@
+# RUN: yaml2obj %p/Inputs/i386-slice.yaml > %t-i386.o
+# RUN: yaml2obj %p/Inputs/x86_64-slice.yaml > %t-x86_64.o
+
+# RUN: llvm-lipo %t-i386.o %t-x86_64.o -create -output %t-universal-llvm.o
+
+# RUN: yaml2obj %p/Inputs/i386-x86_64-universal.yaml > %t-universal.o
+# RUN: cmp %t-universal-llvm.o %t-universal.o
+
+# RUN: yaml2obj %p/Inputs/armv7-slice.yaml > %t-armv7.o
+# RUN: yaml2obj %p/Inputs/arm64-slice.yaml > %t-arm64.o
+
+# RUN: llvm-lipo %t-arm64.o %t-armv7.o %t-universal.o -create -output %t-universal-2.o
+# RUN: llvm-lipo %t-universal-2.o -thin x86_64 -output %t-x86_64_extracted.o
+# RUN: cmp %t-x86_64_extracted.o %t-x86_64.o
+# RUN: llvm-lipo %t-universal-2.o -thin armv7 -output %t-armv7-extracted.o
+# RUN: cmp %t-armv7-extracted.o %t-armv7.o
+
+# RUN: llvm-objdump %t-universal-2.o -m --universal-headers | FileCheck %s
+# CHECK: fat_magic FAT_MAGIC
+# CHECK: nfat_arch 4
+# CHECK: architecture i386
+# CHECK: offset 4096
+# CHECK: align 2^12 (4096)
+# CHECK: architecture x86_64
+# CHECK: offset 8192
+# CHECK: align 2^12 (4096)
+# CHECK: architecture armv7
+# CHECK: offset 16384
+# CHECK: align 2^14 (16384)
+# CHECK: architecture arm64
+# CHECK: offset 32768
+# CHECK: align 2^14 (16384)
diff --git a/llvm/test/tools/llvm-lipo/thin-executable-universal-binary.test b/llvm/test/tools/llvm-lipo/thin-executable-universal-binary.test
index 3992373d9e4..870252cd690 100644
--- a/llvm/test/tools/llvm-lipo/thin-executable-universal-binary.test
+++ b/llvm/test/tools/llvm-lipo/thin-executable-universal-binary.test
@@ -4,7 +4,7 @@
# RUN: chmod -x %t-universal.o
# RUN: llvm-lipo %t-universal.o -thin i386 -output %t32.o
-# RUN: test ! -x %t32.o
+# RUN: ! test -x %t32.o
# RUN: chmod +x %t-universal.o
# RUN: llvm-lipo %t-universal.o -thin i386 -output %t32-ex.o
OpenPOWER on IntegriCloud