1## Show that the archive library emits error messages when adding malformed 2## object files and skips symbol tables for "malformed" bitcode files, which 3## are assumed to be bitcode files generated by compilers from the future. 4 5# RUN: rm -rf %t.dir 6# RUN: split-file %s %t.dir 7# RUN: cd %t.dir 8 9## Create a malformed bitcode object. 10# RUN: llvm-as input.ll -o input.bc 11# RUN: cp input.bc good.bc 12# RUN: %python -c "with open('input.bc', 'a') as f: f.truncate(10)" 13 14## Malformed bitcode objects either warn or error depending on the archive format 15## (see switch in getSymbolicFile). If the archive was created with a warning, 16## we want to check that the archive map is empty. llvm-nm will fail when it 17## tries to read the malformed bitcode file, but it's supposed to print the 18## archive map first, which in this case it won't because there won't be one. 19# RUN: rm -rf bad.a 20# RUN: llvm-ar --format=bsd rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=WARN1 21# RUN: not llvm-nm --print-armap bad.a | count 0 22# RUN: rm -rf bad.a 23# RUN: llvm-ar --format=gnu rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=WARN1 24# RUN: not llvm-nm --print-armap bad.a | count 0 25# RUN: rm -rf bad.a 26# RUN: not llvm-ar --format=bigarchive rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR1 27# RUN: rm -rf bad.a 28# RUN: not llvm-ar --format=coff rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR1 29# RUN: rm -rf bad.a 30# RUN: not llvm-ar --format=darwin rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR1 31 32## Malformed bitcode object is the last file member of archive and 33## the symbol table is required. In this case we check that the 34## symbol table contains entries for the good object only. 35# RUN: rm -rf bad.a 36# RUN: llvm-ar rc bad.a good.bc input.bc 2>&1 | FileCheck %s --check-prefix=WARN1 37# RUN: not llvm-nm --print-armap bad.a | FileCheck %s --check-prefix=ARMAP 38 39## Malformed bitcode object if the symbol table is not required for big archive. 40## For big archives we print an error instead of a warning because the AIX linker 41## presumably requires the index. 42# RUN: rm -rf bad.a 43# RUN: not llvm-ar --format=bigarchive rcS bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR1 44# RUN: rm -rf bad.a 45# RUN: not llvm-ar --format=bigarchive rcS bad.a good.bc input.bc 2>&1 | FileCheck %s --check-prefix=ERR1 46 47# ERR1: error: bad.a: 'input.bc': Invalid bitcode signature 48# WARN1: warning: 'input.bc': Invalid bitcode signature 49 50## Non-bitcode malformed file. 51# RUN: yaml2obj input.yaml -o input.o 52# RUN: not llvm-ar rc bad.a input.o 2>&1 | FileCheck %s --check-prefix=ERR2 53 54# ERR2: error: bad.a: 'input.o': section header table goes past the end of the file: e_shoff = 0x9999 55 56## Don't emit an error or warning if the symbol table is not required for formats other than the big archive format. 57# RUN: llvm-ar --format=gnu rcS good.a input.o input.bc 2>&1 | count 0 58# RUN: llvm-ar t good.a | FileCheck %s --check-prefix=CONTENTS 59 60# CONTENTS: input.o 61# CONTENTS-NEXT: input.bc 62 63# ARMAP: Archive map 64# ARMAP-NEXT: foo in good.bc 65# ARMAP-EMPTY: 66 67#--- input.ll 68target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 69target triple = "x86_64-pc-linux" 70 71@foo = global i32 1 72 73#--- input.yaml 74--- !ELF 75FileHeader: 76 Class: ELFCLASS64 77 Data: ELFDATA2LSB 78 Type: ET_REL 79 EShOff: 0x9999 80