Sign in Join

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

Mailing lists / fpc-pascal / 2015-03

Linux x64 linking error (FPC_ABSMASK_SINGLE)

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Victor Matuzenko

Hi!

I have a (very) huge project, and compilation of a shared library inside it fails at the linking stage:

/usr/bin/ld: </long/directory/file.o>: relocation R_X86_64_32S against `FPC_ABSMASK_SINGLE' can not be used when making a shared object; recompile with -fPIC
</long/directory/file.o>: could not read symbols: Bad value

How can I fix it? Should I pass -fPIC argument (and how to do this)?

fpc was built from trunk

uname -a:
Linux larion 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux

Victor Matuzenko (Виктор Матузенко)

Reply by email

denisgolovan
How can I fix it? Should I pass -fPIC argument (and how to do this)?

AFAIK, PIC code generation is turn on by default.
Are you sure you don't have an opposite problem?
Sometimes when you have asm code written with hard-coded offsets you can get a module which can't be PIC-compiled.

See fpc -h params for _disabling_ PIC code generation.

Regards, Denis Golovan

Reply by email

Jonas Maebe
to Victor Matuzenko: Hi! I have a (very) huge project, and compilation of a shared library inside it fails at…
Victor Matuzenko wrote 9 lines
I have a (very) huge project, and compilation of a shared library inside it fails at the linking stage: /usr/bin/ld: </long/directory/file.o>: relocation R_X86_64_32S against `FPC_ABSMASK_SINGLE' can not be used when making a shared object; recompile with -fPIC </long/directory/file.o>: could not read symbols: Bad value How can I fix it? Should I pass -fPIC argument (and how to do this)?

You just pass this argument to the compiler (or, alternatively, -Cg, which means the same thing). Make sure to clean all compiled code first so that all of your units are recompiled with this option. The standard FPC units are already compiled with this option.

denisgolovan wrote
AFAIK, PIC code generation is turn on by default.

On Linux/x86-64, that is only the case for units compiled via fpcmake (such as the RTL and packages/FCL).

Show quoted text 5 lines
Are you sure you don't have an opposite problem? Sometimes when you have asm code written with hard-coded offsets you can get a module which can't be PIC-compiled. See fpc -h params for _disabling_ PIC code generation.

He gets an error from the linker stating that a dynamic library cannot contain that kind of relocation. Those relocations are created for non- PIC code. Disabling the generation of PIC code cannot solve that issue.

Jonas

Reply by email

Victor Matuzenko
to Jonas Maebe

Thank you for the explanations! -fPIC solves my problem.

02.03.2015 16:49, Jonas Maebe пишет:

Show quoted text 42 lines
On 02 Mar 2015, at 09:14, Victor Matuzenko wrote: > I have a (very) huge project, and compilation of a shared library > inside it fails at the linking stage: > > /usr/bin/ld: </long/directory/file.o>: relocation R_X86_64_32S > against `FPC_ABSMASK_SINGLE' can not be used when making a shared > object; recompile with -fPIC > </long/directory/file.o>: could not read symbols: Bad value > > How can I fix it? Should I pass -fPIC argument (and how to do this)? You just pass this argument to the compiler (or, alternatively, -Cg, which means the same thing). Make sure to clean all compiled code first so that all of your units are recompiled with this option. The standard FPC units are already compiled with this option. On 02 Mar 2015, at 14:36, denisgolovan wrote: > AFAIK, PIC code generation is turn on by default. On Linux/x86-64, that is only the case for units compiled via fpcmake (such as the RTL and packages/FCL). > Are you sure you don't have an opposite problem? > Sometimes when you have asm code written with hard-coded offsets you > can get a module which can't be PIC-compiled. > > See fpc -h params for _disabling_ PIC code generation. He gets an error from the linker stating that a dynamic library cannot contain that kind of relocation. Those relocations are created for non-PIC code. Disabling the generation of PIC code cannot solve that issue. Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Victor Matuzenko (Виктор Матузенко)

Reply by email