Keil Logo

ARMLINK: Placing vTable in a specific section using the Arm Linker

Information in this knowledgebase article applies to:

  • ARMCCv5.xx


Our system comprises internal and external FLASH memory for the executable code.

The external FLASH is slower and we see that lots of vtables which are the pointer tables for virtual functions and Run Time Type Information(RTTI), are being placed in the external memory which limits the overall performance.

How can we place the vtables in a specific section using Arm Linker ?


vtables can be assigned to a particular section with the help of a scatter file.

Below is an example of source code:

class Test{
  Test() {}
  virtual void speak() { std::cout << "Hi!" << std::endl; }

class Testing : Test{
  Testing () {}
  void speak() { std::cout << "Hello!" << std::endl; }

int main() {
  Testing testing;
  return 0;

The vTable generated during the linking of this piece of code can be located to a specific section using the below scatter file:

LoadRegion 0x8000
   ExecReg +0
   vtable 0x80000
      *(:gdef:_ZTV*)       <-- This denotes the vtable for all symbols, you might want to be more specific
   ARM_LIB_STACKHEAP 0x100000 EMPTY 0x4000 {}

The linker will output below result which can be verified in the MAP file:

4066  _ZTV3Testing             0x00080118   Wk    4  Data  Hi   0xc
4067  _ZTV6Test                0x00080124   Wk    4  Data  Hi   0xc
** Section #4 'vtable' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR]
    Size   : 3668 bytes (alignment 4)
    Address: 0x00080000

We can see that the vtables for Test and Testing are placed in section 4.

The section 4 contains all the vtables and is placed at address 0x80000 as we requested with the scatter file.


Last Reviewed: Monday, August 12, 2019

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.