Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-11

Problems with "relocation errors"

7 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Krzysztof

Hi,

I often write shared library (DLL and SO). With DLL I have no serious problems, but with SO I often have "relocation R_X86_64_32S" error. If I use lazarus standard packages (LCL, etc.) then is ok, but If I try to use some external components (for example lNET, RichMemo) then I get this error. lNet example:

/lnet-svn/trunk/lazaruspackage/lib/x86_64-linux/lhttp.o: relocation R_X86_64_32S against `TC_LHTTP_HTTPSTATUSCODES' can not be used when making a shared object; recompile with -fPIC
/lnet-svn/trunk/lazaruspackage/lib/x86_64-linux/lhttp.o: could not read symbols: Bad value

I build project with -fPIC switch and reinstall lNet package with -fPIC switch and rebuild lazarus with -fPIC switch but nothing helped. This error occurs in different files, depending on where I put the -fPIC switch (lnet package installer, project options or lazarus build editor)

I'm wondering, what is the reason of this error. Must I report it to author? I always create lazarus and fpc deb packages from SVN using create_fpc_deb.sh and create_lazarus_deb.sh scripts. Maybe I need some extra switch?

Problems are on Ubuntu 10.10 64bit, GNOME GTK2.

Regards

Sven Barth
to leledumbo
leledumbo wrote
AFAIK PE DLLs are always relocatable while it's not true for ELF SOs. So, whenever you need to create it, always pass -fPIC to ALL used units and their dependencies.

PE images themselves aren't relocatable. All addresses are relative to the defined base address. The loader must manually recalculate the addresses if the binary can't be loaded at the base address.

See also here: http://en.wikipedia.org/wiki/Portable_Executable#Relocations

Regards,
Sven

Marco van de Voort
to Sven Barth: PE images themselves aren't relocatable. All addresses are relative to the defined base…

In our previous episode, Sven Barth said:

Show quoted text 10 lines
> > AFAIK PE DLLs are always relocatable while it's not true for ELF SOs. So, > whenever you need to create it, always pass -fPIC to ALL used units and > their dependencies. PE images themselves aren't relocatable. All addresses are relative to the defined base address. The loader must manually recalculate the addresses if the binary can't be loaded at the base address. See also here: http://en.wikipedia.org/wiki/Portable_Executable#Relocations

They _are_ relocatable (it contains structures to relocate), but _not_ position independant (you must relocate if load address changes)

Sven Barth
to Marco van de Voort
Marco van de Voort wrote 14 lines
In our previous episode, Sven Barth said: >> >> AFAIK PE DLLs are always relocatable while it's not true for ELF SOs. So, >> whenever you need to create it, always pass -fPIC to ALL used units and >> their dependencies. > > PE images themselves aren't relocatable. All addresses are relative to > the defined base address. The loader must manually recalculate the > addresses if the binary can't be loaded at the base address. > > See also here: http://en.wikipedia.org/wiki/Portable_Executable#Relocations They _are_ relocatable (it contains structures to relocate), but _not_ position independant (you must relocate if load address changes)

I threw two things into one pot... I'm sorry :)

Regards,
Sven

Jonas Maebe
to Krzysztof: I often write shared library (DLL and SO). With DLL I have no serious problems, but with…
Krzysztof wrote
I build project with -fPIC switch and reinstall lNet package with -fPIC switch and rebuild lazarus with -fPIC switch but nothing helped. This error occurs in different files, depending on where I put the -fPIC switch (lnet package installer, project options or lazarus build editor) I'm wondering, what is the reason of this error.

It suggests a compiler bug. It would be nice to have a simple test case that reproduces the problem instead of lnet or another package though.

Jonas