Sunday, June 10, 2007

fatal: relocation error: R_AMD64_PC32

I am developing a c simulation tool. I am invoking one of dynamic library
(my home grown library named as: randlib.so)

It has a function as

double unifrand(double, double, long*);

In my simulation application, I invoke the above function with

seed = 1236537;
ran_no = unifrnd(0.0,1.0,&seed);

I have flag below to build

cc -m64 -o dist/Debug/Sun12-Solaris-x86/simperturbation build/Debug/Sun12-Solaris-x86/estimator.o build/Debug/Sun12-Solaris-x86/spoptimze.o -R/SunStudioProjects/randlib/dist/Debug/Sun12-Solaris-x86 -R/usr/sfw/lib/64 -lm /SunStudioProjects/randlib/dist/Debug/Sun12-Solaris-x86/randlib.so


However, during runtime, I have error blow:

ld.so.1: simperturbation: fatal: relocation error: R_AMD64_PC32: file /SunStudioProjects/randlib/dist/Debug/Sun12-Solaris-x86/randlib.so: symbol unifrnd: value 0x2800112fedf does not fit


If I run list dynamic dependencies with the target simulation application binary,

ldd simperturbation
libm.so.2 => /lib/64/libm.so.2
randlib.so => /SunStudioProjects/randlib/dist/Debug/Sun12-Solaris-x86/randlib.so
libc.so.1 => /lib/64/libc.so.1


As I compiled the DLL with -Kpic flag. It works

The URL below helps.

http://blogs.sun.com/rie/entry/my_relocations_don_t_fit

No comments: