Subject: Compiling, -fpic, shared libraries, gdb, etc.
To: None <port-arm32@NetBSD.ORG>
From: Sergio Monesi <msergio@tin.it>
List: port-arm32
Date: 02/13/1998 12:18:28
I reinstalled RiscBSD, I got all the pieces from 1.3a rather than NetBSD 1.3
(nobody has yet managed to explain why the compiler in the comp.tgz set
doesn't work at all...).

I recompiled lesstif (and also qt, just to be sure it wasn't just a lesstif
problem) and it still doesn't work. I compiled it using -fpic and linked
using -Bshareable. There aren't any particularly interesting warnings, the
library is created, the test programs compiled but once executed they crash
with a segmentation fault.

So I decided to investigate this and loaded gdb (which seems to work very
well). Unless gdb is wrong (quite unlikely), the problem is that the value of
some static data (which gdb displays correctly) is loaded incorrectly by the
code in the shared library. I analysed only a small part of the code (near
the place where it crashes), the line looks like:

if (number_of_something + 1 > max_number_of_something) { ... }

Both number_* and max_number_* are static ints, initialised to 0. The code
should load them in r2 and r3, r2 seems to be correctly set to 0 (and then
incremented to 1) but this may be just a coincidence since the address from
which it is loaded differs from the one reported by gdb. However r3 is surely
loaded from the wrong place because it is set to something very high
(0x10XXXXXX) and obviously the code doesn't work as expected.

I suppose that all the static data is loaded incorrectly since the program
still crashes a few instructions later even if I force r3 to 0 using gdb.

So my question is: how do you managed to compile the shared libraries
distributed with RiscBSD (eg. the X stuff)? 

Is a fixed compiler available? BTW: Why is the compiler in the comp.tar.gz
set broken? Or maybe it is the linker...

Alternatively, am I doing something wrong, eg. there is a mysterious compiler
option to use? I used -fpic -msoft-float.

Since I suppose I am not the only one in this situation, could anybody please
enlighten us?

Sergio

-- 
Sergio Monesi...         \ . . . \  Cracking RC5-64 with a StrongARM RiscPC
mailto:msergio@tin.it     \ . . . \  http://www.distributed.net/
http://bounce.to/sergio/   \ . . . \  Join the Wild Wereboar Team (#1308)!