[PATCH] D74375: [ELF] Support INSERT [AFTER|BEFORE] for orphan sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 18:48:43 PST 2020


MaskRay created this revision.
MaskRay added reviewers: grimar, peter.smith, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
MaskRay edited the summary of this revision.

D43468 <https://reviews.llvm.org/D43468>+D44380 <https://reviews.llvm.org/D44380> added INSERT [AFTER|BEFORE] for non-orphan sections. This patch
makes INSERT work for orphan sections as well.

`SECTIONS {...} INSERT [AFTER|BEFORE] .foo` does not set `hasSectionCommands`,
so various layout changes will be suppressed. The behavior is similar to GNU ld:
INSERT is not considered an external linker script.

This feature makes the section layout more flexible. It can be used to:

- Place .nv_fatbin before other readonly SHT_PROGBITS sections to

mitigate relocation overflows.

- Distrub the layout to expose address sensitive application bugs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74375

Files:
  lld/ELF/Driver.cpp
  lld/ELF/LinkerScript.cpp
  lld/ELF/LinkerScript.h
  lld/ELF/ScriptParser.cpp
  lld/ELF/Writer.cpp
  lld/test/ELF/linkerscript/insert-after.test
  lld/test/ELF/linkerscript/insert-before.test
  lld/test/ELF/linkerscript/insert-duplicate.test
  lld/test/ELF/linkerscript/insert-not-exist.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74375.243713.patch
Type: text/x-patch
Size: 13245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200211/1126d16e/attachment.bin>


More information about the llvm-commits mailing list