<div dir="ltr">Thanks!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 9, 2019 at 10:25 AM Fangrui Song via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This revision was automatically updated to reflect the committed changes.<br>
Closed by commit rL368379: [ELF] Expand regions for gaps due to explicit address (authored by MaskRay, committed by ).<br>
<br>
Changed prior to commit:<br>
  <a href="https://reviews.llvm.org/D65722?vs=213516&id=214271#toc" rel="noreferrer" target="_blank">https://reviews.llvm.org/D65722?vs=213516&id=214271#toc</a><br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D65722/new/" rel="noreferrer" target="_blank">https://reviews.llvm.org/D65722/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D65722" rel="noreferrer" target="_blank">https://reviews.llvm.org/D65722</a><br>
<br>
Files:<br>
  lld/trunk/ELF/LinkerScript.cpp<br>
  lld/trunk/test/ELF/linkerscript/memory-gap-explicit-expr.test<br>
<br>
<br>
Index: lld/trunk/ELF/LinkerScript.cpp<br>
===================================================================<br>
--- lld/trunk/ELF/LinkerScript.cpp<br>
+++ lld/trunk/ELF/LinkerScript.cpp<br>
@@ -772,6 +772,14 @@<br>
   if ((sec->flags & SHF_ALLOC) && sec->addrExpr)<br>
     setDot(sec->addrExpr, sec->location, false);<br>
<br>
+  // If the address of the section has been moved forward by an explicit<br>
+  // expression so that it now starts past the current curPos of the enclosing<br>
+  // region, we need to expand the current region to account for the space<br>
+  // between the previous section, if any, and the start of this section.<br>
+  if (ctx->memRegion && ctx->memRegion->curPos < dot)<br>
+    expandMemoryRegion(ctx->memRegion, dot - ctx->memRegion->curPos,<br>
+                       ctx->memRegion->name, sec->name);<br>
+<br>
   switchTo(sec);<br>
<br>
   if (sec->lmaExpr)<br>
Index: lld/trunk/test/ELF/linkerscript/memory-gap-explicit-expr.test<br>
===================================================================<br>
--- lld/trunk/test/ELF/linkerscript/memory-gap-explicit-expr.test<br>
+++ lld/trunk/test/ELF/linkerscript/memory-gap-explicit-expr.test<br>
@@ -0,0 +1,18 @@<br>
+# REQUIRES: x86<br>
+<br>
+# RUN: echo '.section .aaa, "a"; .quad 0; .section .bbb, "a"; .quad 0;' \<br>
+# RUN:   | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o<br>
+# RUN: ld.lld %t.o --script %s -o %t<br>
+# RUN: llvm-readelf -S %t | FileCheck %s<br>
+<br>
+# CHECK: .aaa PROGBITS 0000000000000000 001000 000008<br>
+# CHECK: .bbb PROGBITS 0000000000000014 001014 000008<br>
+<br>
+MEMORY {<br>
+  REGION (rwx) : ORIGIN = 0x0000, LENGTH = 0x100<br>
+}<br>
+<br>
+SECTIONS {<br>
+  .aaa 0 : { *(.aaa) } > REGION<br>
+  .bbb 0x14 : { *(.bbb) } > REGION<br>
+}<br>
<br>
<br>
</blockquote></div>