Option -fno-plt has no effect

Asked by Mere Loom on 2018-05-29

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://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Code-Gen-Options.html#index-fno-plt): "Do not use the PLT for external function calls in position-independent code. Instead, load the callee address at call sites from the GOT and branch to it."

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-7-branch revision 255204]
Host is Ubuntu 18.04 LTS.

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2018-06-11
Last reply:
2018-06-13
Mere Loom (mereloom) said : #1

The same issue also exists on Windows host. There also -fplt and -fno-plt generate identical outputs.

Tejas Belagod (belagod-tejas) said : #2

Hi,

Support for -fno-plt is not implemented presently. How important is this feature for you?

Thanks.

Can you help with this problem?

Provide an answer of your own, or ask Mere Loom for more information if necessary.

To post a message you must log in.