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 34 .text : { 35 __text_start = .; 36 *(.text .text.*) 37 *(.stub) 38 *(.glue_7) 39 *(.glue_7t) 40 *(.gnu.linkonce.t.*) 41 /* Workaround for an erratum in ARM's VFP11 coprocessor */ 42 *(.vfp11_veneer) 43 PROVIDE(MCOUNT_SYM = __utee_mcount); 44 __text_end = .; 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 54 .ctors : { *(.ctors) } 55 .dtors : { *(.dtors) } 56 .plt : { *(.plt) } 57 .got : { *(.got.plt) *(.got) } 58 59 .rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) } 60 .rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) } 61 .rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) } 62 .rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) } 63 .rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } 64 .rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } 65 .rel.dyn : { *(.rel.dyn) } 66 .rel.got : { *(.rel.got) } 67 .rela.got : { *(.rela.got) } 68 .rel.ctors : { *(.rel.ctors) } 69 .rela.ctors : { *(.rela.ctors) } 70 .rel.dtors : { *(.rel.dtors) } 71 .rela.dtors : { *(.rela.dtors) } 72 .rel.init : { *(.rel.init) } 73 .rela.init : { *(.rela.init) } 74 .rel.fini : { *(.rel.fini) } 75 .rela.fini : { *(.rela.fini) } 76 .rel.bss : { *(.rel.bss) } 77 .rela.bss : { *(.rela.bss) } 78 .rel.plt : { *(.rel.plt) } 79 .rela.plt : { *(.rela.plt) } 80 81 .dynamic : { *(.dynamic) } :dyn :rodata 82 .dynsym : { *(.dynsym) } :rodata 83 .dynstr : { *(.dynstr) } 84 .hash : { *(.hash) } 85 86 /* Page align to allow dropping execute bit for RW data */ 87 . = ALIGN(4096); 88 89 .data : { *(.data .data.* .gnu.linkonce.d.*) } :rwdata 90 91 .bss : { 92 *(.bss .bss.* .gnu.linkonce.b.* COMMON) 93 94 /* 95 * TA profiling with gprof 96 * Reserve some space for the profiling buffer, only if the 97 * TA is instrumented (i.e., some files were built with -pg). 98 * Note that PROVIDE() above defines a symbol only if it is 99 * referenced in the object files. 100 * This also provides a way to detect at runtime if the TA is 101 * instrumented or not. 102 */ 103 . = ALIGN(8); 104 __gprof_buf_start = .; 105 . += DEFINED(MCOUNT_SYM) ? 106 GPROF_BUF_MULT(__text_end - __text_start) : 0; 107 __gprof_buf_end = .; 108 } 109 110 /DISCARD/ : { *(.interp) } 111} 112 113