The gcc documentation states, "This option makes a difference on AArch64, m68k, PowerPC and SPARC." I don't see the x86 or x64 architectures listed. AArch64 is related to ARM processors isn't it? If compiling for the linux_x86_x64 then does this option produce any value?
Should gcc -fPIC option be used when compiling for x86_64 architectures?
189 Views Asked by shawn1874 At
1
There are 1 best solutions below
Related Questions in C
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in LINUX
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- Why does Hugo generate different taxonomy-related HTML on different OS's?
- Writes in io_uring do not advance the file offset
- Why `set -o pipefail` gives different output even though the pipe is not failing
- what really controls the permissions: UID or eUID?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Docker container unable to make HTTPS requests to external API
- Whow to use callback_query_handler in Python 3.10
- Create kea runtime directory at startup in Yocto image
- Problem on CPU scheduling algorithms in OS
- How to copy files into the singularity sandbox?
- Android kernel error: undefined reference to `get_hw_version_platform'
- Is there a need for BPF Linux namespace?
- Error when trying to execute a binary compiled in a Kali Linux machine on an Ubuntu system
- Issue with launching application after updating ElectronJs to version 28.0.0 on Windows and Linux
Related Questions in GCC
- File refuses to compile std::erase() even if using -std=g++23
- the difference between two style of inline ASM
- Why veneer code generated by gcc for cortex-m0 seems 8-byte aligned?
- How to compile the Linux kernel with -O0 for more detailed debug?
- GMP Windows installation "configure: error: could not find a working compiler"
- Unable to run get .exe file from assembly NASM
- Problem with compiling c++ project that is running python code using Python.h -> undefined reference
- How to use a newer linker and glibc in a Kotlin/Native project?
- "Config.guess failed to determine the host type" when trying build binutils-2.7 with Cygwin
- Trying to compile GCC returns a bunch of errors
- Compiling with gcc fno-common option causes performance degradation
- On cygwin I get errors containing -lintl and -liconv when running gcc
- Constant function pointer optimization
- How to obtain mingw-w64 version 9.3.0 or older for MSYS2?
- How to fix this error in terminal while writing hello world code in VS Code on C?
Related Questions in X86
- How to call a C language function from x86 assembly code?
- the difference between two style of inline ASM
- Understanding the differences between mov and lea instructions in x86 assembly
- ARM Assembly code is not executing in Vitis IDE
- x86 - compare numbers and push the result onto the stack
- Seeking for the the method for adding the DL (data register) value to DX register
- link.exe unresolved external symbol _mainCRTStartup
- x86 Wrote a boot loader that prints a message to the screen but the characters are completely different to what I expected
- How does CPU tell between MMIO(Memory Mapped IO) and normal memory access in x86 architecture
- Why do register arg values need to be re-assigned in NASM after an int 0x80 system call?
- Why does LLVM-MCA measure an execution stall?
- Why does shr eax, 32 not do anything?
- Evaluating this in Assembly (A % B) % (C % D)
- Understanding throughput of simd sum implementation x86
- Making portable execution errors
Related Questions in POSITION-INDEPENDENT-CODE
- CTF - PIE and non PIE infected binary, base-pointer, instruction pointer values
- Function Pointers in position independent code (-fpic) on stm32 gcc
- Position Independent Code on STM32 - pointers
- Should gcc -fPIC option be used when compiling for x86_64 architectures?
- Understanding a DT_TEXTREL warning
- When static library needs position independent code
- Position Independent Code, GCC versus ARMCC
- CMake: Do I need to set POSITION_INDEPENDENT_CODE here and what exactly is its purpose?
- GCC: how -pie affects address of file scope variable?
- How to find address of function in memory?
- Why does modern GCC compile files as PIE by default?
- Is there a way to tell if a Windows binary is a PIE
- Why can `%rip + displacement` access data section?
- Move the PC into another register with xtensa (lx6) cores
- Position independent code on MCU - everything works, except vsnprintf - C alternative for vsnprintf?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The text you're quoting is from the GCC manual entry for
-fPICwhich directly follows the entry for-fpic. When they say "makes a difference", they mean compared to-fpic.x86-64 can't save instructions or machine-code size with limited-range displacements because call/jump and RIP-relative addressing use
rel3232-bit displacements, so they can reach anywhere within +-2GiB of the instruction. That's the full size allowed in the "small" and "small-PIC" code models, which is enough for basically anything, except sometimes huge arrays in.bss. ("medium" and "large" use 64-bit absolute addresses for arrays over a certain threshold, or for everything which makes every function call an indirect jump).x86-64 does have
jmp rel8(but notcall rel8), but compilers will only use that if one function happens to tailcall another in the same compilation unit, thus the instructions assemble into the same object file and the assembler can see the distance at assemble time and can choose a shorter branch encoding. Jumps to code outside the current object file always get assembled tojmp rel32, becausejmp rel8would rarely fit, only having -128..+127 byte range. (And there's no way for the linker to make an instruction bigger if it needs more room; that would change the distance between instructions before and after it, which probably don't have relocation info since the assembler assumed distances were constant.)If you're compiling a shared library, yes you should use
-fPIC. It's not different from-fpicon x86-64, but you need one or the other.Although with modern distros configuring GCC with
-fPIEas the default, the main difference on x86-64 is I think assuming symbol interposition is possible for global variables that aren't__attribute__((visibility("hidden"))).-fPIEcode-gen is suitable for shared libraries on x86-64 I think, but-fno-pieor-fno-picisn't, and will give link errors when linking into a PIE or normal shared library. (See 32-bit absolute addresses no longer allowed in x86-64 Linux?)