[lld] r371197 - Merging r371013:

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 04:20:16 PDT 2019


Author: hans
Date: Fri Sep  6 04:20:15 2019
New Revision: 371197

URL: http://llvm.org/viewvc/llvm-project?rev=371197&view=rev
Log:
Merging r371013:
------------------------------------------------------------------------
r371013 | ruiu | 2019-09-05 07:30:24 +0200 (Thu, 05 Sep 2019) | 13 lines

Align output segments correctly

Previously, segments were aligned according to their first section's
alignment requirements. That was not correct, but segments are also
aligned to a page boundary, and a page boundary is usually much larger
than a section alignment requirement, so no one noticed this bug before.

Now, lld has --nmagic option which sets maxPageSize to 1 to effectively
disable page alignment, which reveals the issue.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43212

Differential Revision: https://reviews.llvm.org/D67152
------------------------------------------------------------------------

Added:
    lld/branches/release_90/test/ELF/nmagic.s
      - copied unchanged from r371013, lld/trunk/test/ELF/nmagic.s
Modified:
    lld/branches/release_90/   (props changed)
    lld/branches/release_90/ELF/Writer.cpp

Propchange: lld/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep  6 04:20:15 2019
@@ -1 +1 @@
-/lld/trunk:366445,366447,366500,366504,366573,366780,366784,366836,367836-367837,368041,368078,368145,368964,369184,369445,369694,369828
+/lld/trunk:366445,366447,366500,366504,366573,366780,366784,366836,367836-367837,368041,368078,368145,368964,369184,369445,369694,369828,371013

Modified: lld/branches/release_90/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/ELF/Writer.cpp?rev=371197&r1=371196&r2=371197&view=diff
==============================================================================
--- lld/branches/release_90/ELF/Writer.cpp (original)
+++ lld/branches/release_90/ELF/Writer.cpp Fri Sep  6 04:20:15 2019
@@ -2233,7 +2233,8 @@ static uint64_t computeFileOffset(Output
   // The first section in a PT_LOAD has to have congruent offset and address
   // module the page size.
   if (os->ptLoad && os->ptLoad->firstSec == os) {
-    uint64_t alignment = std::max<uint64_t>(os->alignment, config->maxPageSize);
+    uint64_t alignment =
+        std::max<uint64_t>(os->ptLoad->p_align, config->maxPageSize);
     return alignTo(off, alignment, os->addr);
   }
 




More information about the llvm-commits mailing list