[PATCH] D85100: [ELF] Allow sections after a non-allocable section to be covered by PT_LOAD

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 2 13:29:34 PDT 2020


MaskRay created this revision.
MaskRay added reviewers: grimar, jhenderson, psmith.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
MaskRay requested review of this revision.

GNU ld allows sections after a non-allocable section to be covered by PT_LOAD
(PR37607) and assigns addresses to non-allocable output sections (similar to
allocable NOBITS sections. The location counter is not advanced).

This patch tries to fix PR37607 (remove a special case in
`Writer<ELFT>::createPhdrs`). To make the created PT_LOAD meaningful, we cannot
reset dot to 0 for a middle non-allocable output section. This results in
removal of wwo special cases in LinkerScript::assignOffsets. Non-allocable
non-orphan sections can have non-zero addresses like in GNU ld.

The zero address rule for non-allocable sections is weakened to apply to orphan
only. This results in a special case in `createSection` and findOrphanPos, respectively.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85100

Files:
  lld/ELF/LinkerScript.cpp
  lld/ELF/Writer.cpp
  lld/test/ELF/linkerscript/compress-debug-sections-custom.s
  lld/test/ELF/linkerscript/sections.s
  lld/test/ELF/linkerscript/symbols-non-alloc.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85100.282477.patch
Type: text/x-patch
Size: 7059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200802/37e9b622/attachment.bin>


More information about the llvm-commits mailing list