[all-commits] [llvm/llvm-project] 7c426f: [ELF] Support INSERT [AFTER|BEFORE] for orphan sec...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Feb 12 08:23:01 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 7c426fb1a6d4b7db2517529ec5d863b380479249
      https://github.com/llvm/llvm-project/commit/7c426fb1a6d4b7db2517529ec5d863b380479249
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-02-12 (Wed, 12 Feb 2020)

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

  Log Message:
  -----------
  [ELF] Support INSERT [AFTER|BEFORE] for orphan sections

D43468+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 the result
will be similar to a regular link without a linker script. The differences when `hasSectionCommands` is set include:

* image base is different
* -z noseparate-code/-z noseparate-loadable-segments are unavailable
* some special symbols such as `_end _etext _edata` are not defined

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.
* Disturb the layout to expose address sensitive application bugs.

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D74375




More information about the All-commits mailing list