[PATCH] D38361: [ELF] Stop setting output section size early

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 12:15:03 PST 2017


James Henderson via Phabricator <reviews at reviews.llvm.org> writes:

>  template <class ELFT>
> Index: ELF/InputSection.h
> ===================================================================
> --- ELF/InputSection.h
> +++ ELF/InputSection.h
> @@ -324,6 +324,11 @@
>    // to. The writer sets a value.
>    uint64_t OutSecOff = 0;
>  
> +  // The order in which the section was added to its output section. This is
> +  // used when ordering SHF_LINK_ORDER sections. It is not set for sections
> +  // inserted late, such as thunk sections.
> +  llvm::Optional<size_t> OutSecPos;
> +

I don't like the idea of adding a member for the section position. At no
point we need the position and the offset simultaneously and having both
variables means they can get inconsistent.

One way to look at the current issue is that the early estimate of the
offset is correct in the common case, which makes it really easy to use
it incorrectly before the final value is computed.

If we make the value almost always wrong, that problem goes away. What
do you think of the attached patch? We could rename OutSecOff to
OutSecOffsetOrIndex, but that doesn't seem worth it.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.diff
Type: text/x-patch
Size: 3265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171207/3a9cf3de/attachment.bin>
-------------- next part --------------

Cheers,
Rafael


More information about the llvm-commits mailing list