[PATCH] D39697: Limit the maximum alignment of copyrel'ed shared symbols to 32.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 14:33:55 PST 2017


It is funny that llvm-mc fails with an assertion failure when your assembly
contains ".align 0x100000000" because it assumes internally that alignments
is less than 2^32. I need to fix it first.

On Mon, Nov 6, 2017 at 2:15 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:
>
> > ruiu updated this revision to Diff 121783.
> > ruiu added a comment.
> >
> > - Fix build error.
> >
> >
> > https://reviews.llvm.org/D39697
> >
> > Files:
> >   lld/ELF/InputFiles.cpp
> >
> >
> > Index: lld/ELF/InputFiles.cpp
> > ===================================================================
> > --- lld/ELF/InputFiles.cpp
> > +++ lld/ELF/InputFiles.cpp
> > @@ -809,13 +809,15 @@
> >      // 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.
> > -    uint32_t Alignment = 1;
> > +    uint64_t Alignment = 1;
> >      if (Sym.st_value)
> >        Alignment = 1ULL << countTrailingZeros((uint64_t)Sym.st_value);
> >      if (0 < Sym.st_shndx && Sym.st_shndx < Sections.size()) {
> > -      uint32_t SecAlign = Sections[Sym.st_shndx].sh_addralign;
> > +      uint64_t SecAlign = Sections[Sym.st_shndx].sh_addralign;
> >        Alignment = std::min(Alignment, SecAlign);
> >      }
> > +    if (Alignment > UINT32_MAX)
> > +      error(toString(this) + ": alignment too large: " + Name);
>
> LGTM, but can you add a testcase?
>
> Thanks,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171106/f771d3ad/attachment.html>


More information about the llvm-commits mailing list