1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/* 18 These addresses are fake, but in a particular way that mesh with our expectations. 19 - ".flash" will contain all parts of the app that go into actual flash 20 *app header 21 * code 22 * RO data 23 * initial contents of RW data 24 * initial contents of the GOT 25 * list of relocs 26 * list of symbols 27 - ".ram" will contain all data that uses ram (and is not part of the flash image) 28 * RW data in its actua location 29 * BSS 30 * the GOT 31 - ".trash" contains sections taht GCC simply feel like it MUST produce (link error otherwise) but we have no use for. it will be tripped 32 33 After this image is produced a nonoapp_postprocess unitily will process relocs and symbols and compress them to a small reloc table 34 while also modifying the app code itself potentially to adjust for new reloc format. This shrinks relocs a lot. GCC produces relocs at 8 35 bytes per reloc and symbols at 16 bytes per symbol. We remove all symbol infos (as we do not need them) and compress the relevant data 36 from there into relocs and app image itself, generating 4 bytes per reloc of "nano reloc data" 37 38 Our format allows apps that are up to 256MB of flash and 256MB of ram in size. 39*/ 40 41MEMORY 42{ 43 flash : ORIGIN = 0x10000000, LENGTH = 256K /* we write this to flash */ 44 ram : ORIGIN = 0x80000000, LENGTH = 128K /* we allocate this in ram */ 45 trash : ORIGIN = 0xF0000000, LENGTH = 256K /* we throw this away soon after linking */ 46} 47 48SECTIONS 49{ 50 .flash : { 51 /***** start of struct BinHdr [see nanohub/nanohub.h] *****/ 52 /* binary format marker: 'NBIN' (LE) */ 53 LONG(0x4E49424E) 54 55 /* version */ 56 KEEP(*(.app_version)); 57 58 /* things we need to load app */ 59 LONG(__data_start) 60 LONG(__data_end) 61 LONG(LOADADDR(.data)) 62 63 LONG(__bss_start) 64 LONG(__bss_end) 65 66 /* things we need to run it */ 67 LONG(__got_start) 68 LONG(__got_end) 69 LONG(__rel_start) 70 LONG(__rel_end) 71 72 KEEP(*(.app_init)); 73 /***** end of struct BinHdr [see nanohub/nanohub.h] *****/ 74 75 /* code */ 76 *(.text) *(.text.*) ; 77 *(.rodata) *(.rodata.*) ; 78 . = ALIGN(4); 79 } > flash = 0xff 80 81 .data : { 82 . = ALIGN(4); 83 __data_start = ABSOLUTE(.); 84 *(.data); 85 *(.data.*); 86 . = ALIGN(4); 87 __data_end = ABSOLUTE(.); 88 89 . = ALIGN(4); 90 __got_start = ABSOLUTE(.); 91 *(.got) *(.got.*) ; 92 __got_end = ABSOLUTE(.); 93 94 } > ram AT > flash 95 96 .relocs : { 97 . = ALIGN(4); 98 /* relocs */ 99 __rel_start = ABSOLUTE(.); 100 *(.rel) *(.rel.*) *(.rel.data.rel.local) 101 __rel_end = ABSOLUTE(.); 102 . = ALIGN(4); 103 104 } > flash = 0xff 105 106 .dynsym : { 107 *(.dynsym); *(.dynsym.*); 108 } > flash = 0xff 109 110 .bss : { 111 . = ALIGN(4); 112 __bss_start = ABSOLUTE(.); 113 *(.bss) *(.bss.*) *(COMMON); 114 . = ALIGN(4); 115 __bss_end = ABSOLUTE(.); 116 } > ram 117 118 __data_data = LOADADDR(.data); 119 120 .dynstr : { 121 *(.dynstr); *(.dynstr.*); 122 } > trash 123 .hash : { 124 *(.hash); *(.hash.*); 125 } > trash 126 .dynamic : { 127 *(.dynamic); *(.dynamic.*); 128 } > trash 129} 130