[PATCH] D47602: Correct aligment computation for shared object symbols

Han Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 31 13:22:29 PDT 2018


shenhan updated this revision to Diff 149348.

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D47602

Files:
  ELF/InputFiles.cpp


Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -896,10 +896,12 @@
 uint32_t SharedFile<ELFT>::getAlignment(ArrayRef<Elf_Shdr> Sections,
                                         const Elf_Sym &Sym) {
   uint64_t Ret = 1;
-  if (Sym.st_value)
+  // When Sym.st_shndx is set to SHN_COMMON, st_value contains
+  // alignment information.
+  if (Sym.st_shndx == SHN_COMMON && Sym.st_value)
     Ret = 1ULL << countTrailingZeros((uint64_t)Sym.st_value);
   if (0 < Sym.st_shndx && Sym.st_shndx < Sections.size())
-    Ret = std::min<uint64_t>(Ret, Sections[Sym.st_shndx].sh_addralign);
+    Ret = std::max<uint64_t>(Ret, Sections[Sym.st_shndx].sh_addralign);
 
   if (Ret > UINT32_MAX)
     error(toString(this) + ": alignment too large: " +


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47602.149348.patch
Type: text/x-patch
Size: 832 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180531/b76876f5/attachment.bin>


More information about the llvm-commits mailing list