<div dir="ltr">This was yet another trace of COFF-ism. For some unknown reason, Windows loader doesn't like empty sections, so we had this code.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 14, 2015 at 3:23 AM, Rafael Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Thu Aug 13 13:23:43 2015<br>
New Revision: 244929<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244929&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244929&view=rev</a><br>
Log:<br>
Set the file offset of zero sized sections.<br>
<br>
There is no reason not to do it and this matches what gold and bfd ld do.<br>
<br>
Modified:<br>
    lld/trunk/ELF/Writer.cpp<br>
    lld/trunk/test/elf2/basic.s<br>
    lld/trunk/test/elf2/basic32.s<br>
    lld/trunk/test/elf2/basic32be.s<br>
    lld/trunk/test/elf2/basic64be.s<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=244929&r1=244928&r2=244929&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=244929&r1=244928&r2=244929&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Thu Aug 13 13:23:43 2015<br>
@@ -123,8 +123,6 @@ template <class ELFT> void OutputSection<br>
 }<br>
<br>
 template <class ELFT> void OutputSection<ELFT>::setFileOffset(uintX_t Off) {<br>
-  if (Header.sh_size == 0)<br>
-    return;<br>
   Header.sh_offset = Off;<br>
 }<br>
<br>
<br>
Modified: lld/trunk/test/elf2/basic.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=244929&r1=244928&r2=244929&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=244929&r1=244928&r2=244929&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic.s (original)<br>
+++ lld/trunk/test/elf2/basic.s Thu Aug 13 13:23:43 2015<br>
@@ -75,7 +75,7 @@ _start:<br>
 # CHECK-NEXT:       SHF_WRITE (0x1)<br>
 # CHECK-NEXT:     ]<br>
 # CHECK-NEXT:     Address: 0x2000<br>
-# CHECK-NEXT:     Offset: 0x0<br>
+# CHECK-NEXT:     Offset: 0x1010<br>
 # CHECK-NEXT:     Size: 0<br>
 # CHECK-NEXT:     Link: 0<br>
 # CHECK-NEXT:     Info: 0<br>
@@ -91,7 +91,7 @@ _start:<br>
 # CHECK-NEXT:       SHF_WRITE (0x1)<br>
 # CHECK-NEXT:     ]<br>
 # CHECK-NEXT:     Address: 0x2000<br>
-# CHECK-NEXT:     Offset: 0x0<br>
+# CHECK-NEXT:     Offset: 0x1010<br>
 # CHECK-NEXT:     Size: 0<br>
 # CHECK-NEXT:     Link: 0<br>
 # CHECK-NEXT:     Info: 0<br>
<br>
Modified: lld/trunk/test/elf2/basic32.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32.s?rev=244929&r1=244928&r2=244929&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32.s?rev=244929&r1=244928&r2=244929&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic32.s (original)<br>
+++ lld/trunk/test/elf2/basic32.s Thu Aug 13 13:23:43 2015<br>
@@ -75,7 +75,7 @@ _start:<br>
 # CHECK-NEXT:       SHF_WRITE (0x1)<br>
 # CHECK-NEXT:     ]<br>
 # CHECK-NEXT:     Address: 0x2000<br>
-# CHECK-NEXT:     Offset: 0x0<br>
+# CHECK-NEXT:     Offset: 0x1010<br>
 # CHECK-NEXT:     Size: 0<br>
 # CHECK-NEXT:     Link: 0<br>
 # CHECK-NEXT:     Info: 0<br>
@@ -91,7 +91,7 @@ _start:<br>
 # CHECK-NEXT:       SHF_WRITE (0x1)<br>
 # CHECK-NEXT:     ]<br>
 # CHECK-NEXT:     Address: 0x2000<br>
-# CHECK-NEXT:     Offset: 0x0<br>
+# CHECK-NEXT:     Offset: 0x1010<br>
 # CHECK-NEXT:     Size: 0<br>
 # CHECK-NEXT:     Link: 0<br>
 # CHECK-NEXT:     Info: 0<br>
<br>
Modified: lld/trunk/test/elf2/basic32be.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32be.s?rev=244929&r1=244928&r2=244929&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32be.s?rev=244929&r1=244928&r2=244929&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic32be.s (original)<br>
+++ lld/trunk/test/elf2/basic32be.s Thu Aug 13 13:23:43 2015<br>
@@ -75,7 +75,7 @@ _start:<br>
 # CHECK-NEXT:       SHF_WRITE (0x1)<br>
 # CHECK-NEXT:     ]<br>
 # CHECK-NEXT:     Address: 0x2000<br>
-# CHECK-NEXT:     Offset: 0x0<br>
+# CHECK-NEXT:     Offset: 0x1010<br>
 # CHECK-NEXT:     Size: 0<br>
 # CHECK-NEXT:     Link: 0<br>
 # CHECK-NEXT:     Info: 0<br>
@@ -91,7 +91,7 @@ _start:<br>
 # CHECK-NEXT:       SHF_WRITE (0x1)<br>
 # CHECK-NEXT:     ]<br>
 # CHECK-NEXT:     Address: 0x2000<br>
-# CHECK-NEXT:     Offset: 0x0<br>
+# CHECK-NEXT:     Offset: 0x1010<br>
 # CHECK-NEXT:     Size: 0<br>
 # CHECK-NEXT:     Link: 0<br>
 # CHECK-NEXT:     Info: 0<br>
<br>
Modified: lld/trunk/test/elf2/basic64be.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic64be.s?rev=244929&r1=244928&r2=244929&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic64be.s?rev=244929&r1=244928&r2=244929&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic64be.s (original)<br>
+++ lld/trunk/test/elf2/basic64be.s Thu Aug 13 13:23:43 2015<br>
@@ -80,7 +80,7 @@ _start:<br>
 # CHECK-NEXT:       SHF_WRITE (0x1)<br>
 # CHECK-NEXT:     ]<br>
 # CHECK-NEXT:     Address: 0x2000<br>
-# CHECK-NEXT:     Offset: 0x0<br>
+# CHECK-NEXT:     Offset: 0x1010<br>
 # CHECK-NEXT:     Size: 0<br>
 # CHECK-NEXT:     Link: 0<br>
 # CHECK-NEXT:     Info: 0<br>
@@ -96,7 +96,7 @@ _start:<br>
 # CHECK-NEXT:       SHF_WRITE (0x1)<br>
 # CHECK-NEXT:     ]<br>
 # CHECK-NEXT:     Address: 0x2000<br>
-# CHECK-NEXT:     Offset: 0x0<br>
+# CHECK-NEXT:     Offset: 0x1010<br>
 # CHECK-NEXT:     Size: 0<br>
 # CHECK-NEXT:     Link: 0<br>
 # CHECK-NEXT:     Info: 0<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>