I am trying to get a shared object to build under GCC 2.95 on Solaris 2.7
for Sparc, but text strings in a static structure are not being relocated...
I had the same problem under egcs 1.1.2...
basicly when I compile the module (showing one .c file and the linking):
gcc -fPIC -DLDAP_REFERRALS -I/nfs_tools/src/ldap/include -g -O2 -pipe -I/nfs_tools/install/Python-1.5.2/include/python1.5 -I/nfs_tools/install/Python-1.5.2/include/python1.5 -DHAVE_CONFIG_H -c ./functions.c
gcc -shared LDAPObject.o common.o constants.o errors.o functions.o ldapmodule.o message.o version.o -L/nfs_tools/src/ldap/libraries -lldap -llber -lsocket -lnsl -o ldapmodule.so
in functions.c, it has a structure of:
static PyMethodDef methods[] = {
{ "open", (PyCFunction)l_ldap_open, METH_VARARGS,
doc_open },
{ "dn2ufn", (PyCFunction)l_ldap_dn2ufn, METH_VARARGS,
doc_dn2ufn },
{ "explode_dn", (PyCFunction)l_ldap_explode_dn, METH_VARARGS,
doc_explode_dn },
{ "is_ldap_url", (PyCFunction)l_ldap_is_ldap_url, METH_VARARGS,
doc_is_ldap_url },
{ NULL, NULL }
};
now when the module gets loaded, none of the pointers in this structure
get relocated:
(gdb) frame 3
#3 0xff149a0c in LDAPadd_methods (d=0xd4918, methods=0xff16eaf8)
at ./common.c:18
18 PyDict_SetItemString( d, meth->ml_name, f );
(gdb) print *methods
$1 = {ml_name = 0x158e68 <Address 0x158e68 out of bounds>, ml_meth = 0x14b5a8,
ml_flags = 1, ml_doc = 0x16e770 <Address 0x16e770 out of bounds>}
as you can see, the methods structure is actually located at 0xff16eaf8,
and considering that the ml_name and friends are part of the same file,
they shouldn't be at such a low address....
the above gdb was obtains from a core dump when trying to load the module..
if you haven't recognized this already, it's comiling a module for python
that can be loading/imported at run time, but because of this problem, I
haven't been able to get this to work...
does anybody have any idea on how to fix this problem?? it seems strange
that it would relocate some of the symbols but not all of them, considering
that everything is compiled for pic...
any help would be greatly apreciated...
--
John-Mark Gurney
Eugene 4J School District