Index: lld/ELF/InputFiles.cpp =================================================================== --- lld/ELF/InputFiles.cpp +++ lld/ELF/InputFiles.cpp @@ -808,10 +808,17 @@ // We do not usually care about alignments of data in shared object // files because the loader takes care of it. However, if we promote a // DSO symbol to point to .bss due to copy relocation, we need to keep - // the original alignment requirements. We infer it here. + // the original alignment requirements. + // + // Since a symbol in .dynsym don't have an alignment field, we need to + // infer it conservatively from its address. If a symbol happens to be + // aligned to a large alignment, we round it down to a reasonable number + // (which is currently 32 that satisfies the x86-64 AVX alignment + // requirment.) uint32_t Alignment = 1; if (Sym.st_value) - Alignment = 1ULL << countTrailingZeros((uint64_t)Sym.st_value); + Alignment = 1 << std::min(countTrailingZeros((uint64_t)Sym.st_value), + countTrailingZeros((uint64_t)32)); if (0 < Sym.st_shndx && Sym.st_shndx < Sections.size()) { uint32_t SecAlign = Sections[Sym.st_shndx].sh_addralign; Alignment = std::min(Alignment, SecAlign);