[all-commits] [llvm/llvm-project] 66f8ac: [ELF] Support (TYPE=<value>) to customize the outp...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Feb 17 12:11:11 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 66f8ac8d3604d67599734c3fd272032e9448aca2
      https://github.com/llvm/llvm-project/commit/66f8ac8d3604d67599734c3fd272032e9448aca2
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-02-17 (Thu, 17 Feb 2022)

  Changed paths:
    M lld/ELF/OutputSections.cpp
    M lld/ELF/OutputSections.h
    M lld/ELF/ScriptParser.cpp
    M lld/docs/ELF/linker_script.rst
    A lld/test/ELF/linkerscript/custom-section-type.s
    M lld/test/ELF/linkerscript/noload.s

  Log Message:
  -----------
  [ELF] Support (TYPE=<value>) to customize the output section type

The current output section type allows to set the ELF section type to
SHT_PROGBITS or SHT_NOLOAD. This patch allows an arbitrary section value
to be specified. Some common SHT_* literal names are supported as well.

```
SECTIONS {
  note (TYPE=SHT_NOTE) : { BYTE(8) *(note) }
  init_array ( TYPE=14 ) : { QUAD(14) }
  fini_array (TYPE = SHT_FINI_ARRAY) : { QUAD(15) }
}
```

When `sh_type` is specified, it is an error if an input section has a different type.

Our syntax is compatible with GNU ld 2.39 (https://sourceware.org/bugzilla/show_bug.cgi?id=28841).

Reviewed By: peter.smith

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




More information about the All-commits mailing list