diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-09-07 11:22:03 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-09-07 11:22:03 +0000 |
commit | f5136486a6f241c762d251d39865f5b92d4caf86 (patch) | |
tree | 8d0594aaf301b80248e1442fb1d8f0ef9aa1a073 /ELF | |
parent | 7a63c3fd2d6157b77034dea8294a73b0f7030848 (diff) | |
download | src-f5136486a6f241c762d251d39865f5b92d4caf86.tar.gz src-f5136486a6f241c762d251d39865f5b92d4caf86.zip |
Vendor import of lld release_90 branch r371301:vendor/lld/lld-release_900-r372316vendor/lld/lld-release_90-r371301vendor/lld-90
Notes
Notes:
svn path=/vendor/lld/dist-release_90/; revision=351987
svn path=/vendor/lld/lld-release_900-r372316/; revision=352529; tag=vendor/lld/lld-release_900-r372316
Diffstat (limited to 'ELF')
-rw-r--r-- | ELF/Writer.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/ELF/Writer.cpp b/ELF/Writer.cpp index b8c8891648a4..10b171e8c0d7 100644 --- a/ELF/Writer.cpp +++ b/ELF/Writer.cpp @@ -2230,25 +2230,27 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() { // same with its virtual address modulo the page size, so that the loader can // load executables without any address adjustment. static uint64_t computeFileOffset(OutputSection *os, uint64_t off) { - // File offsets are not significant for .bss sections. By convention, we keep - // section offsets monotonically increasing rather than setting to zero. - if (os->type == SHT_NOBITS) - return off; - - // If the section is not in a PT_LOAD, we just have to align it. - if (!os->ptLoad) - return alignTo(off, os->alignment); - // The first section in a PT_LOAD has to have congruent offset and address // module the page size. - OutputSection *first = os->ptLoad->firstSec; - if (os == first) { - uint64_t alignment = std::max<uint64_t>(os->alignment, config->maxPageSize); + if (os->ptLoad && os->ptLoad->firstSec == os) { + uint64_t alignment = + std::max<uint64_t>(os->ptLoad->p_align, config->maxPageSize); return alignTo(off, alignment, os->addr); } + // File offsets are not significant for .bss sections other than the first one + // in a PT_LOAD. By convention, we keep section offsets monotonically + // increasing rather than setting to zero. + if (os->type == SHT_NOBITS) + return off; + + // If the section is not in a PT_LOAD, we just have to align it. + if (!os->ptLoad) + return alignTo(off, os->alignment); + // If two sections share the same PT_LOAD the file offset is calculated // using this formula: Off2 = Off1 + (VA2 - VA1). + OutputSection *first = os->ptLoad->firstSec; return first->offset + os->addr - first->addr; } |