[PATCH] D68256: ELF: Add .interp synthetic sections first in createSyntheticSections().

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 19:03:44 PDT 2019


pcc created this revision.
pcc added reviewers: ruiu, MaskRay, grimar, peter.smith.
Herald added subscribers: kristof.beyls, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

Our .interp section is not a SyntheticSection. As a result, it terminates the
loop in removeUnusedSyntheticSections(). This has at least two consequences:

- The synthetic .bss and .bss.rel.ro sections are always present in dynamically linked executables, even when they are not needed.
- The synthetic .ARM.exidx (and possibly other) sections are always present in partitions other than the last one, even when not needed. .ARM.exidx in particular is problematic because it assumes that its list of code sections is non-empty in getLinkOrderDep(), which can lead to a crash if the partition does not have any code sections.

Fix these problems by moving the creation of the .interp sections to the
top of createSyntheticSections(). While here, make the code a little less
error-prone by changing the add() lambdas to take a SyntheticSection instead
of an InputSectionBase.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68256

Files:
  lld/ELF/SyntheticSections.cpp
  lld/ELF/Writer.cpp
  lld/test/ELF/Inputs/shared.s
  lld/test/ELF/dynamic-linker.s
  lld/test/ELF/partition-dynamic-linker.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68256.222536.patch
Type: text/x-patch
Size: 4132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191001/a9293346/attachment.bin>


More information about the llvm-commits mailing list