[lld] r221335 - PECOFF: Set the AddressOfRelocationTable in the DOS header
David Majnemer
david.majnemer at gmail.com
Tue Nov 4 22:37:09 PST 2014
Author: majnemer
Date: Wed Nov 5 00:37:08 2014
New Revision: 221335
URL: http://llvm.org/viewvc/llvm-project?rev=221335&view=rev
Log:
PECOFF: Set the AddressOfRelocationTable in the DOS header
Many programs, for reasons unknown, really like to look at the
AddressOfRelocationTable to determine whether or not they are looking at
a bona fide PE file. Without this, programs like the UNIX `file'
utility will insist that they are looking at a MS DOS executable.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/test/pecoff/trivial.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=221335&r1=221334&r2=221335&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Wed Nov 5 00:37:08 2014
@@ -113,6 +113,7 @@ public:
ArrayRef<uint8_t> array = _context.getDosStub();
std::memcpy(buffer, array.data(), array.size());
auto *header = reinterpret_cast<llvm::object::dos_header *>(buffer);
+ header->AddressOfRelocationTable = sizeof(llvm::object::dos_header);
header->AddressOfNewExeHeader = _size;
}
Modified: lld/trunk/test/pecoff/trivial.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/trivial.test?rev=221335&r1=221334&r2=221335&view=diff
==============================================================================
--- lld/trunk/test/pecoff/trivial.test (original)
+++ lld/trunk/test/pecoff/trivial.test Wed Nov 5 00:37:08 2014
@@ -59,6 +59,25 @@ FILE-NEXT: SizeOfStackCommit: 4096
FILE-NEXT: SizeOfHeapReserve: 1048576
FILE-NEXT: SizeOfHeapCommit: 4096
FILE-NEXT: NumberOfRvaAndSize: 16
+FILE: DOSHeader {
+FILE-NEXT: Magic: MZ
+FILE-NEXT: UsedBytesInTheLastPage: 0
+FILE-NEXT: FileSizeInPages: 0
+FILE-NEXT: NumberOfRelocationItems: 0
+FILE-NEXT: HeaderSizeInParagraphs: 0
+FILE-NEXT: MinimumExtraParagraphs: 0
+FILE-NEXT: MaximumExtraParagraphs: 0
+FILE-NEXT: InitialRelativeSS: 0
+FILE-NEXT: InitialSP: 0
+FILE-NEXT: Checksum: 0
+FILE-NEXT: InitialIP: 0
+FILE-NEXT: InitialRelativeCS: 0
+FILE-NEXT: AddressOfRelocationTable: 64
+FILE-NEXT: OverlayNumber: 0
+FILE-NEXT: OEMid: 0
+FILE-NEXT: OEMinfo: 0
+FILE-NEXT: AddressOfNewExeHeader: 128
+FILE-NEXT: }
SECTIONS: Format: COFF-i386
SECTIONS-NEXT: Arch: i386
More information about the llvm-commits
mailing list