<div dir="ltr">What if a symbol happens to have an address that is aligned to a very large number? What we are doing here is making a guess, and there's no way to make it precise.<div><br></div><div>Maybe we should limit an alignment to 32 (or a reasonable maximum alignment that makes sense on any ISA) if a guessed alignment is too big?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 6, 2017 at 1:03 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> writes:<br>
<br>
> On Fri, Nov 3, 2017 at 9:06 PM, Rafael Avila de Espindola <<br>
> <a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
><br>
>> Rui Ueyama via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> writes:<br>
>><br>
>> > Modified: lld/trunk/ELF/InputFiles.cpp<br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/</a><br>
>> InputFiles.cpp?rev=316863&r1=<wbr>316862&r2=316863&view=diff<br>
>> > ==============================<wbr>==============================<br>
>> ==================<br>
>> > --- lld/trunk/ELF/InputFiles.cpp (original)<br>
>> > +++ lld/trunk/ELF/InputFiles.cpp Sun Oct 29 09:49:42 2017<br>
>> > @@ -763,7 +763,9 @@ template <class ELFT> void SharedFile<EL<br>
>> >      // files because the loader takes care of it. However, if we<br>
>> promote a<br>
>> >      // DSO symbol to point to .bss due to copy relocation, we need to<br>
>> keep<br>
>> >      // the original alignment requirements. We infer it here.<br>
>> > -    uint32_t Alignment = 1ULL << countTrailingZeros((uint64_t)<br>
>> Sym.st_value);<br>
>> > +    uint32_t Alignment = 1;<br>
>> > +    if (Sym.st_value)<br>
>> > +      Alignment = 1ULL << countTrailingZeros((uint64_t)<wbr>Sym.st_value);<br>
>><br>
>> This still implicitly discard information if st_value is aligned to more<br>
>> than 32 bits, no? Should Alignment be a uint_64?<br>
>><br>
><br>
> Yes, but we use uint32_t to represent alignments everywhere in lld. In<br>
> practice, I don't think there's a point to support alignments larger than 4<br>
> GiB because I've never seen such large alignments. (If we really need it,<br>
> we probably should consider representing alignments in the form of N in 2^N<br>
> to save bits to store alignments.)<br>
<br>
</div></div>I fully agree that we should not support alignments that are that<br>
big. What we should do is produce an error when we see an alignment we<br>
don't support. Right now we just silently use the low 32 bits.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div>