blob: 6419245b315fa8a8e1d70707ef94f12bba301fcb [file] [log] [blame]
# 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.
LONG(DEFINED(compartment_error_handler) ? compartment_error_handler - __compartment_code_start + SIZEOF(.compartment_import_table) : -1);
# 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);
*(.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);
}
}