From: hank peng Date: Tue, 9 Dec 2008 11:19:33 +0800 Subject: [U-Boot] Two confusing questions about relocation of code on MPC8548CDS board Message-ID: <389deec70812081919p394bcag82b87b82db552eae@mail.gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de After code is relocated, cpu jumped from flash to RAM, I have two questions I can't understand. Any help will be appreciated greatly. 1. Because TEXT_BASE=0xfff80000 which points to flash space, after code is copied from flash to RAM and start to run from RAM, how can u-boot make sure code is place independent? For example, what if I write such code as follows: lis r0, LABEL at h ori r0, r0, LABEL at l mtlr r0 blr Here, symbol "LABEL" must be a value which also points to flash space. After "blr" is executed, we go back to flash, right? 2. Similar as question 1, if I define a global variable like this in a C file: static int my_global = 1; powerpc-linux-readelf command shows that my_global located in .data section and its symbol value also points to flash space. When running in RAM, if I want to change its value: my_global = 2; I don't know how compilor translate this C code into assembly, if it uses absolute address to locate my_global, I think writing can't be operated, so does compilor use relative address to locate my_global? But how? -- The simplest is not all best but the best is surely the simplest!