From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Holler Date: Sat, 30 Oct 2010 15:08:55 +0200 Subject: [U-Boot] arm: wrong Relocation and not cleared BSS Message-ID: <4CCC18E7.8080708@ahsoftware.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello, to give the topic a better meaning and to summarize what I think is currently happening along with some "pictures" for a better understanding: We are starting with code (c) and data (d) somewhere in the memory: ---------- |cd | ---------- The relocation in start.S should achieve this: ---------- | cd| ---------- That means code and data should be moved upwards. What currently is happening is the following: ---------- | d c | ---------- The code is moved upwards, but that code still uses the data at d. This results another problem: Some parts in the code are assuming that d is cleared (set to zero in start.S). But what start.S does it to clear the new location (z in the picture below). ---------- | d cz| ---------- Because the code (c) still uses the data (bss) in d and not in z, some hard to find errors might occur because the used data isn't set to zero as required. I have almost no knowledge about how gcc and the binutils are handling relocation, therfore I can't help much further here. What I think is part of the problem, is that -fPIC was removed. Using -pie in LDFLAGS might be used to get relocatable code, but the data will not be relocated. And I would wonder if that is possible without instructing the compiler to build stuff for relocation (-fPIC). I hope that brings some light into the problem. Regards, Alexander