Sunday, September 08, 2013

LiveSD card nearly ready

I've been working on getting a bootable SD card working for the last couple of weeks, and it is getting close to release.

It is based on Linux From Scratch, specifically the automated version jhalfs-2.3.2, and the latest LFS book on SVN.  LFS is a book describing how to generate a minimal Linux distribution from source code and goes through several stages to avoid dependencies on the build operating system (in my case Knoppix 7.2).  JHALFS automates that process by reading the book for you and generating scripts and makefiles to perform all of the work described in the book.  It's a really good idea to go through the book manually a couple of times first, if you want to learn what it's all about, but eventually you'll want to automate it as I did in the construct-live-cd part of the ROLF repository on sourceforge.  JHALFS, however, moves with the times (my scripts generate linux-, but LFS is on linux-3.10.10).

Moving with the times is not without its own problems, however.

Somewhere between binutils-2.22/linux- and binutils-2.23.2/linux-3.10.10, there seems to have come a change which meant that all my ROLF programs would fail on startup.  More strangely still, ldd and gdb would report the problem as follows:

ldd: exited with unknown exit code (139)
(gdb) start
Temporary breakpoint 1 at 0x8000383
Starting program: /tmp/x/x1

Program received signal SIGSEGV, Segmentation fault.
0xb7fdfa24 in dl_main () from /lib/
I had the same problem many years ago, but this time, I'm writing it down!

The culprit is a link option I have to use to avoid the loader putting native code or data where RISC OS programs expect to have ROM or RAM mapped:
I have never come across an option that tells the linker to avoid a certain area of memory for the program to use, so this is the best I could come up with.  ".interp" seemed to be the first section located in memory, and all other sections would follow on, so, initially, I tried
...with the result that I got similar problems as above.  Adding 256 bytes to the address, however made it go away and for a long time, I was happy....

It turns out that adding another 256 bytes makes it go away again.  If anyone can tell me why this happens, I'd be very interested to know!