mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-23 21:44:15 +00:00
TSP: add PIE support
This implementation simply mimics that of BL31. Change-Id: Ibbaa4ca012d38ac211c52b0b3e97449947160e07 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
69af7fcf99
commit
d974301d22
4 changed files with 65 additions and 3 deletions
4
Makefile
4
Makefile
|
@ -472,6 +472,10 @@ endif
|
||||||
endif
|
endif
|
||||||
BL31_CFLAGS += -fpie
|
BL31_CFLAGS += -fpie
|
||||||
BL31_LDFLAGS += $(PIE_LDFLAGS)
|
BL31_LDFLAGS += $(PIE_LDFLAGS)
|
||||||
|
ifeq ($(ARCH),aarch64)
|
||||||
|
BL32_CFLAGS += -fpie
|
||||||
|
BL32_LDFLAGS += $(PIE_LDFLAGS)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Include the CPU specific operations makefile, which provides default
|
# Include the CPU specific operations makefile, which provides default
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
|
* Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <platform_def.h>
|
||||||
|
|
||||||
#include <arch.h>
|
#include <arch.h>
|
||||||
#include <asm_macros.S>
|
#include <asm_macros.S>
|
||||||
#include <bl32/tsp/tsp.h>
|
#include <bl32/tsp/tsp.h>
|
||||||
|
@ -46,6 +48,24 @@
|
||||||
|
|
||||||
func tsp_entrypoint _align=3
|
func tsp_entrypoint _align=3
|
||||||
|
|
||||||
|
#if ENABLE_PIE
|
||||||
|
/*
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
* If PIE is enabled fixup the Global descriptor Table only
|
||||||
|
* once during primary core cold boot path.
|
||||||
|
*
|
||||||
|
* Compile time base address, required for fixup, is calculated
|
||||||
|
* using "pie_fixup" label present within first page.
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
pie_fixup:
|
||||||
|
ldr x0, =pie_fixup
|
||||||
|
and x0, x0, #~(PAGE_SIZE - 1)
|
||||||
|
mov_imm x1, (BL32_LIMIT - BL32_BASE)
|
||||||
|
add x1, x1, x0
|
||||||
|
bl fixup_gdt_reloc
|
||||||
|
#endif /* ENABLE_PIE */
|
||||||
|
|
||||||
/* ---------------------------------------------
|
/* ---------------------------------------------
|
||||||
* Set the exception vector to something sane.
|
* Set the exception vector to something sane.
|
||||||
* ---------------------------------------------
|
* ---------------------------------------------
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
|
* Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -36,6 +36,17 @@ SECTIONS
|
||||||
.rodata . : {
|
.rodata . : {
|
||||||
__RODATA_START__ = .;
|
__RODATA_START__ = .;
|
||||||
*(.rodata*)
|
*(.rodata*)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep the .got section in the RO section as it is patched
|
||||||
|
* prior to enabling the MMU and having the .got in RO is better for
|
||||||
|
* security. GOT is a table of addresses so ensure 8-byte alignment.
|
||||||
|
*/
|
||||||
|
. = ALIGN(8);
|
||||||
|
__GOT_START__ = .;
|
||||||
|
*(.got)
|
||||||
|
__GOT_END__ = .;
|
||||||
|
|
||||||
. = ALIGN(PAGE_SIZE);
|
. = ALIGN(PAGE_SIZE);
|
||||||
__RODATA_END__ = .;
|
__RODATA_END__ = .;
|
||||||
} >RAM
|
} >RAM
|
||||||
|
@ -45,7 +56,19 @@ SECTIONS
|
||||||
*tsp_entrypoint.o(.text*)
|
*tsp_entrypoint.o(.text*)
|
||||||
*(.text*)
|
*(.text*)
|
||||||
*(.rodata*)
|
*(.rodata*)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep the .got section in the RO section as it is patched
|
||||||
|
* prior to enabling the MMU and having the .got in RO is better for
|
||||||
|
* security. GOT is a table of addresses so ensure 8-byte alignment.
|
||||||
|
*/
|
||||||
|
. = ALIGN(8);
|
||||||
|
__GOT_START__ = .;
|
||||||
|
*(.got)
|
||||||
|
__GOT_END__ = .;
|
||||||
|
|
||||||
*(.vectors)
|
*(.vectors)
|
||||||
|
|
||||||
__RO_END_UNALIGNED__ = .;
|
__RO_END_UNALIGNED__ = .;
|
||||||
/*
|
/*
|
||||||
* Memory page(s) mapped to this section will be marked as
|
* Memory page(s) mapped to this section will be marked as
|
||||||
|
@ -69,6 +92,17 @@ SECTIONS
|
||||||
__DATA_END__ = .;
|
__DATA_END__ = .;
|
||||||
} >RAM
|
} >RAM
|
||||||
|
|
||||||
|
/*
|
||||||
|
* .rela.dyn needs to come after .data for the read-elf utility to parse
|
||||||
|
* this section correctly. Ensure 8-byte alignment so that the fields of
|
||||||
|
* RELA data structure are aligned.
|
||||||
|
*/
|
||||||
|
. = ALIGN(8);
|
||||||
|
__RELA_START__ = .;
|
||||||
|
.rela.dyn . : {
|
||||||
|
} >RAM
|
||||||
|
__RELA_END__ = .;
|
||||||
|
|
||||||
#ifdef TSP_PROGBITS_LIMIT
|
#ifdef TSP_PROGBITS_LIMIT
|
||||||
ASSERT(. <= TSP_PROGBITS_LIMIT, "TSP progbits has exceeded its limit.")
|
ASSERT(. <= TSP_PROGBITS_LIMIT, "TSP progbits has exceeded its limit.")
|
||||||
#endif
|
#endif
|
||||||
|
@ -129,6 +163,10 @@ SECTIONS
|
||||||
__RW_END__ = .;
|
__RW_END__ = .;
|
||||||
__BL32_END__ = .;
|
__BL32_END__ = .;
|
||||||
|
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.dynsym .dynstr .hash .gnu.hash)
|
||||||
|
}
|
||||||
|
|
||||||
__BSS_SIZE__ = SIZEOF(.bss);
|
__BSS_SIZE__ = SIZEOF(.bss);
|
||||||
#if USE_COHERENT_MEM
|
#if USE_COHERENT_MEM
|
||||||
__COHERENT_RAM_UNALIGNED_SIZE__ =
|
__COHERENT_RAM_UNALIGNED_SIZE__ =
|
||||||
|
|
|
@ -213,7 +213,7 @@ Common build options
|
||||||
|
|
||||||
- ``ENABLE_PIE``: Boolean option to enable Position Independent Executable(PIE)
|
- ``ENABLE_PIE``: Boolean option to enable Position Independent Executable(PIE)
|
||||||
support within generic code in TF-A. This option is currently only supported
|
support within generic code in TF-A. This option is currently only supported
|
||||||
in BL2_AT_EL3 and BL31. Default is 0.
|
in BL2_AT_EL3, BL31, and BL32 (TSP). Default is 0.
|
||||||
|
|
||||||
- ``ENABLE_PMF``: Boolean option to enable support for optional Performance
|
- ``ENABLE_PMF``: Boolean option to enable support for optional Performance
|
||||||
Measurement Framework(PMF). Default is 0.
|
Measurement Framework(PMF). Default is 0.
|
||||||
|
|
Loading…
Add table
Reference in a new issue