From 95203efc1ace6090da1b91af6d734d69fce742fd Mon Sep 17 00:00:00 2001 From: George Rimar Date: Tue, 23 Apr 2019 13:27:54 +0000 Subject: [PATCH] [LLD][ELF] - Remove file-class.a binary from inputs and improve the test case. file-class.a was used to diagnose the "corrupted ELF file: invalid file class" error when the object was fetched from the archive. file-class.a contained an object of 16 bytes size. I replaced it with an echo call (because it is impossible to use yaml2obj for that, and I am not sure it is worth to support), and also increased its size to 18 bytes. That allowed to also test a case when such object is a regular input and not an archive member (we have a bit different logic for these cases). llvm-svn: 358985 --- lld/test/ELF/invalid/Inputs/file-class.a | Bin 156 -> 0 bytes lld/test/ELF/invalid/invalid-elf.test | 4 ---- lld/test/ELF/invalid/invalid-file-class.test | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) delete mode 100644 lld/test/ELF/invalid/Inputs/file-class.a create mode 100644 lld/test/ELF/invalid/invalid-file-class.test diff --git a/lld/test/ELF/invalid/Inputs/file-class.a b/lld/test/ELF/invalid/Inputs/file-class.a deleted file mode 100644 index f0ce607b4fdc831d97b8f3bbd3067ace32b366b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 156 zcmY$iNi0gvu;bEKKm`U!TnHPPR8TN9f+&1 | \ -# RUN: FileCheck --check-prefix=INVALID-FILE-CLASS %s -# INVALID-FILE-CLASS: file-class.a(test.o): corrupted ELF file: invalid file class - # RUN: not ld.lld %p/Inputs/binding.elf -o %t2 2>&1 | \ # RUN: FileCheck --check-prefix=INVALID-BINDING %s # INVALID-BINDING: unexpected binding diff --git a/lld/test/ELF/invalid/invalid-file-class.test b/lld/test/ELF/invalid/invalid-file-class.test new file mode 100644 index 0000000..a271d37 --- /dev/null +++ b/lld/test/ELF/invalid/invalid-file-class.test @@ -0,0 +1,19 @@ +# REQUIRES: x86 +# RUN: rm -rf %t && mkdir -p %t + +## In this test, we check that able to report objects with +## invalid ELF class type. There are 2 cases we want to check: +## when the object is a regular input and when it is fetched from the archive. + +## Create a broken ELF object with ELFCLASSNONE class using echo. We need to fill +## first 18 bytes which are used by LLD to check the object. +## 0x7f, 'E', 'L', 'F', ELFCLASSNONE(0), ELFDATA2LSB(1), +## EV_CURRENT(1), ELFOSABI_LINUX(3), , ET_REL(1), EM_NONE(0) +# RUN: echo -e -n "\x7f\x45\x4c\x46\x00\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" > %t/invalid.o + +# RUN: llvm-ar --format=gnu cr %t/invalid-class.a %t/invalid.o +# RUN: not ld.lld -whole-archive %t/invalid-class.a -o %t2 2>&1 | FileCheck %s +# CHECK: invalid-class.a(invalid.o): corrupted ELF file: invalid file class + +# RUN: not ld.lld %t/invalid.o -o %t2 2>&1 | FileCheck %s --check-prefix=OBJ +# OBJ: invalid.o: corrupted ELF file: invalid file class -- 2.7.4