This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Stop setting OutSecOff too early.
ClosedPublic

Authored by grimar on Apr 6 2018, 6:59 AM.

Details

Summary

Currently LLD sets OutSecOff in addSection for input sections.
That is a fake offset (just a rude approximation to remember the order),
used for sorting SHF_LINK_ORDER sections
(see resolveShfLinkOrder, compareByFilePosition).

There are 2 problems with such approach:

  1. We currently change and reuse Size field as a value assigned. Changing size is

not good because leads to bugs. Currently, SIZEOF(.bss) for empty .bss returns 2
because we add two empty synthetic sections and increase size twice by 1.
(See PR37011: https://bugs.llvm.org/show_bug.cgi?id=37011)

  1. Such approach simply does not work when --symbol-ordering-file is involved,

because processing of the ordering file might break the initial section order.

Test cases provided. This fixes PR37011.

Diff Detail

Event Timeline

grimar created this revision.Apr 6 2018, 6:59 AM
This revision is now accepted and ready to land.Apr 6 2018, 10:33 AM
This revision was automatically updated to reflect the committed changes.