forked from CHERIoT-Platform/cheriot-rtos
-
Notifications
You must be signed in to change notification settings - Fork 4
/
compartment.ldscript
76 lines (75 loc) · 2.24 KB
/
compartment.ldscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright Microsoft and CHERIoT Contributors.
# SPDX-License-Identifier: MIT
SECTIONS
{
. = 0;
.compartment_export_table : ALIGN(8)
{
# Space for the compartment's PCC and GDC
. = . + 16;
# The compartment error handler, if it is defined.
# The linker will process this relocation now, so we need to make it a
# delta. The final layout will be the compartment import table
# followed by the text segment. There won't be any padding, because
# the compartment import table is more strongly aligned than text.
SHORT(DEFINED(compartment_error_handler) ? compartment_error_handler - __compartment_code_start + SIZEOF(.compartment_import_table) : 0xffff);
# The stackless compartment error handler, if it is defined.
SHORT(DEFINED(compartment_error_handler_stackless) ? compartment_error_handler_stackless - __compartment_code_start + SIZEOF(.compartment_import_table) : 0xffff);
# Array of compartment exports
*(.compartment_exports .compartment_exports.*);
}
# Lay out the compartment imports section. This will end up on PCC.
.compartment_import_table : ALIGN(8)
{
# Array of compartment imports.
HIDDEN(__compartment_pcc_start = .);
# The first import table entry is the compartment switcher.
HIDDEN(.compartment_switcher = .);
. = . + 8;
*(.compartment_imports .compartment_imports.*);
}
# Lay out the code
.text :
{
HIDDEN(__compartment_code_start = .);
# If there is a compartment error handler, make sure that it is before
# anything that can have linker relaxations so that its displacement
# from __compartment_code_start is a constant.
*(.compartment_error_handler_stackless));
*(.compartment_error_handler);
*(.text .text.*);
}
.init_array :
{
HIDDEN(__init_array_start = .);
*(.init_array);
HIDDEN(__init_array_end = .);
}
# Read-only data that will end up in the compartment's PCC.
.rodata :
{
*(.rodata .rodata.*);
*(.data.rel.ro .data.rel.ro.*);
}
# Lay out all of the globals.
.data :
{
*(.data .data.*);
*(.sdata .sdata.*);
}
# BSS remains in a separate section so that we can find it later.
.bss :
{
*(.sbss .sbss.*);
*(.bss .bss.*);
}
.sealed_objects :
{
*(.sealed_objects .sealed_objects.*);
}
# Throw some stuff away that we don't need.
/DISCARD/ :
{
*(.comment);
}
}