Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -896,10 +896,12 @@ uint32_t SharedFile::getAlignment(ArrayRef 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(Ret, Sections[Sym.st_shndx].sh_addralign); + Ret = std::max(Ret, Sections[Sym.st_shndx].sh_addralign); if (Ret > UINT32_MAX) error(toString(this) + ": alignment too large: " +