[all-commits] [llvm/llvm-project] dbd0ad: [LLD][ELF] Add support for INPUT_SECTION_FLAGS

Peter Smith via All-commits all-commits at lists.llvm.org
Tue Jan 21 02:15:02 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: dbd0ad33668ea7b6d5c2c5db1fa290cc08ab99d9
      https://github.com/llvm/llvm-project/commit/dbd0ad33668ea7b6d5c2c5db1fa290cc08ab99d9
  Author: Peter Smith <peter.smith at linaro.org>
  Date:   2020-01-21 (Tue, 21 Jan 2020)

  Changed paths:
    M lld/ELF/LinkerScript.cpp
    M lld/ELF/LinkerScript.h
    M lld/ELF/ScriptParser.cpp
    A lld/test/ELF/input-section-flags-diag1.test
    A lld/test/ELF/input-section-flags-diag2.test
    A lld/test/ELF/input-section-flags-diag3.test
    A lld/test/ELF/input-section-flags-keep.s
    A lld/test/ELF/input-section-flags.s

  Log Message:
  -----------
  [LLD][ELF] Add support for INPUT_SECTION_FLAGS

The INPUT_SECTION_FLAGS linker script command is used to constrain the
section pattern matching to sections that match certain combinations of
flags.

There are two ways to express the constraint.
withFlags: Section must have these flags.
withoutFlags: Section must not have these flags.

The syntax of the command is:
INPUT_SECTION_FLAGS '(' sect_flag_list ')'
sect_flag_list: NAME
| sect_flag_list '&' NAME

Where NAME matches a section flag name such as SHF_EXECINSTR, or the
integer value of a section flag. If the first character of NAME is ! then
it means must not contain flag.

We do not support the rare case of { INPUT_SECTION_FLAGS(flags) filespec }
where filespec has no input section description like (.text).

As an example from the ld man page:
SECTIONS {
  .text : { INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS) *(.text) }
  .text2 :  { INPUT_SECTION_FLAGS (!SHF_WRITE) *(.text) }
}
.text will match sections called .text that have both the SHF_MERGE and
SHF_STRINGS flag.
.text2 will match sections called .text that don't have the SHF_WRITE flag.

The flag names accepted are the generic to all targets and SHF_ARM_PURECODE
as it is very useful to filter all the pure code sections into a single
program header that can be marked execute never.

fixes PR44265

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




More information about the All-commits mailing list