xref: /optee_os/ta/arch/arm/ta.ld.S (revision fa0525fa6a3046e03374f572141845c268058e61)
1#ifdef ARM32
2OUTPUT_FORMAT("elf32-littlearm")
3OUTPUT_ARCH(arm)
4#define MCOUNT_SYM __gnu_mcount_nc
5/*
6 * This magic value corresponds to the size requested by
7 * libutee/arch/arm/gprof/gprof.c
8 */
9#define GPROF_BUF_MULT(x) ((x) * 136) / 100
10#endif
11#ifdef ARM64
12OUTPUT_FORMAT("elf64-littleaarch64")
13OUTPUT_ARCH(aarch64)
14#define MCOUNT_SYM _mcount
15#define GPROF_BUF_MULT(x) ((x) * 177) / 100
16#endif
17
18PHDRS {
19	/*
20	 * Exec and rodata headers are hard coded to RX and RO
21	 * respectively. This is needed because the binary is relocatable
22	 * and the linker would automatically make any header writeable
23	 * that need to be updated during relocation.
24	 */
25	exec PT_LOAD FLAGS (5);		/* RX */
26	rodata PT_LOAD FLAGS (4);	/* RO */
27	rwdata PT_LOAD;
28	dyn PT_DYNAMIC;
29}
30
31SECTIONS {
32	.ta_head : {*(.ta_head)} :exec
33	.text : {
34		__text_start = .;
35		*(.text .text.*)
36		*(.stub)
37		*(.glue_7)
38		*(.glue_7t)
39		*(.gnu.linkonce.t.*)
40		/* Workaround for an erratum in ARM's VFP11 coprocessor */
41		*(.vfp11_veneer)
42		__text_end = .;
43	}
44        .plt : { *(.plt) }
45
46	.eh_frame : { *(.eh_frame) } :rodata
47	.rodata : {
48		*(.gnu.linkonce.r.*)
49		*(.rodata .rodata.*)
50	}
51	/* .ARM.exidx is sorted, so has to go in its own output section.  */
52	.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
53        .ctors : { *(.ctors) }
54        .dtors : { *(.dtors) }
55	.got : { *(.got.plt) *(.got) }
56	.rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
57	.rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
58	.rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
59	.rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
60	.rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
61	.rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
62	.rel.dyn : { *(.rel.dyn) }
63	.rel.got : { *(.rel.got) }
64	.rela.got : { *(.rela.got) }
65	.rel.ctors : { *(.rel.ctors) }
66	.rela.ctors : { *(.rela.ctors) }
67	.rel.dtors : { *(.rel.dtors) }
68	.rela.dtors : { *(.rela.dtors) }
69	.rel.init : { *(.rel.init) }
70	.rela.init : { *(.rela.init) }
71	.rel.fini : { *(.rel.fini) }
72	.rela.fini : { *(.rela.fini) }
73	.rel.bss : { *(.rel.bss) }
74	.rela.bss : { *(.rela.bss) }
75	.rel.plt : { *(.rel.plt) }
76	.rela.plt : { *(.rela.plt) }
77	.dynamic : { *(.dynamic) } :dyn :rodata
78	.dynsym : { *(.dynsym) } :rodata
79	.dynstr : { *(.dynstr) }
80	.hash : { *(.hash) }
81
82	/* Page align to allow dropping execute bit for RW data */
83	. = ALIGN(4096);
84
85	.data : { *(.data .data.* .gnu.linkonce.d.*) } :rwdata
86	.bss : {
87		*(.bss .bss.* .gnu.linkonce.b.* COMMON)
88
89		/*
90		 * TA profiling with gprof
91		 * Reserve some space for the profiling buffer, only if the
92		 * TA is instrumented (i.e., some files were built with -pg).
93		 * This also provides a way to detect at runtime if the TA is
94		 * instrumented or not.
95		 */
96		. = ALIGN(8);
97		__gprof_buf_start = .;
98		. += DEFINED(MCOUNT_SYM) ?
99			GPROF_BUF_MULT(__text_end - __text_start) : 0;
100		__gprof_buf_end = .;
101	}
102
103	/DISCARD/ : { *(.interp) }
104}
105
106