1/* 2 * Copyright (c) 2006 SigmaTel, Inc. 3 * 4 * elftosb boot description file that creates some complicated situations for 5 * the loader to handle. of course this is also a good test for elftosb itself. 6 */ 7 8/* testing C style comments */ 9// testing C++ style comments 10# testing shell style comments 11 12constants { 13 kProgressReportsImageFlag = 0x1; 14 15 kPlayerDriveTag = 0xa0; 16 kHostlinkDriveTag = 0xb0; 17} 18 19options { 20 productVersion = "5.0.999"; 21 componentVersion = "5.0.999"; 22 23 flags = kProgressReportsImageFlag; // turn on progress reports 24 25 secinfoClear = "ignore"; 26} 27 28constants { 29 arg = 0xfeedf00d; 30 31 callArg1 = 2; 32 callArg2 = 3; 33 34 halfword = 10.h; 35 36// flag = 1; 37 38 testboolexpr = 1 > 0; 39 40 mainSizeIsDefined = defined(mainSize); 41} 42 43sources { 44 elffile = extern(0) (toolset="ghs"); 45 binfile1 = extern(1); 46 binfile2 = extern(2); 47 foofile = "file.dat"; 48 anotherfile = "another.dat"; 49 srecfile = "test_files/sd_player_gcc.srec"; 50} 51 52options { 53 driveTag = kPlayerDriveTag; 54 55 some_option = defined(testboolexpr); 56} 57 58constants { 59 printMessageAddr = elffile:printMessage; 60 printMessageSize = sizeof(elffile:printMessage); 61 62 // create const with address of main() in elffile 63 mainAddr = elffile:main; 64 65 mainSize = sizeof(elffile:main); 66 67 halfwordSize = sizeof(halfword); 68 69 elf_startAddr = elffile:_start; 70 71// poop = exists(nonexistantfile); 72 73 binfile1size = sizeof(binfile1); 74} 75 76/* 77 * test s-record support 78 */ 79section (0) 80{ 81 load dcd {{ 00 11 22 33 }} > 0; 82 load srecfile; 83 call srecfile; 84} 85 86section(1; coalesce=true) { 87 88 info "welcome to section 1!"; 89 info "elffile path = $(elffile)"; 90 info "mainSizeIsDefined = $(d:mainSizeIsDefined)"; 91 info "printMessage = $(x:printMessageAddr)"; 92 93 info "size of binfile1 = $(binfile1size)"; 94 95 // can use symbol refs inside bool expressions in an if stmt 96 if elffile:main == 0 97 { 98 warning "$(elffile) does not seem to have a main() function"; 99 } 100 else 101 { 102 info "address of main() of $(elffile) is $(x:mainAddr)"; 103 } 104 105 if defined(flag) && flag != 0 106 { 107 load 0x1234.h > 0..10K; 108 } 109 else 110 { 111 // print message using both decimal and hex formatting 112 warning "loading only halfword = $(d:halfword) [$(x:halfword)]!"; 113 load halfword > 0..1K; 114 } 115 116 info "size of main() in $(elffile) is $(mainSize)"; 117 info "printMessage() size is $(printMessageSize)"; 118 info "size of halfword = $(halfwordSize)"; 119 120 load 0xff.b > 32K..32K + sizeof(elffile:printMessage); 121 122 from elffile { 123 load {{ 00 01 02 03 04 }} > 1K; 124 125 // load all sections except .mytext 126 load ~$.mytext; 127 128 // figure out where to go from here 129 call :maybeSwitchSections(callArg1); 130 131 // print msg and loop 132 load "hi from section 1" > :szMsg; 133 call :printMessage(0); 134 135 jump :hello(0); 136 } 137 138 // erase a function in memory 139 load 0.w > (elffile:endOfLine)..(elffile:endOfLine + sizeof(elffile:endOfLine)); 140} 141 142section(2; alignment=64K) { 143 // cause an error if testConst has not been set 144 if !defined(testConst) 145 { 146 error "testConst is not defined!"; 147 } 148 149 from elffile { 150 load "in section 2" > :szMsg; 151 call :printMessage(); 152 } 153 154 // load the contents of binfile1 into the upper 128KB of ocram 155 load binfile1 > 128K..192K; 156 157 from elffile { 158 load "loaded binfile1" > :szMsg; 159 call :printMessage(0); 160 161 call :maybeSwitchSections(callArg2); 162 163 jump :endOfLine(2); 164 } 165} 166 167// non-bootable section between two bootable sections 168section(0xbeef; alignment=32K, cleartext=false) <= binfile2; 169 170section(3; alignment=8K) { 171 // load our special section 172 load $.mytext from elffile; 173 call elffile:countToN(5); 174 175 if (exists(foofile) && exists(anotherfile)) 176 { 177 // a trainload of beef! 178 load 0xbeef.h > 128K..192K; 179 } 180 else if (exists(elffile) && callArg1 == 2) 181 { 182 // aaaaaaah! 183 load 0x12345678.w > 128K..192K; 184 } 185 else 186 { 187 from elffile 188 { 189 // aaaaaaah! 190 load 0xaaaa.h > 128K..192K; 191 load $.text; 192 load 0xbbbb.h > 128K..192K; 193 } 194 } 195 196 from elffile { 197 load "hold on now, in section 3" > :szMsg; 198 call :printMessage(0); 199 200 jump :endOfLine(3); 201 } 202 203 from elffile { 204 load elffile; 205 load elffile > .; 206 load elffile[ $.bss ] > elffile:countToN; 207// load [ $.bss ] > (elffile:countToN)..(elffile:countToN + sizeof(elffile:countToN)); 208 call elffile; 209 call elffile(1); 210 } 211 212 info "address of _start in $(elffile) is $(elf_startAddr)"; 213} 214 215section ('four'; alignment=8K, sectionFlags=0x1000) <= binfile1; 216 217section ('five'; alignment=8K, cleartext=1, sectionFlags=0x1000) <= binfile1; 218 219/* 220 * create a data section out of some sections of an elf file 221 */ 222section (1234) <= ~$.bss, ~$.data from elffile; 223section (4321) <= elffile [ $* ]; 224section (1111) <= elffile; 225 226/* test data sections from various data sources */ 227section (0xaa) <= 0x12345678.w; 228section (0xbb) <= "hi there! this is a data section."; 229section (0xcc) <= {{ aa55aa55aa55aa55aa55aa55aa55aa55 }}; 230 231 232section (2345) 233{ 234 load elffile[ $*.text*, ~$.sdram* ]; 235} 236 237 238section ('six_') 239{ 240 // load a blob at address 0x1000 241 load {{ 242 00 0a 07 b0 bb ff 03 78 243 00 0a 07 b0 bb ff 03 78 244 00 0a 07 b0 bb ff 03 78 245 00 0a 07 b0 bb ff 03 78 246 00 0a 07 b0 bb ff 03 78 247 }} > 0x1000; 248} 249 250section ('bad_') 251{ 252 // uncomment to test better error reporting for files that failed to open 253// load foofile; 254} 255 256//section (2345) <= {{ 00 11 22 33 44 55 }}; 257 258 259 260 261