1## Show that when bitcode is added to an archive it is handled correctly. 2## The symbol table is as expected and it can be extracted without issue. 3 4# RUN: rm -rf %t 5# RUN: split-file %s %t && mkdir -p %t/extracted 6# RUN: cd %t 7# RUN: llvm-as a.ll -o a.bc 8 9## Create symtab from bitcode for a new archive. 10# RUN: llvm-ar rcs new.a a.bc 11# RUN: llvm-ar t new.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 12# RUN: llvm-nm --print-armap new.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 13 14# FILES: a.bc 15 16# SYMS: Archive map 17# SYMS-NEXT: gfunc in a.bc 18# SYMS-NEXT: gdata in a.bc 19 20# SYMS: a.bc: 21# SYMS-NEXT: -------- D gdata 22# SYMS-NEXT: -------- T gfunc 23# SYMS-NEXT: -------- d ldata 24# SYMS-NEXT: -------- t lfunc 25 26## Update symtab from bitcode in an existing archive. 27# RUN: llvm-ar rcS update.a a.bc 28# RUN: llvm-ar t update.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 29## Check no symbol table is present. 30# RUN: llvm-nm --print-armap update.a | FileCheck --check-prefix=NOSYMS %s --implicit-check-not={{.}} 31# RUN: llvm-ar s update.a 32# RUN: llvm-ar t update.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 33# RUN: llvm-nm --print-armap update.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 34 35# NOSYMS: a.bc: 36# NOSYMS-NEXT: -------- D gdata 37# NOSYMS-NEXT: -------- T gfunc 38# NOSYMS-NEXT: -------- d ldata 39# NOSYMS-NEXT: -------- t lfunc 40 41## Create symtab from bitcode for a regular archive via MRI script. 42# RUN: llvm-ar -M < add.mri 43# RUN: llvm-ar t mri.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 44# RUN: llvm-nm --print-armap mri.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 45 46## Create symtab from bitcode for a new thin archive. 47# RUN: llvm-ar rcs --thin new-thin.a a.bc 48# RUN: llvm-ar t new-thin.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 49# RUN: llvm-nm --print-armap new-thin.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 50 51## Update symtab from bitcode in an existing thin archive. 52# RUN: llvm-ar rcS --thin update-thin.a a.bc 53# RUN: llvm-ar t update-thin.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 54## Check no symbol table is present. 55# RUN: llvm-nm --print-armap update-thin.a | FileCheck --check-prefix=NOSYMS %s --implicit-check-not={{.}} 56# RUN: llvm-ar s update-thin.a 57# RUN: llvm-ar t update-thin.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 58# RUN: llvm-nm --print-armap update-thin.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 59 60## Create symtab from bitcode for a thin archive via MRI script. 61# RUN: llvm-ar -M < add-thin.mri 62# RUN: llvm-ar t mri-thin.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 63# RUN: llvm-nm --print-armap mri-thin.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 64 65## Create symtab from bitcode from another archive. 66# RUN: llvm-ar rcs input.a a.bc 67# RUN: llvm-ar cqsL lib.a input.a 68# RUN: llvm-ar t lib.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 69# RUN: llvm-nm --print-armap lib.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 70 71## Create symtab from bitcode from another archive via MRI script. 72# RUN: llvm-ar -M < addlib.mri 73# RUN: llvm-ar t mri-addlib.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 74# RUN: llvm-nm --print-armap mri-addlib.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 75 76## Create symtab from bitcode from another thin archive. 77# RUN: llvm-ar rcs --thin input-thin.a a.bc 78# RUN: llvm-ar cqsL --thin lib-thin.a input-thin.a 79# RUN: llvm-ar t lib-thin.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 80# RUN: llvm-nm --print-armap lib-thin.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 81 82## Create symtab from bitcode from another thin archive via MRI script. 83# RUN: llvm-ar -M < addlib-thin.mri 84# RUN: llvm-ar t mri-addlib-thin.a | FileCheck --check-prefix=FILES %s --implicit-check-not={{.}} 85# RUN: llvm-nm --print-armap mri-addlib-thin.a | FileCheck --check-prefix=SYMS %s --implicit-check-not={{.}} 86 87## Extract bitcode and ensure it has not been changed. 88# RUN: cd extracted 89# RUN: llvm-ar x ../new.a a.bc 90# RUN: cmp a.bc a.bc 91 92#--- a.ll 93@gdata = global i32 0 94@ldata = internal global i32 0 95define void @gfunc() { ret void } 96define internal void @lfunc() { ret void } 97 98#--- add.mri 99CREATE mri.a 100ADDMOD a.bc 101SAVE 102END 103 104#--- add-thin.mri 105CREATETHIN mri-thin.a 106ADDMOD a.bc 107SAVE 108END 109 110#--- addlib.mri 111CREATE mri-addlib.a 112ADDLIB input.a 113SAVE 114END 115 116#--- addlib-thin.mri 117CREATE mri-addlib-thin.a 118ADDLIB input-thin.a 119SAVE 120END 121