<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 2, 2015 at 8:17 AM, George Rimar via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>>> +  // Can have offset if requires copy relocation.<br>
>> +  uintX_t OffsetInBSS = 0;<br>
>> +  bool NeedsCopy = false;<br>
><br>
>You can drop the bool by initializing OffsetInBSS to -1 and using that<br>
>to mean that copy relocation is not needed, no?<br>
<br>
</span>I dont think it will be enough. In void Writer<ELFT>::scanRelocs() method E->NeedsCopy flag is used to determine<br>
if rela.dyn entry is needed for SharedSymbol or not. Each such copy relocation for symbol should be added to rela.dyn only once<br>
and that is for what this flag was initially added I think.<br>
<span><br>
if (auto *E = dyn_cast<SharedSymbol<ELFT>>(Body)) {<br>
</span>  if (E->NeedsCopy)<br>
    continue;<br>
<span>  E->NeedsCopy = Target->relocNeedsCopy(Type, *Body);<br>
}<br>
</span>....<br>
Out<ELFT>::RelaDyn->addReloc({C, RI});<br>
<span><br>
<br>
>> +    const Elf_Sym &Sym = C->Sym;<br>
>> +    // We don't know the exact alignment requirement for the data copied by a<br>
>> +    // copy relocation, so align that to 16 byte boundaries that should be large<br>
>> +    // enough unconditionally.<br>
>> +    Off = RoundUpToAlignment(Off, 16);<br>
>> +    C->OffsetInBSS = Off;<br>
>> +    Off += Sym.st_size;<br>
><br>
>The alignment of a symbol is less than or equal to the alignment of<br>
>the section it came from. You can use the alignment of the section in<br>
>here.<br>
<br>
</span>I`ll review that idea later.<div><div><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank"></a></div></div></blockquote><div><br></div><div>If we push hard, a symbol alignment can be computed from the section alignment *and* the offset of the symbol in the section. For example, if symbol S is at offset 24 in a section whose alignment is 16, S needs to be aligned on a 8 byte boundary. That's what gold does.</div><div><br></div><div>But I don't think we really need that because I think the number of copy relocations is small. Saving a few bytes doesn't seem to make sense.</div></div></div></div>