ARM: Using STL vectors

Hi,

I'm writing a C++ program that will run on an STM3210E-EVAL board and I'm having some problems using STL vectors. I'm wondering what I'm doing wrong. (Or if STL vectors are even supported.)

Here's a snippet:

#include <vector>

.
.
.

void func()
{
  std::vector<int> temp;

  temp.push_back(5);
}

When I try to run the debugger on my target, I end up somewhere in assembly land and never reach the beginning of my main() function. (I am not familiar with assembly so, I'm not quite sure where I am or how I got there.)

When I run in simulator mode, everything works fine. (I end up at the beginning of my main() function like I expect.)

It appears that whenever I make any command that increases the size of my vector, I get the same result. If I never insert into my vector or resize it, then the debugger brings me to the beginning of main(), like I'd expect.

The last time I saw something like this was when my heap was 0 and I tried newing something on the heap. If anyone has any ideas, I'd be grateful.

I'm required to write my program in C++ and though I'm not required to use vectors, I really would like to. (I also have a few ideas of how to implement it differently if it turns out that vectors don't work.)

Thanks,

Parents Reply
  • you must read the following document: DUI0349A_rvct_libraries_guide.pdf paragraph 2.5.1, available at http://www.arm.com (it counts for the RealView compiler):

    The entry point of a program is at __main in the C library where library code does the
    following:
    1. Copies non root (RO and RW) execution regions from their load addresses to their
    execution addresses. Also, if any data sections are compressed, they are
    decompressed from the load address to the execution address. See the Linker and
    Utilities Guide for more information.
    2. Zeroes ZI regions.
    3. Branches to __rt_entry.
    .
    .
    .
    .
    The library function __rt_entry() runs the program as follows:
    1. Calls __rt_stackheap_init() to set up the stack and heap.
    2. Calls __rt_lib_init() to initialize referenced library functions, initialize the
    locale and, if necessary, set up argc and argv for main().
    For C++, calls the constructors for any top-level objects by way of
    __cpp_initialize__aeabi_. See C++ initialization, construction, and destruction
    for more information.
    3. Calls main(), the user-level root of the application.
    From main(), your program might call, among other things, library functions. See
    Library functions called from main() on page 2-36 for more information.
    4. Calls exit() with the value returned by main().
    

    so, if you try to use your STL library too soon, you are, I am sorry to sad, dead. very dead...

Children
More questions in this forum