View Issue Details

IDProjectCategoryView StatusLast Update
0032251FPCInstallerpublic2017-12-14 18:04
ReporterMattias GaertnerAssigned ToPierre Muller 
PrioritynormalSeverityminorReproducibilityalways
Status confirmedResolutionopen 
Product Version3.0.4Product Build 
Target VersionFixed in Version 
Summary0032251: FPC RPM 3.0.4RC1 package for x86_64 fails to link on Fedora Core 21
DescriptionLinking fails with
/usr/bin/ld: /usr/lib64/fpc/3.0.4/units/x86_64-linux/rtl/prt0.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
test.pas(3,1) Error: Error while linking

Steps To ReproduceInstall FPC
ftp://freepascal.stack.nl/pub/mirrors/fpc/beta/3.0.4-rc1/fpc-3.0.4-0.rc1.x86_64.rpm
on Fedora Core 21.

When compiling a program, even the simplest "begin writeln; end.", I get the following:

Free Pascal Compiler version 3.0.4rc1 [2017/07/02] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test.pas
Linking test
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld: /usr/lib64/fpc/3.0.4/units/x86_64-linux/rtl/prt0.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
test.pas(3,1) Error: Error while linking
test.pas(3,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode

GNU ld version 2.24

Notes:
- The i386 rpm works on the 32bit version of Fedora Core 21.
- The previous rpm FPC 3.0.2 works without problem.
- Building a FPC 3.0.4RC1 from svn works too and can link without error.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId0
FPCTarget
Attached Files

Activities

Pierre Muller

2017-08-09 01:00

developer   ~0102120

There is a small error in the link, correct address is:
ftp://freepascal.stack.nl/pub/mirrors/fpc/beta/3.0.4-rc1/x86_64-linux/fpc-3.0.4-0.rc1.x86_64.rpm

I finally managed to extract the rpm,
and indeed readelf -r reports unknown relocation type 0x2a...

No idea what is causing this.

This is not RPM specific,
the tarball has the same file, with the same error!

Pierre Muller

muller@gcc20:~/pas/test/test304rc1$ readelf -r usr/lib64/fpc/3.0.4/units/x86_64-linux/rtl/prt0.o

Relocation section '.rela.text' at offset 0x370 contains 8 entries:
  Offset Info Type Sym. Value Sym. Name + Addend
000000000003 00080000002a unrecognized: 2a 0000000000000008 __dl_fini - 4
000000000010 000a0000002a unrecognized: 2a 0000000000000008 operatingsystem_parame - 4
00000000001a 000b0000002a unrecognized: 2a 0000000000000008 operatingsystem_parame - 4
00000000002f 000c0000002a unrecognized: 2a 0000000000000008 operatingsystem_parame - 4
00000000003d 000d0000002a unrecognized: 2a 0000000000000008 __stkptr - 4
000000000048 000e00000002 R_X86_64_PC32 0000000000000000 PASCALMAIN - 4
000000000051 00080000002a unrecognized: 2a 0000000000000008 __dl_fini - 4
000000000062 00100000002a unrecognized: 2a 0000000000000000 operatingsystem_result - 4

Bart Broersma

2017-08-09 18:53

reporter   ~0102123

FWIW:

I installed 3.0.4RC1 from tarball on Mint 18 64-bit:

bart@simenon /usr/local/lib/fpc/3.0.4/units/x86_64-linux/rtl $ readelf -r prt0.o

Relocation section '.rela.text' at offset 0x370 contains 8 entries:
  Offset Info Type Sym. Value Sym. Name + Addend
000000000003 00080000002a R_X86_64_REX_GOTP 0000000000000008 __dl_fini - 4
000000000010 000a0000002a R_X86_64_REX_GOTP 0000000000000008 operatingsystem_parame - 4
00000000001a 000b0000002a R_X86_64_REX_GOTP 0000000000000008 operatingsystem_parame - 4
00000000002f 000c0000002a R_X86_64_REX_GOTP 0000000000000008 operatingsystem_parame - 4
00000000003d 000d0000002a R_X86_64_REX_GOTP 0000000000000008 __stkptr - 4
000000000048 000e00000002 R_X86_64_PC32 0000000000000000 PASCALMAIN - 4
000000000051 00080000002a R_X86_64_REX_GOTP 0000000000000008 __dl_fini - 4
000000000062 00100000002a R_X86_64_REX_GOTP 0000000000000000 operatingsystem_result - 4

Pierre Muller

2017-08-10 07:11

developer   ~0102126

OK, thanks Bart!

  this means that it is GNU assembler version related:
After a search in different binutils release sources, it apears that
R_X86_64_REX_GOTPCRELX was introduced in GNU binutils version 2.26!

muller@gcc20:~/pas/fpc-3.0.4/lib/fpc/3.0.4/units/x86_64-linux/rtl$ readelf --version
GNU readelf (GNU Binutils for Debian) 2.22
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
muller@gcc20:~/pas/fpc-3.0.4/lib/fpc/3.0.4/units/x86_64-linux/rtl$ readelf -r prt0.o

Relocation section '.rela.text' at offset 0x370 contains 8 entries:
  Offset Info Type Sym. Value Sym. Name + Addend
000000000003 00080000002a unrecognized: 2a 0000000000000008 __dl_fini - 4
000000000010 000a0000002a unrecognized: 2a 0000000000000008 operatingsystem_parame - 4
00000000001a 000b0000002a unrecognized: 2a 0000000000000008 operatingsystem_parame - 4
00000000002f 000c0000002a unrecognized: 2a 0000000000000008 operatingsystem_parame - 4
00000000003d 000d0000002a unrecognized: 2a 0000000000000008 __stkptr - 4
000000000048 000e00000002 R_X86_64_PC32 0000000000000000 PASCALMAIN - 4
000000000051 00080000002a unrecognized: 2a 0000000000000008 __dl_fini - 4
000000000062 00100000002a unrecognized: 2a 0000000000000000 operatingsystem_result - 4
muller@gcc20:~/pas/fpc-3.0.4/lib/fpc/3.0.4/units/x86_64-linux/rtl$ x86_64-linux-readelf --version
GNU readelf (GNU Binutils) 2.29
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
muller@gcc20:~/pas/fpc-3.0.4/lib/fpc/3.0.4/units/x86_64-linux/rtl$ x86_64-linux-readelf -r prt0.o

Relocation section '.rela.text' at offset 0x370 contains 8 entries:
  Offset Info Type Sym. Value Sym. Name + Addend
000000000003 00080000002a R_X86_64_REX_GOTP 0000000000000008 __dl_fini - 4
000000000010 000a0000002a R_X86_64_REX_GOTP 0000000000000008 operatingsystem_parame - 4
00000000001a 000b0000002a R_X86_64_REX_GOTP 0000000000000008 operatingsystem_parame - 4
00000000002f 000c0000002a R_X86_64_REX_GOTP 0000000000000008 operatingsystem_parame - 4
00000000003d 000d0000002a R_X86_64_REX_GOTP 0000000000000008 __stkptr - 4
000000000048 000e00000002 R_X86_64_PC32 0000000000000000 PASCALMAIN - 4
000000000051 00080000002a R_X86_64_REX_GOTP 0000000000000008 __dl_fini - 4
000000000062 00100000002a R_X86_64_REX_GOTP 0000000000000000 operatingsystem_result - 4

So this means that the current RC1 mandates
a GNU binutils 2.26 or newer...

Pierre

Thaddy de Koning

2017-08-10 10:01

reporter   ~0102127

Last edited: 2017-08-10 10:02

View 2 revisions

But that was already documented.... It is actually http://wiki.freepascal.org/User_Changes_Trunk subject GNU Binutils 2.19.1 or later are required by default.
I have no explanation for 22 vs 19, though.

Pierre Muller

2017-08-10 10:11

developer   ~0102128

Hi Thaddy,

  I must disagree witrh you here:
the requirement for 2.19.1 is for i386_android target,
and 2.26 is from January 2016!

  I did not find this requirement, and I don't even know
if the core team was aware of this before!

  I syspect that we did not realize that the introduction
of this new relocation makes an incompatibility of our
release candidate with systems using older GNU binutils version.


Pierre

Pierre Muller

2017-08-10 10:15

developer   ~0102129

On GCC compile farm machine gcc20
with GNU binutils 2.22, I get this:

muller@gcc20:~/pas/release_3_0_4_rc1/fpcsrc/rtl/units/x86_64-linux$ readelf -r prt0.o

Relocation section '.rela.text' at offset 0x660 contains 11 entries:
  Offset Info Type Sym. Value Sym. Name + Addend
000000000003 000800000009 R_X86_64_GOTPCREL 0000000000000008 __dl_fini - 4
000000000013 000a00000009 R_X86_64_GOTPCREL 0000000000000008 operatingsystem_parame - 4
00000000001d 000b00000009 R_X86_64_GOTPCREL 0000000000000008 operatingsystem_parame - 4
000000000032 000c00000009 R_X86_64_GOTPCREL 0000000000000008 operatingsystem_parame - 4
000000000040 000d00000009 R_X86_64_GOTPCREL 0000000000000008 __stkptr - 4
00000000004b 000e00000002 R_X86_64_PC32 0000000000000000 PASCALMAIN - 4
000000000057 000800000009 R_X86_64_GOTPCREL 0000000000000008 __dl_fini - 4
000000000068 001000000009 R_X86_64_GOTPCREL 0000000000000000 operatingsystem_result - 4
00000000000b 000900000002 R_X86_64_PC32 000000000000000f _start - 4
000000000050 000f00000002 R_X86_64_PC32 0000000000000054 _haltproc - 4
000000000077 000f00000002 R_X86_64_PC32 0000000000000054 _haltproc - 4
m

I suspect that R_X86_64_REX_GOTPCRELX relocation is only
useful if your executable does not fit into 2Gb ...

Marco van de Voort

2017-08-13 01:08

manager   ~0102150

Anything before fedora 25 is out of support ?

https://en.wikipedia.org/wiki/Fedora_(operating_system)

Mattias Gaertner

2017-08-13 09:15

manager   ~0102152

True.
Does it work on other old rpm distros, like RHEL 5 and CentOS 6?

Marco van de Voort

2017-08-13 22:12

manager   ~0102160

Last edited: 2017-08-13 22:13

View 2 revisions

CentOS 6 is in maintenance part of the support cycle, and only critical security bugs will be fixed, iow it is not a target for new targets/versions. (though one could argue a fixes release is an update rather than a new version, IMHO that is a stretch unless specific security issues are named)

(see
https://wiki.centos.org/About/Product#fndef-a91b3c0c287c782f9af063daff9e64b566d648c7-1
)

More importantly, if one /builds/ the RPM on centos6, does it work then?

Mattias Gaertner

2017-12-13 12:29

manager   ~0104672

The bug affects the current CentOS 7 too. It has ld 2.25.

Pierre Muller

2017-12-13 13:29

developer   ~0104673

Could you test this file:
ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/x86_64-linux/x86_64-linux-prt0-pre2.26-binutils.tar.gz

Simply extract it at the base 3.0.4 installation directory,
it contains the 4 files that are directly compiled using GNU assembler,
but the version from the general tar installer, which was generated on
a system with an old GNU binutils version.

Pierre


muller@gcc67:~/pas/fpc-3.0.4$ tar -tvzf x86_64-linux-prt0-pre2.26-binutils.tar.gz
-rw-r--r-- muller/muller 2224 2017-10-03 13:56 lib/fpc/3.0.4/units/x86_64-linux/rtl/cprt0.o
-rw-r--r-- muller/muller 1880 2017-10-03 13:56 lib/fpc/3.0.4/units/x86_64-linux/rtl/dllprt0.o
-rw-r--r-- muller/muller 2504 2017-10-03 13:56 lib/fpc/3.0.4/units/x86_64-linux/rtl/gprt0.o
-rw-r--r-- muller/muller 1896 2017-10-03 13:56 lib/fpc/3.0.4/units/x86_64-linux/rtl/prt0.o

Mattias Gaertner

2017-12-14 17:26

manager   ~0104713

Replacing the four files works, but gives linker warnings:
crtbeginS.o not found, this will probably cause a linking failure
crtendS.o not found, this will probably cause a linking failure

Bart Broersma

2017-12-14 18:04

reporter   ~0104714

> crtbeginS.o not found, this will probably cause a linking failure
> crtendS.o not found, this will probably cause a linking failure

Had this on an old linux system.
Resolved it like this:

gcc --print-file-name crtbegin.o

That gave:
/usr/lib/gcc/i686-redhat-linux/4.7.2/crtbegin.o

Added this path (/usr/lib/gcc/i686-redhat-linux/4.7.2/) in /etc/fpc.cfg
to the library path (-Fl ) section

Issue History

Date Modified Username Field Change
2017-08-08 22:16 Mattias Gaertner New Issue
2017-08-09 01:00 Pierre Muller Note Added: 0102120
2017-08-09 01:00 Pierre Muller Assigned To => Pierre Muller
2017-08-09 01:00 Pierre Muller Status new => confirmed
2017-08-09 18:53 Bart Broersma Note Added: 0102123
2017-08-10 07:11 Pierre Muller Note Added: 0102126
2017-08-10 10:01 Thaddy de Koning Note Added: 0102127
2017-08-10 10:02 Thaddy de Koning Note Edited: 0102127 View Revisions
2017-08-10 10:11 Pierre Muller Note Added: 0102128
2017-08-10 10:15 Pierre Muller Note Added: 0102129
2017-08-13 01:08 Marco van de Voort Note Added: 0102150
2017-08-13 09:15 Mattias Gaertner Note Added: 0102152
2017-08-13 22:12 Marco van de Voort Note Added: 0102160
2017-08-13 22:13 Marco van de Voort Note Edited: 0102160 View Revisions
2017-12-13 12:29 Mattias Gaertner Note Added: 0104672
2017-12-13 13:29 Pierre Muller Note Added: 0104673
2017-12-14 17:26 Mattias Gaertner Note Added: 0104713
2017-12-14 18:04 Bart Broersma Note Added: 0104714