xref: /optee_os/ta/arch/arm/ta.ld.S (revision aaec75ec87470731e54ff9a1cbf5b72c0d6ee9bd)
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		PROVIDE(MCOUNT_SYM = __utee_mcount);
43		__text_end = .;
44	}
45        .plt : { *(.plt) }
46
47	.eh_frame : { *(.eh_frame) } :rodata
48	.rodata : {
49		*(.gnu.linkonce.r.*)
50		*(.rodata .rodata.*)
51	}
52	/* .ARM.exidx is sorted, so has to go in its own output section.  */
53	.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
54        .ctors : { *(.ctors) }
55        .dtors : { *(.dtors) }
56	.got : { *(.got.plt) *(.got) }
57	.rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
58	.rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
59	.rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
60	.rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
61	.rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
62	.rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
63	.rel.dyn : { *(.rel.dyn) }
64	.rel.got : { *(.rel.got) }
65	.rela.got : { *(.rela.got) }
66	.rel.ctors : { *(.rel.ctors) }
67	.rela.ctors : { *(.rela.ctors) }
68	.rel.dtors : { *(.rel.dtors) }
69	.rela.dtors : { *(.rela.dtors) }
70	.rel.init : { *(.rel.init) }
71	.rela.init : { *(.rela.init) }
72	.rel.fini : { *(.rel.fini) }
73	.rela.fini : { *(.rela.fini) }
74	.rel.bss : { *(.rel.bss) }
75	.rela.bss : { *(.rela.bss) }
76	.rel.plt : { *(.rel.plt) }
77	.rela.plt : { *(.rela.plt) }
78	.dynamic : { *(.dynamic) } :dyn :rodata
79	.dynsym : { *(.dynsym) } :rodata
80	.dynstr : { *(.dynstr) }
81	.hash : { *(.hash) }
82
83	/* Page align to allow dropping execute bit for RW data */
84	. = ALIGN(4096);
85
86	.data : { *(.data .data.* .gnu.linkonce.d.*) } :rwdata
87	.bss : {
88		*(.bss .bss.* .gnu.linkonce.b.* COMMON)
89
90		/*
91		 * TA profiling with gprof
92		 * Reserve some space for the profiling buffer, only if the
93		 * TA is instrumented (i.e., some files were built with -pg).
94		 * Note that PROVIDE() above defines a symbol only if it is
95		 * referenced in the object files.
96		 * This also provides a way to detect at runtime if the TA is
97		 * instrumented or not.
98		 */
99		. = ALIGN(8);
100		__gprof_buf_start = .;
101		. += DEFINED(MCOUNT_SYM) ?
102			GPROF_BUF_MULT(__text_end - __text_start) : 0;
103		__gprof_buf_end = .;
104	}
105
106	/DISCARD/ : { *(.interp) }
107}
108
109