[lld] r185309 - [PECOFF][Writer] Add setter methods that sets the import address table location to file header.
Rui Ueyama
ruiu at google.com
Mon Jul 1 00:59:17 PDT 2013
Author: ruiu
Date: Mon Jul 1 02:59:17 2013
New Revision: 185309
URL: http://llvm.org/viewvc/llvm-project?rev=185309&view=rev
Log:
[PECOFF][Writer] Add setter methods that sets the import address table location to file header.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=185309&r1=185308&r2=185309&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Mon Jul 1 02:59:17 2013
@@ -242,9 +242,25 @@ private:
class DataDirectoryChunk : public HeaderChunk {
public:
DataDirectoryChunk() : HeaderChunk() {
- // [FIXME] Currently all entries are filled with zero.
_size = sizeof(_dirs);
- std::memset(&_dirs, 0, sizeof(_dirs));
+ std::memset(_dirs, 0, sizeof(_dirs));
+ }
+
+ // Set the import table address and size. The import table is usually in
+ // .idata section, but because .idata section can be merged with other section
+ // such as .rdata, the given address can be in any section.
+ void setImportTableDirectoryRva(uint32_t rva, uint32_t size) {
+ _dirs[1].RelativeVirtualAddress = rva;
+ _dirs[1].Size = size;
+ }
+
+ // Set the address and size of the import address table (IAT). This is
+ // redundant information because the import table contains the file offset of
+ // the IAT. Although it's redundant, it needs to be set properly, otherwise
+ // the loader refuses the executable.
+ void setImportAddressTableRva(uint32_t rva, uint32_t size) {
+ _dirs[12].RelativeVirtualAddress = rva;
+ _dirs[12].Size = size;
}
virtual void write(uint8_t *fileBuffer) {
More information about the llvm-commits
mailing list