This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Linkerscript: fixed non-determinism when handling MEMORY.
ClosedPublic

Authored by grimar on Nov 2 2017, 4:49 AM.

Details

Summary

When findMemoryRegion do search to find a region for output section it
iterates over MemoryRegions which is DenseMap and so does not
guarantee iteration in insertion order. As a result selected region depends
on its name and not on its definition position
Testcase shows the issue, patch fixes it. Behavior after applying the patch
seems consistent with bfd.

Diff Detail

Event Timeline

grimar created this revision.Nov 2 2017, 4:49 AM
grimar planned changes to this revision.Nov 2 2017, 4:56 AM
grimar updated this revision to Diff 121286.Nov 2 2017, 5:28 AM
  • Improved testcase.
  • Fixed using of destroyed object happened when doing Script->MemoryRegions[Alias] = Script->MemoryRegions[Name];, where MemoryRegions is MapVector. Right side returned reference to element of internal vector and it was resized and invalidated when called operator[] for left side assignment, so dead value was assigned finally.
ruiu accepted this revision.Nov 2 2017, 10:53 AM

LGTM

This revision is now accepted and ready to land.Nov 2 2017, 10:53 AM
This revision was automatically updated to reflect the committed changes.