From 76d650e8d77f19b9ee0ae708fff38109ff79e360 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 6 Jul 2015 14:26:07 +0000 Subject: Check that COFF .obj files have sections with zero virtual address spaces. When talking about the virtual address of sections the coff spec says: ... for simplicity, compilers should set this to zero. Otherwise, it is an arbitrary value that is subtracted from offsets during relocation. We don't currently subtract it, so check that it is zero. If some producer does create such files, we can change getRelocationOffset instead. llvm-svn: 241447 --- llvm/test/Object/Inputs/invalid-bad-section-address.coff | Bin 0 -> 304 bytes llvm/test/Object/coff-invalid.test | 13 +++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 llvm/test/Object/Inputs/invalid-bad-section-address.coff create mode 100644 llvm/test/Object/coff-invalid.test (limited to 'llvm/test') diff --git a/llvm/test/Object/Inputs/invalid-bad-section-address.coff b/llvm/test/Object/Inputs/invalid-bad-section-address.coff new file mode 100644 index 00000000000..8d96e013751 Binary files /dev/null and b/llvm/test/Object/Inputs/invalid-bad-section-address.coff differ diff --git a/llvm/test/Object/coff-invalid.test b/llvm/test/Object/coff-invalid.test new file mode 100644 index 00000000000..b85543dcfe8 --- /dev/null +++ b/llvm/test/Object/coff-invalid.test @@ -0,0 +1,13 @@ +RUN: llvm-readobj -s %p/Inputs/invalid-bad-section-address.coff 2>&1 | \ +RUN: FileCheck --check-prefix=SECTIONS %s + +SECTIONS: Section { +SECTIONS-NEXT: Number: 1 +SECTIONS-NEXT: Name: .text (2E 74 65 78 74 00 00 00) +SECTIONS-NEXT: VirtualSize: 0x0 +SECTIONS-NEXT: VirtualAddress: 0x1000000 + +RUN: not llvm-readobj -r %p/Inputs/invalid-bad-section-address.coff 2>&1 | \ +RUN: FileCheck %s + +CHECK: Sections with relocations should have an address of 0 -- cgit v1.2.3