fpic

How to recompile with -fPIC

廉价感情. 提交于 2019-11-26 06:35:47
问题 I was trying to reinstall my ffmpeg, following this guide, on my ARM Ubuntu machine. Unfortunately, when I compile a program which uses this lib I get the following failure: /usr/bin/ld: /usr/local/lib/libavcodec.a(amrnbdec.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol\' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libavcodec.a: could not read symbols: Bad value collect2: ld returned 1 exit status Now I would like to recompile it with -fPIC like

How can I tell, with something like objdump, if an object file has been built with -fPIC?

做~自己de王妃 提交于 2019-11-26 06:06:14
问题 How can I tell, with something like objdump , if an object file has been built with -fPIC ? 回答1: The answer depends on the platform. On most platforms, if output from readelf --relocs foo.o | egrep '(GOT|PLT|JU?MP_SLOT)' is empty, then either foo.o was not compiled with -fPIC , or foo.o doesn't contain any code where -fPIC matters. 回答2: I just had to do this on a PowerPC target to find which shared object (.so) was being built without -fPIC. What I did was run readelf -d libMyLib1.so and look

GCC -fPIC option

℡╲_俬逩灬. 提交于 2019-11-26 02:15:42
问题 I have read about GCC\'s Options for Code Generation Conventions, but could not understand what \"Generate position-independent code (PIC)\" does. Please give an example to explain me what does it mean. 回答1: Position Independent Code means that the generated machine code is not dependent on being located at a specific address in order to work. E.g. jumps would be generated as relative rather than absolute. Pseudo-assembly: PIC: This would work whether the code was at address 100 or 1000 100: