[PECOFF] Add DISCARDABLE characteristic to .reloc section

This patch sets the IMAGE_SCN_MEM_DISCARDABLE characteristic to the base
relocations section in order to match MS PECOFF specification.

Patch by Ron Ofir.

llvm-svn: 190798
This commit is contained in:
Rui Ueyama 2013-09-16 17:35:13 +00:00
parent 9c30f7a4ff
commit d5e4f637ef
2 changed files with 18 additions and 2 deletions

View File

@ -707,7 +707,8 @@ private:
// When loaded into memory, reloc section should be readable and writable.
static const uint32_t characteristics =
llvm::COFF::IMAGE_SCN_MEM_READ |
llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA;
llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
llvm::COFF::IMAGE_SCN_MEM_DISCARDABLE;
// Returns a list of RVAs that needs to be relocated if the binary is loaded
// at an address different from its preferred one.

View File

@ -20,7 +20,7 @@ BASEREL-SECTION-NEXT: 3000 00100000 0c000000 07300c30 00000000 .........0.0...
NOBASEREL-SECTION-NOT: Contents of section .reloc:
# RUN: lld -flavor link /out:%t1 /subsystem:console /force /opt:noref \
# RUN: -- %t.obj && llvm-readobj -file-headers %t1 \
# RUN: -- %t.obj && llvm-readobj -file-headers -sections %t1 \
# RUN: | FileCheck %s --check-prefix=BASEREL-HEADER
#
# RUN: lld -flavor link /out:%t1 /subsystem:console /force /opt:noref /fixed \
@ -30,3 +30,18 @@ NOBASEREL-SECTION-NOT: Contents of section .reloc:
BASEREL-HEADER-NOT: IMAGE_FILE_RELOCS_STRIPPED
NOBASEREL-HEADER: IMAGE_FILE_RELOCS_STRIPPED
BASEREL-HEADER: Name: .reloc (2E 72 65 6C 6F 63 00 00)
BASEREL-HEADER-NEXT: VirtualSize: 0xC
BASEREL-HEADER-NEXT: VirtualAddress: 0x3000
BASEREL-HEADER-NEXT: RawDataSize: 512
BASEREL-HEADER-NEXT: PointerToRawData: 0x600
BASEREL-HEADER-NEXT: PointerToRelocations: 0x0
BASEREL-HEADER-NEXT: PointerToLineNumbers: 0x0
BASEREL-HEADER-NEXT: RelocationCount: 0
BASEREL-HEADER-NEXT: LineNumberCount: 0
BASEREL-HEADER-NEXT: Characteristics [ (0x42000040)
BASEREL-HEADER-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
BASEREL-HEADER-NEXT: IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
BASEREL-HEADER-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
BASEREL-HEADER-NEXT: ]