vtable with PIC option

Asked by Jonathan Dumaresq on 2017-04-13

HI,

we are looking to get our code position independant on cortex-m4.

I have activated those switches, -fPIC -mno-pic-data-is-text-relative -msingle-pic-base. Now with this code, I see in assembly, that the compiler will use the R9 to locate the GOT and get ossfet in to the to reach global symbol. In global symbol, I see global variables, static variable and vtable/typeinfo.

The question is about vtable/typeinfo. I see in my map file that all the vtable now get into a new section (compare to no pic option) called .data. rel.ro instead of .rodata

I know that in a full os like Linux, this can be interesting, but for an bare metal system, this is look strange to me. The vtable cannot change in runtime, so I think this vtable should confsidered like any other const symbol and continue to be text relative (from PC) like any other function.

The main issue here, is that each vtable, are now referenced by the GOT and in the mean time add code to retrieve the VTABLE.

From a small measurement, this add ~ 5% more code on big project.

Are you aware of any compiler switch for VTABLE/TYPEINFO to be PC relative instead of be referenced into the GOT ?

Regards

Jonathan

Question information

Language:
English Edit question
Status:
Open
For:
GNU ARM Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2017-04-13
Last reply:

Can you help with this problem?

Provide an answer of your own, or ask Jonathan Dumaresq for more information if necessary.

To post a message you must log in.