xref: /optee_os/ta/arch/arm/ta.ld.S (revision 8bbd9b374a51a1b8617796aae8a70c271543357f)
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
18#ifndef CFG_FTRACE_BUF_SIZE
19#define CFG_FTRACE_BUF_SIZE 2048
20#endif
21
22SECTIONS {
23	.ta_head : {*(.ta_head)}
24	.text : {
25		__text_start = .;
26		*(.text .text.*)
27		*(.stub)
28		*(.glue_7)
29		*(.glue_7t)
30		*(.gnu.linkonce.t.*)
31		/* Workaround for an erratum in ARM's VFP11 coprocessor */
32		*(.vfp11_veneer)
33		__text_end = .;
34	}
35        .plt : { *(.plt) }
36
37	.eh_frame : { *(.eh_frame) }
38	.rodata : {
39		*(.gnu.linkonce.r.*)
40		*(.rodata .rodata.*)
41	}
42	/* .ARM.exidx is sorted, so has to go in its own output section.  */
43	.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
44        .ctors : { *(.ctors) }
45        .dtors : { *(.dtors) }
46	.dynsym : { *(.dynsym) }
47	.dynstr : { *(.dynstr) }
48	.hash : { *(.hash) }
49
50	/* Page align to allow dropping execute bit for RW data */
51	. = ALIGN(4096);
52
53	.got : { *(.got.plt) *(.got) }
54	.rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
55	.rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
56	.rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
57	.rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
58	.rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
59	.rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
60	.rel.dyn : { *(.rel.dyn) }
61	.rel.got : { *(.rel.got) }
62	.rela.got : { *(.rela.got) }
63	.rel.ctors : { *(.rel.ctors) }
64	.rela.ctors : { *(.rela.ctors) }
65	.rel.dtors : { *(.rel.dtors) }
66	.rela.dtors : { *(.rela.dtors) }
67	.rel.init : { *(.rel.init) }
68	.rela.init : { *(.rela.init) }
69	.rel.fini : { *(.rel.fini) }
70	.rela.fini : { *(.rela.fini) }
71	.rel.bss : { *(.rel.bss) }
72	.rela.bss : { *(.rela.bss) }
73	.rel.plt : { *(.rel.plt) }
74	.rela.plt : { *(.rela.plt) }
75	.dynamic : { *(.dynamic) }
76
77	.data : { *(.data .data.* .gnu.linkonce.d.*) }
78	.bss : {
79		*(.bss .bss.* .gnu.linkonce.b.* COMMON)
80
81		/*
82		 * TA profiling with gprof
83		 * Reserve some space for the profiling buffer, only if the
84		 * TA is instrumented (i.e., some files were built with -pg).
85		 * This also provides a way to detect at runtime if the TA is
86		 * instrumented or not.
87		 */
88		. = ALIGN(8);
89		__gprof_buf_start = .;
90		. += DEFINED(MCOUNT_SYM) ?
91			GPROF_BUF_MULT(__text_end - __text_start) : 0;
92		__gprof_buf_end = .;
93
94		/*
95		 * TA tracing using ftrace
96		 * Reserve some space for the ftrace buffer, only if the
97		 * TA is instrumented (i.e., some files were built with -pg).
98		 */
99		. = ALIGN(8);
100		__ftrace_buf_start = .;
101		. += DEFINED(MCOUNT_SYM) ?
102			CFG_FTRACE_BUF_SIZE : 0;
103		__ftrace_buf_end = .;
104	}
105
106	/DISCARD/ : { *(.interp) }
107}
108
109