brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 021df7e Raw
80 lines · plain
1## Show that the archive library emits error messages when adding malformed2## object files and skips symbol tables for "malformed" bitcode files, which3## are assumed to be bitcode files generated by compilers from the future.4 5# RUN: rm -rf %t.dir6# RUN: split-file %s %t.dir7# RUN: cd %t.dir8 9## Create a malformed bitcode object.10# RUN: llvm-as input.ll -o input.bc11# RUN: cp input.bc good.bc12# 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 format15## (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 it17## tries to read the malformed bitcode file, but it's supposed to print the18## archive map first, which in this case it won't because there won't be one.19# RUN: rm -rf bad.a20# RUN: llvm-ar --format=bsd rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=WARN121# RUN: not llvm-nm --print-armap bad.a | count 022# RUN: rm -rf bad.a23# RUN: llvm-ar --format=gnu rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=WARN124# RUN: not llvm-nm --print-armap bad.a | count 025# RUN: rm -rf bad.a26# RUN: not llvm-ar --format=bigarchive rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR127# RUN: rm -rf bad.a28# RUN: not llvm-ar --format=coff rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR129# RUN: rm -rf bad.a30# RUN: not llvm-ar --format=darwin rc bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR131 32## Malformed bitcode object is the last file member of archive and33## the symbol table is required. In this case we check that the34## symbol table contains entries for the good object only.35# RUN: rm -rf bad.a36# RUN: llvm-ar rc bad.a good.bc input.bc 2>&1 | FileCheck %s --check-prefix=WARN137# RUN: not llvm-nm --print-armap bad.a | FileCheck %s --check-prefix=ARMAP38 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 linker41## presumably requires the index.42# RUN: rm -rf bad.a43# RUN: not llvm-ar --format=bigarchive rcS bad.a input.bc 2>&1 | FileCheck %s --check-prefix=ERR144# RUN: rm -rf bad.a45# RUN: not llvm-ar --format=bigarchive rcS bad.a good.bc input.bc 2>&1 | FileCheck %s --check-prefix=ERR146 47# ERR1: error: bad.a: 'input.bc': Invalid bitcode signature48# WARN1: warning: 'input.bc': Invalid bitcode signature49 50## Non-bitcode malformed file.51# RUN: yaml2obj input.yaml -o input.o52# RUN: not llvm-ar rc bad.a input.o 2>&1 | FileCheck %s --check-prefix=ERR253 54# ERR2: error: bad.a: 'input.o': section header table goes past the end of the file: e_shoff = 0x999955 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 058# RUN: llvm-ar t good.a | FileCheck %s --check-prefix=CONTENTS59 60# CONTENTS:      input.o61# CONTENTS-NEXT: input.bc62 63# ARMAP: Archive map64# ARMAP-NEXT: foo in good.bc65# ARMAP-EMPTY:66 67#--- input.ll68target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"69target triple = "x86_64-pc-linux"70 71@foo = global i32 172 73#--- input.yaml74--- !ELF75FileHeader:76  Class:   ELFCLASS6477  Data:    ELFDATA2LSB78  Type:    ET_REL79  EShOff:  0x999980