forked from OSchip/llvm-project
[PECOFF] Do not emit a section if it's empty.
The PE32+ loader does not seem to like an executable with an empty section, so we should not emit a section if it's empty. llvm-svn: 200514
This commit is contained in:
parent
ec3da87f82
commit
ebc13c47f2
|
@ -932,6 +932,7 @@ void PECOFFWriter::build(const File &linkedFile) {
|
|||
StringRef sectionName = i.first;
|
||||
std::vector<const DefinedAtom *> &contents = i.second;
|
||||
auto *section = new AtomChunk(_ctx, sectionName, contents);
|
||||
if (section->size() > 0)
|
||||
addSectionChunk(section, sectionTable);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ CHECK-NEXT: Arch: x86_64
|
|||
CHECK-NEXT: AddressSize: 64bit
|
||||
CHECK-NEXT: ImageFileHeader {
|
||||
CHECK-NEXT: Machine: IMAGE_FILE_MACHINE_AMD64 (0x8664)
|
||||
CHECK-NEXT: SectionCount: 3
|
||||
CHECK-NEXT: SectionCount: 2
|
||||
CHECK-NEXT: TimeDateStamp:
|
||||
CHECK-NEXT: PointerToSymbolTable: 0x0
|
||||
CHECK-NEXT: SymbolCount: 0
|
||||
|
|
|
@ -17,7 +17,7 @@ FILE-NEXT: Arch: i386
|
|||
FILE-NEXT: AddressSize: 32bit
|
||||
FILE-NEXT: ImageFileHeader {
|
||||
FILE-NEXT: Machine: IMAGE_FILE_MACHINE_I386 (0x14C)
|
||||
FILE-NEXT: SectionCount: 2
|
||||
FILE-NEXT: SectionCount: 1
|
||||
FILE-NEXT: TimeDateStamp:
|
||||
FILE-NEXT: PointerToSymbolTable: 0x0
|
||||
FILE-NEXT: SymbolCount: 0
|
||||
|
@ -66,23 +66,6 @@ SECTIONS-NEXT: AddressSize: 32bit
|
|||
SECTIONS-NEXT: Sections [
|
||||
SECTIONS-NEXT: Section {
|
||||
SECTIONS-NEXT: Number: 1
|
||||
SECTIONS-NEXT: Name: .data (2E 64 61 74 61 00 00 00)
|
||||
SECTIONS-NEXT: VirtualSize: 0x0
|
||||
SECTIONS-NEXT: VirtualAddress: 0x1000
|
||||
SECTIONS-NEXT: RawDataSize: 0
|
||||
SECTIONS-NEXT: PointerToRawData: 0x200
|
||||
SECTIONS-NEXT: PointerToRelocations: 0x0
|
||||
SECTIONS-NEXT: PointerToLineNumbers: 0x0
|
||||
SECTIONS-NEXT: RelocationCount: 0
|
||||
SECTIONS-NEXT: LineNumberCount: 0
|
||||
SECTIONS-NEXT: Characteristics [
|
||||
SECTIONS-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
|
||||
SECTIONS-NEXT: IMAGE_SCN_MEM_READ
|
||||
SECTIONS-NEXT: IMAGE_SCN_MEM_WRITE
|
||||
SECTIONS-NEXT: ]
|
||||
SECTIONS-NEXT: }
|
||||
SECTIONS-NEXT: Section {
|
||||
SECTIONS-NEXT: Number: 2
|
||||
SECTIONS-NEXT: Name: .text (2E 74 65 78 74 00 00 00)
|
||||
SECTIONS-NEXT: VirtualSize: 0x6
|
||||
SECTIONS-NEXT: VirtualAddress: 0x1000
|
||||
|
|
Loading…
Reference in New Issue