[all-commits] [llvm/llvm-project] c4fea3: [LLD][ELF] Cortex-M Security Extensions (CMSE) Sup...

amilendra via All-commits all-commits at lists.llvm.org
Wed Jun 21 06:47:49 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c4fea3905617af89d1ad87319893e250f5b72dd6
      https://github.com/llvm/llvm-project/commit/c4fea3905617af89d1ad87319893e250f5b72dd6
  Author: Amilendra Kodithuwakku <Amilendra.Kodithuwakku at arm.com>
  Date:   2023-06-21 (Wed, 21 Jun 2023)

  Changed paths:
    M lld/ELF/Arch/ARM.cpp
    M lld/ELF/Config.h
    M lld/ELF/Driver.cpp
    M lld/ELF/InputFiles.cpp
    M lld/ELF/InputFiles.h
    M lld/ELF/LinkerScript.cpp
    M lld/ELF/LinkerScript.h
    M lld/ELF/MarkLive.cpp
    M lld/ELF/Options.td
    M lld/ELF/SymbolTable.h
    M lld/ELF/SyntheticSections.cpp
    M lld/ELF/SyntheticSections.h
    M lld/ELF/Target.h
    M lld/ELF/Writer.cpp
    A lld/test/ELF/Inputs/arm-cmse-macros.s
    A lld/test/ELF/aarch64-cmse.s
    A lld/test/ELF/arm-cmse-diagnostics.s
    A lld/test/ELF/arm-cmse-implib.s
    A lld/test/ELF/arm-cmse-keep-sections.s
    A lld/test/ELF/arm-cmse-noveneers.s
    A lld/test/ELF/arm-cmse-secure.s
    A lld/test/ELF/arm-cmse-veneers.s

  Log Message:
  -----------
  [LLD][ELF] Cortex-M Security Extensions (CMSE) Support

This commit provides linker support for Cortex-M Security Extensions (CMSE).
The specification for this feature can be found in ARM v8-M Security Extensions:
Requirements on Development Tools.

The linker synthesizes a security gateway veneer in a special section;
`.gnu.sgstubs`, when it finds non-local symbols `__acle_se_<entry>` and `<entry>`,
defined relative to the same text section and having the same address. The
address of `<entry>` is retargeted to the starting address of the
linker-synthesized security gateway veneer in section `.gnu.sgstubs`.

In summary, the linker translates input:

```
    .text
  entry:
  __acle_se_entry:
    [entry_code]

```
into:

```
    .section .gnu.sgstubs
  entry:
    SG
    B.W __acle_se_entry

    .text
  __acle_se_entry:
    [entry_code]
```

If addresses of `__acle_se_<entry>` and `<entry>` are not equal, the linker
considers that `<entry>` already defines a secure gateway veneer so does not
synthesize one.

If `--out-implib=<out.lib>` is specified, the linker writes the list of secure
gateway veneers into a CMSE import library `<out.lib>`. The CMSE import library
will have 3 sections: `.symtab`, `.strtab`, `.shstrtab`. For every secure gateway
veneer <entry> at address `<addr>`, `.symtab` contains a `SHN_ABS` symbol `<entry>` with
value `<addr>`.

If `--in-implib=<in.lib>` is specified, the linker reads the existing CMSE import
library `<in.lib>` and preserves the entry function addresses in the resulting
executable and new import library.

Reviewed By: MaskRay, peter.smith

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




More information about the All-commits mailing list