Option -fno-plt has no effect
Goal: to generate position independent code (PIC) that does function calls through the global offset tablee (GOT) and does not use a procedure linkage table (PLT). GCC has option -fno-plt for that purpouse (https:/
Expected result: when compiling with -fpic -fno-plt, each function call should contain instructions to read function address from .got and then branch to that address.
Actual result: direct function calls are generated instead (bl to constant relocatable address):
$ cat test.c
void f2();
void f1() {
f2();
}
$ arm-none-eabi-gcc -c -fpic -fno-plt test.c -o test_no_plt.o
$ arm-none-eabi-gcc -c -fpic -fplt test.c -o test_plt.o
$ diff -b test_no_plt.o test_plt.o
$
This shows, that -fplt and -fno-plt generate identical outputs. Both contain direct function calls that get replaced with PLT by linker when using arm-none-eabi-ld -shared. Using regular version of gcc, different binaries are generated as expected (one contains function call to relocated address, the other one dereferences address from GOT first and then calls)
I am using prebuilt binary distribution of the toolchain:
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-
Host is Ubuntu 18.04 LTS.
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Ervin Oro for more information if necessary.