mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 10:18:14 +08:00
[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
This commit is contained in:
@@ -896,6 +896,15 @@ void LinkerScript::diagnoseOrphanHandling() const {
|
||||
}
|
||||
}
|
||||
|
||||
void LinkerScript::diagnoseMissingSGSectionAddress() const {
|
||||
if (!config->cmseImplib || !in.armCmseSGSection->isNeeded())
|
||||
return;
|
||||
|
||||
OutputSection *sec = findByName(sectionCommands, ".gnu.sgstubs");
|
||||
if (sec && !sec->addrExpr && !config->sectionStartMap.count(".gnu.sgstubs"))
|
||||
error("no address assigned to the veneers output section " + sec->name);
|
||||
}
|
||||
|
||||
// This function searches for a memory region to place the given output
|
||||
// section in. If found, a pointer to the appropriate memory region is
|
||||
// returned in the first member of the pair. Otherwise, a nullptr is returned.
|
||||
|
||||
Reference in New Issue
Block a user