7.8.4 Example of placing ARM C++ library code

You can place C++ library code using a scatter file.

The following is a C++ program that is to be scatter-loaded:

#include <iostream>

using namespace std;

extern "C" int foo ()
{
  cout << "Hello" << endl;
  return 1;
}

To place the C++ library code, define the scatter file as follows:

LR 0x0
{
    ER1 0x0
    {
        *armlib*(+RO)
    }
    ER2 +0
    {
        *cpplib*(+RO)
        *(.init_array)   ; Section .init_array must be placed explicitly,
                         ; otherwise it is shared between two regions, and
                         ; the linker is unable to decide where to place it.
    }
    ER3 +0
    {
        *(+RO)
    }
    ER4 +0
    {
        *(+RW,+ZI)
    }
}

The name armlib indicates the ARM C library files that are located in the directory install_directory\lib\armlib.

The name cpplib indicates the ARM C++ library files that are located in the directory install_directory\lib\cpplib.

Non-ConfidentialPDF file icon PDF versionARM DUI0474M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.