fpic

Problems with static local variables with relocatable code

霸气de小男生 提交于 2019-12-12 16:16:08
问题 I am building a project which has relocatable code on bare metal. It is a Cortex M3 embedded application. I do not have a dynamic linker and have implemented all the relocations in my startup code. Mostly it is working but my local static variables appear to be incorrectly located. Their address is offset by the amount that my executable is offset in memory - ie I compile my code as if it is loaded at memory location 0 but I actually load it in memory located at 0x8000. The static local

nasm issue relocation R_X86_64_PC32 shared library

拟墨画扇 提交于 2019-12-12 02:24:19
问题 I am using nasm 64 to compile .S to .o and then create a shared library with gcc like this: nasm -f elf64 source/strlen.S nasm -f elf64 source/strchr.S nasm -f elf64 source/memset.S nasm -f elf64 source/strcspn.S nasm -f elf64 source/rindex.S nasm -f elf64 source/strpbrk.S nasm -f elf64 source/strcmp.S nasm -f elf64 source/strncmp.S nasm -f elf64 source/strcasecmp.S /usr/bin/gcc -shared ./source/strlen.o ./source/strchr.o ./source/memset.o ./source/strcspn.o ./source/rindex.o ./source/strpbrk

How to configure CMake to build a library with -fPIC? [duplicate]

折月煮酒 提交于 2019-12-10 17:22:25
问题 This question already has an answer here : How to link against PIC version of a library's dependency in CMake? (1 answer) Closed 3 years ago . I'm trying to create a static library with -fPIC specified. add_library(cpp-netlib_pic STATIC ${SRCS}) set_property(TARGET cpp-netlib_pic PROPERTY POSITION_INDEPENDENT_CODE) This doesn't work. The library ( cpp-netlib_pic ) is built without the -fPIC flags. Other targets which link against cpp-netlib_pic do however, have -fPIC added to their compiler

fPIC compiling error: no such file or directory

扶醉桌前 提交于 2019-12-10 11:39:28
问题 I am running elementary OS 64-bit and have the source code for the following project on github: https://github.com/pellegre/libcrafter I however get the following error when trying to configure it via the ./configure command: After that I check the config.log file: Anyone know why this could be? I've compiled with fPIC before without hassle. Example from the configure file in the folder: Update for Peter in comments: 来源: https://stackoverflow.com/questions/27107913/fpic-compiling-error-no

Detect 32-bit x86 processor in CMakeList.txt?

╄→гoц情女王★ 提交于 2019-12-08 13:50:26
问题 We are catching errors in our CMake makefiles due to lack of -fPIC . Her's one from a ci20 MIPS dev-board: ... [ 92%] Built target cryptopp-object Scanning dependencies of target cryptopp-shared Scanning dependencies of target cryptopp-static Linking CXX static library libcryptopp.a Linking CXX shared library libcryptopp.so /usr/bin/ld: CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o: relocation R_MIPS_HI16 against `a local symbol' can not be used when making a shared object; recompile with

What, if any, are the implications of compiling objects with gcc -fPIC flag if they get used in executables?

一曲冷凌霜 提交于 2019-12-06 20:14:32
问题 I am putting together a makefile for a project i am working on. I have an executable and a shared library in the project. Both use some of the same source files which get compiled separately into object files. To be able to use these objects in the shared library I need to use the -fPIC (position independent code) flag in gcc. Are there any implications of compiling objects with -fPIC that get used in a executable? 回答1: Compiling position-independent code when not necessary is a performance

Why does including -fPIC to compile a static library cause a segmentation fault at run time?

不想你离开。 提交于 2019-12-06 04:19:27
I'm compiling C++ static library with g++ and using the -fPIC option. I must use the -fPIC option because eventually this library will be linked with other static libraries to form a dynamic library. When I test the static library locally, it works completely fine when I don't include the -fPIC option. But as soon as I compile the library with -fPIC, I receive a segmentation fault error at run-time when calling one of the functions. What reasons could including -fPIC to compile a static library cause a segementation fault at run-time? A dynamic library is supposed to be loaded at run-time and

What, if any, are the implications of compiling objects with gcc -fPIC flag if they get used in executables?

爷,独闯天下 提交于 2019-12-05 00:19:28
I am putting together a makefile for a project i am working on. I have an executable and a shared library in the project. Both use some of the same source files which get compiled separately into object files. To be able to use these objects in the shared library I need to use the -fPIC (position independent code) flag in gcc. Are there any implications of compiling objects with -fPIC that get used in a executable? Compiling position-independent code when not necessary is a performance drag on some platforms (most notably, the register-starved x86 architecture, because PIC takes away a

Compiling ghc with -fPIC support

99封情书 提交于 2019-12-03 20:37:04
问题 I'm trying to install GHC with -fPIC support in Fedora. I've grabbed a source tarball since it seems no binary one has this. In Build.mk i've changed the quick build type to ifeq "$(BuildFlavour)" "quick" SRC_HC_OPTS = -H64m -O0 -fasm -fPIC GhcStage1HcOpts = -O -fasm -fPIC GhcStage2HcOpts = -O0 -fasm -fPIC GhcLibHcOpts = -O -fasm -fPIC SplitObjs = NO HADDOCK_DOCS = NO BUILD_DOCBOOK_HTML = NO BUILD_DOCBOOK_PS = NO BUILD_DOCBOOK_PDF = NO endif unfortunately, when compiling i still get the ld

linker error “relocation R_X86_64_PC32 against undefined symbol” despite compilation with -fPIC

妖精的绣舞 提交于 2019-12-01 17:27:26
问题 I'm compiling a c++ program using the command line g++ -c prog.cc -std=c++11 -march=native -fPIC -fopenmp and then try to make a shared object via g++ prog.o -shared -fopenmp -o lib/libprog.so This has always worked. But today I get: /usr/bin/ld: prog.o: relocation R_X86_64_PC32 against undefined symbol `_ZTVN12_GLOBAL__N_111handle_baseE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status The