[lld] r358985 - [LLD][ELF] - Remove file-class.a binary from inputs and improve the test case.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 06:27:54 PDT 2019


Author: grimar
Date: Tue Apr 23 06:27:54 2019
New Revision: 358985

URL: http://llvm.org/viewvc/llvm-project?rev=358985&view=rev
Log:
[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).


Added:
    lld/trunk/test/ELF/invalid/invalid-file-class.test
Removed:
    lld/trunk/test/ELF/invalid/Inputs/file-class.a
Modified:
    lld/trunk/test/ELF/invalid/invalid-elf.test

Removed: lld/trunk/test/ELF/invalid/Inputs/file-class.a
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/Inputs/file-class.a?rev=358984&view=auto
==============================================================================
Binary file - no diff available.

Modified: lld/trunk/test/ELF/invalid/invalid-elf.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-elf.test?rev=358985&r1=358984&r2=358985&view=diff
==============================================================================
--- lld/trunk/test/ELF/invalid/invalid-elf.test (original)
+++ lld/trunk/test/ELF/invalid/invalid-elf.test Tue Apr 23 06:27:54 2019
@@ -8,10 +8,6 @@
 # RUN:   FileCheck --check-prefix=NOT-ELF %s
 # NOT-ELF: not-elf.a(empty.o): not an ELF file
 
-# RUN: not ld.lld %t/simple.o %p/Inputs/file-class.a -o %t2 2>&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

Added: lld/trunk/test/ELF/invalid/invalid-file-class.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-file-class.test?rev=358985&view=auto
==============================================================================
--- lld/trunk/test/ELF/invalid/invalid-file-class.test (added)
+++ lld/trunk/test/ELF/invalid/invalid-file-class.test Tue Apr 23 06:27:54 2019
@@ -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), <padding zero bytes>, 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




More information about the llvm-commits mailing list