<div dir="ltr"><div>Besides Chandler's comment, here's mine.</div><div><br></div><div><div><div>> diff --git lib/ReaderWriter/PECOFF/WriterPECOFF.cpp lib/ReaderWriter/PECOFF/WriterPECOFF.cpp</div><div>> index 34dc1fb..fb5c3a3 100644</div>

<div>> --- lib/ReaderWriter/PECOFF/WriterPECOFF.cpp</div><div>> +++ lib/ReaderWriter/PECOFF/WriterPECOFF.cpp</div><div>> @@ -351,6 +355,15 @@ public:</div><div>>        layout->_virtualAddr += rva;</div><div>

>    }</div><div>></div><div>> +  uint64_t getAtomVirtualAddress(StringRef name) {</div><div>> +    for (auto atomLayout : _atomLayouts) {</div><div>> +      if (atomLayout->_atom->name() == name) {</div>

<div>> +        return atomLayout->_virtualAddr;</div><div>> +      }</div><div>> +    }</div><div>> +    return 0;</div><div>> +  }</div><div>> +</div><div><br></div><div>Nit: you can omit {} for "for" and "if" in this case.</div>

<div><br></div><div>> @@ -747,6 +760,20 @@ public:</div><div>>      peHeader->setSizeOfInitializedData(rdata->size() + data->size());</div><div>>      peHeader->setNumberOfSections(_numSections);</div>

<div>>      peHeader->setSizeOfImage(_imageSizeInMemory);</div><div>> +</div><div>> +    // Find the virtual address of the entry point symbol if any.</div><div>> +    // PECOFF spec says that entry point for dll images is optional, in which</div>

<div>> +    // case must be set to 0.</div><div>> +    if (_PECOFFTargetInfo.entrySymbolName().empty() &&</div><div>> +        _PECOFFTargetInfo.getImageType() == PECOFFTargetInfo::IMAGE_DLL) {</div><div>

> +      peHeader->setAddressOfEntryPoint(0);</div><div>> +    } else {</div><div>> +      uint64_t entryPointAddress = text->getAtomVirtualAddress(</div><div>> +        _PECOFFTargetInfo.entrySymbolName());</div>

<div>> +      if (entryPointAddress != 0) {</div><div>> +        peHeader->setAddressOfEntryPoint(entryPointAddress);</div><div>> +      }</div><div>> +    }</div><div>>    }</div><div><br></div><div>I'd make this a separate function to keep build() as concise as possible.</div>

</div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 30, 2013 at 4:12 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div class="im">On Tue, Jul 30, 2013 at 3:46 PM, Jesús Serrano García <span dir="ltr"><<a href="mailto:dagonoweda@gmail.com" target="_blank">dagonoweda@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><blockquote type="cite"><div>Looks like the <span>entry</span> function name should be _mainCRTStartup
        if subsystem is "console",</div>
      <div>_WinMainCRTStartup if subsystem is "windows", and
        "__DllMainCRTStartup" for DLL.</div>
      <div>See <a href="http://msdn.microsoft.com/en-us/library/f9t8842e%28v=vs.80%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/f9t8842e(v=vs.80).aspx</a>.</div>
    </blockquote></div>
    I think this is rather a Visual Studio convention for its C runtime
    library, and the PECOFF spec says nothing about it, so I though that
    "_main" is a good default <span>entry</span> <span>point</span> name, taking into account that
    there is currently no CRT guidelines (or at least I'm unaware of
    them) in the lld project.</blockquote><div><br></div></div><div>Sorry for the ambiguity, but the goal of all the PECOFF work in LLD is to support linking in a compatible way for Windows. If you have another usecase for linking PECOFF, you should raise that on the discussion list (not the commit list) as it'll need a separate design from what we're currently working on.</div>


<div><br></div><div>For now, as Rui has said, we should follow the MSDN spec he cited.</div></div></div></div>
</blockquote></div><br></div>