Linux x64 linking error (FPC_ABSMASK_SINGLE)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Linux x64 linking error (FPC_ABSMASK_SINGLE)

Виктор Матузенко
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 (Виктор Матузенко)

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Linux x64 linking error (FPC_ABSMASK_SINGLE)

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Linux x64 linking error (FPC_ABSMASK_SINGLE)

Jonas Maebe-2
In reply to this post by Виктор Матузенко

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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Linux x64 linking error (FPC_ABSMASK_SINGLE)

Виктор Матузенко
Thank you for the explanations! -fPIC solves my problem.

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

>
> 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  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal