[PATCH] D45368: [ELF] - Stop setting OutSecOff too early.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 6 06:59:42 PDT 2018


grimar created this revision.
grimar added reviewers: ruiu, espindola.
Herald added subscribers: arichardson, emaste.

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)

2. 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.


https://reviews.llvm.org/D45368

Files:
  ELF/LinkerScript.cpp
  ELF/OutputSections.cpp
  ELF/Writer.cpp
  test/ELF/linkerscript/empty-section-size.test
  test/ELF/linkerscript/section-metadata2.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45368.141336.patch
Type: text/x-patch
Size: 4317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180406/c6f7f779/attachment.bin>


More information about the llvm-commits mailing list