Linker trouble - position independent code(??)

Volker Wysk post at volker-wysk.de
Thu Sep 26 01:38:48 UTC 2019


Hi!

All of a sudden, I can't link my programs any longer. This affects all
my programs, which I build with a shared Makefile. But I haven't
changed the Makefile...

I get messages like this (indentation by me):

cc build/sicherung.o build/Hsskripte.o build/Sicherung.o 
   build/SicherungAktionen.o build/Text.o build/Wahl.o build/Zeit.o  
   build/hssk.o   -o build/sicherung
/usr/bin/ld: build/sicherung.o: relocation R_X86_64_32S against
   undefined symbol `stg_upd_frame_info' can not be used when making a 
   PIE object; recompile with -fPIC
/usr/bin/ld: build/Hsskripte.o: relocation R_X86_64_32S against
   `.text' can not be used when making a PIE object; recompile with 
   -fPIC
... more like this ...
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: 
In function `_start':
(.text+0x20): undefined reference to `main'
/usr/bin/ld: final link failed: Invalid operation
collect2: error: ld returned 1 exit status

I've attached the complete build messages.

I've never dealt with position independent code. I've tried that "-
fPIC" switch, but this produces lots of new error messages.

Any idea of what's wrong?

Bye,
V.W.
-------------- next part --------------
-*- mode: compilation; default-directory: "~/src/hsskripte/" -*-
Compilation started at Thu Sep 26 03:33:34

LANG=C make -k build/sicherung
ghc -o build/Hsskripte.o -c  -ibuild -I. -isrc -XUndecidableInstances -fno-warn-deprecations -XScopedTypeVariables -XDeriveDataTypeable -XTypeSynonymInstances -XFlexibleInstances -XStandaloneDeriving -package regex-compat -package edit-distance -fno-warn-typed-holes -package containers -package pretty -package hsshellscript -package text -package bytestring -package time -package rfc5051 -static  -odir build -hidir build src/Hsskripte.hs
ghc -o build/Zeit.o -c  -ibuild -I. -isrc -XUndecidableInstances -fno-warn-deprecations -XScopedTypeVariables -XDeriveDataTypeable -XTypeSynonymInstances -XFlexibleInstances -XStandaloneDeriving -package regex-compat -package edit-distance -fno-warn-typed-holes -package containers -package pretty -package hsshellscript -package text -package bytestring -package time -package rfc5051 -static  -odir build -hidir build src/Zeit.hs
ghc -o build/Sicherung.o -c  -ibuild -I. -isrc -XUndecidableInstances -fno-warn-deprecations -XScopedTypeVariables -XDeriveDataTypeable -XTypeSynonymInstances -XFlexibleInstances -XStandaloneDeriving -package regex-compat -package edit-distance -fno-warn-typed-holes -package containers -package pretty -package hsshellscript -package text -package bytestring -package time -package rfc5051 -static  -odir build -hidir build src/Sicherung.hs
ghc -o build/Text.o -c  -ibuild -I. -isrc -XUndecidableInstances -fno-warn-deprecations -XScopedTypeVariables -XDeriveDataTypeable -XTypeSynonymInstances -XFlexibleInstances -XStandaloneDeriving -package regex-compat -package edit-distance -fno-warn-typed-holes -package containers -package pretty -package hsshellscript -package text -package bytestring -package time -package rfc5051 -static  -odir build -hidir build src/Text.hs
ghc -o build/Wahl.o -c  -ibuild -I. -isrc -XUndecidableInstances -fno-warn-deprecations -XScopedTypeVariables -XDeriveDataTypeable -XTypeSynonymInstances -XFlexibleInstances -XStandaloneDeriving -package regex-compat -package edit-distance -fno-warn-typed-holes -package containers -package pretty -package hsshellscript -package text -package bytestring -package time -package rfc5051 -static  -odir build -hidir build src/Wahl.hs
ghc -o build/SicherungAktionen.o -c  -ibuild -I. -isrc -XUndecidableInstances -fno-warn-deprecations -XScopedTypeVariables -XDeriveDataTypeable -XTypeSynonymInstances -XFlexibleInstances -XStandaloneDeriving -package regex-compat -package edit-distance -fno-warn-typed-holes -package containers -package pretty -package hsshellscript -package text -package bytestring -package time -package rfc5051 -static  -odir build -hidir build src/SicherungAktionen.hs
ghc -o build/sicherung.o -c  -ibuild -I. -isrc -XUndecidableInstances -fno-warn-deprecations -XScopedTypeVariables -XDeriveDataTypeable -XTypeSynonymInstances -XFlexibleInstances -XStandaloneDeriving -package regex-compat -package edit-distance -fno-warn-typed-holes -package containers -package pretty -package hsshellscript -package text -package bytestring -package time -package rfc5051 -static  -odir build -hidir build src/sicherung.hs
gcc -o build/hssk.o -c  -O2 src/hssk.c -fPIC
src/hssk.c:16:38: warning: 'struct statfs' declared inside parameter list will not be visible outside of this definition or declaration
 int statfs1(const char *path, struct statfs *buf)
                                      ^~~~~~
src/hssk.c: In function 'statfs1':
src/hssk.c:24:9: warning: implicit declaration of function 'statfs'; did you mean 'statfs1'? [-Wimplicit-function-declaration]
   erg = statfs(path, buf);
         ^~~~~~
         statfs1
cc   build/sicherung.o build/Hsskripte.o build/Sicherung.o build/SicherungAktionen.o build/Text.o build/Wahl.o build/Zeit.o build/hssk.o   -o build/sicherung
/usr/bin/ld: build/sicherung.o: relocation R_X86_64_32S against undefined symbol `stg_upd_frame_info' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: build/Hsskripte.o: relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: build/Sicherung.o: relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: build/SicherungAktionen.o: relocation R_X86_64_32S against undefined symbol `stg_bh_upd_frame_info' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: build/Text.o: relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: build/Wahl.o: relocation R_X86_64_32S against undefined symbol `stg_upd_frame_info' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: build/Zeit.o: relocation R_X86_64_32S against undefined symbol `stg_upd_frame_info' can not be used when making a PIE object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/usr/bin/ld: final link failed: Invalid operation
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'build/sicherung' failed
make: *** [build/sicherung] Error 1

Compilation exited abnormally with code 2 at Thu Sep 26 03:33:39


More information about the Glasgow-haskell-users mailing list