vtable with PIC option

Asked by Jonathan Dumaresq on 2017-04-13


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 ?



Question information

English Edit question
GNU ARM Embedded Toolchain Edit question
No assignee Edit question
Last query:
Last reply:
Jonathan Dumaresq (jdumaresq) said : #1


any though ?


Launchpad Janitor (janitor) said : #2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Jonathan Dumaresq (jdumaresq) said : #3


any though ?


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.