[PATCH] [PECOFF][Writer] Implement the writer that can emit text section.

Rui Ueyama ruiu at google.com
Thu May 30 14:16:19 PDT 2013


  Yeah, my view is this is a reasonable small patch as a step toward full PE/COFF support. Before this patch, the writer was just a stub, and now it can do something meaningful. I thought about whether I should include more in this patch and stopped doing that because it was going to be too large.

  Comments below.


================
Comment at: lib/ReaderWriter/PECOFF/WriterPECOFF.cpp:69
@@ +68,3 @@
+    // Make the DOS stub occupy the first 128 bytes of an exe. Technically
+    // this can be as small as 64 bytes, but GNU binutil's objdump cannot
+    // parse such irregular header.
----------------
Shankar Kalpathi Easwaran wrote:
> Rui Ueyama wrote:
> > Shankar Kalpathi Easwaran wrote:
> > > Is this a binutils requirement, is llvm-objdump able to print ?
> > I think it's binutil's bug. llmv-objdump can parse such file.
> Then that constant should be 64 bytes.
I prefer to keep this as is because (1) 64 bit DOS stub is uncommon and (2) binutil is useful for debugging. Removing the 64 bit gap does not save space, because the total size of the header is always 512 byte (so the gap will have to be moved to the end of the header if we remove it from here).

================
Comment at: lib/ReaderWriter/PECOFF/WriterPECOFF.cpp:117-119
@@ +116,5 @@
+
+    // The address of entry point relative to ImageBase. Windows executable
+    // usually starts at address 0x401000.
+    _peHeader.AddressOfEntryPoint = 0x1000;
+    _peHeader.BaseOfCode = 0x1000;
----------------
Shankar Kalpathi Easwaran wrote:
> Rui Ueyama wrote:
> > Shankar Kalpathi Easwaran wrote:
> > > The comment is misleading. All these should come from TargetInfo.
> > Right. It should be set by command line option. It's also to-do.
> The comment says 0x401000 and you are setting to 0x1000. Same with few other comments below.
As described in the comment, this is relative to ImageBase which is 0x400000.


http://llvm-reviews.chandlerc.com/D892

BRANCH
  coff3

ARCANIST PROJECT
  lld



More information about the llvm-commits mailing list