The java stuff generates sections with names like .rodata.jutf8.10 and
.rodata.jutf.14 that have the entry size (sh_entsize) set to an
integerer that isn't a power of two.  When merging these sections into
the final output, lld adjusts the alignment to be at least the entry
size.  However, the alignment of a section should always be a power of
2, and this is checked later on.  At that point lld throws us a fatal
error.

The diff below fixes this issue by sticking to the original alignment
if the entry size isn't a power of two.  Presumably lld is trying to
optimize things here by making sure that entries are word or
cache-line aligned when possible.  But such an optimization doesn't
make sense if the entry size isn't a power of 2 

This makes the ports gcc build on amd64 systems with lld as the default linker.

ok?


Index: gnu/llvm/tools/lld/ELF/SyntheticSections.cpp
===================================================================
RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/SyntheticSections.cpp,v
retrieving revision 1.8
diff -u -p -r1.8 SyntheticSections.cpp
--- gnu/llvm/tools/lld/ELF/SyntheticSections.cpp        3 Jun 2018 12:34:03 
-0000       1.8
+++ gnu/llvm/tools/lld/ELF/SyntheticSections.cpp        20 Oct 2018 13:48:46 
-0000
@@ -2512,7 +2512,9 @@ void elf::mergeSections() {
       continue;
 
     StringRef OutsecName = getOutputSectionName(MS);
-    uint32_t Alignment = std::max<uint32_t>(MS->Alignment, MS->Entsize);
+    uint32_t Alignment = MS->Alignment;
+    if (isPowerOf2_32(MS->Entsize))
+        Alignment = std::max<uint32_t>(Alignment, MS->Entsize);
 
     auto I = llvm::find_if(MergeSections, [=](MergeSyntheticSection *Sec) {
       // While we could create a single synthetic section for two different

Reply via email to