22 lines · plain
1# REQUIRES: x862# This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.3# XFAIL: main-run-twice4# RUN: rm -rf %t && mkdir -p %t5 6## In this test, we check that able to report objects with7## invalid ELF class type. There are 2 cases we want to check:8## when the object is a regular input and when it is fetched from the archive.9 10## Create a broken ELF object with ELFCLASSNONE class using echo. We need to fill11## first 18 bytes which are used by LLD to check the object.12## 0x7f, 'E', 'L', 'F', ELFCLASSNONE(0), ELFDATA2LSB(1),13## EV_CURRENT(1), ELFOSABI_LINUX(3), <padding zero bytes>, ET_REL(1), EM_NONE(0)14# RUN: echo -e -n "\x7f\x45\x4c\x46\x00\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" > %t/invalid.o15 16# RUN: llvm-ar --format=gnu crS %t/invalid-class.a %t/invalid.o17# RUN: not ld.lld -whole-archive %t/invalid-class.a -o /dev/null 2>&1 | FileCheck %s18# CHECK: invalid-class.a(invalid.o): corrupted ELF file: invalid file class19 20# RUN: not ld.lld %t/invalid.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=OBJ21# OBJ: invalid.o: corrupted ELF file: invalid file class22