Skip to content

Frequently Asked Questions

Anton Kolesov edited this page Jun 16, 2015 · 13 revisions
  • Q: How to change heap and stack size in baremetal applications?

    A: To change size of heap in baremetal applications the following option should be specified to the linker: --defsym=__DEFAULT_HEAP_SIZE=${SIZE}, where ${SIZE} is desired heap size, in bytes. It also possible to use size suffixes, like k and m to specify size in kilobytes and megabytes respectively. For stack size respective option is --defsym=__DEFAULT_STACK_SIZE=${STACK_SIZE}. Note that those are linker commands - they are valid only when passed to "ld" application, if gcc driver is used for linking, then those options should be prefixed with -Wl. For example:

    $ arc-elf32-gcc -Wl,--defsym=__DEFAULT_HEAP_SIZE=256m
    -Wl,--defsym=__DEFAULT_STACK_SIZE=1024m hello.o -o hello.bin
    

    Those options are valid only when default linker script is used. If custom linker script is used, then effective way to change stack/heap size depends on properties of that linker script - it might be the same, or it might be different.

  • Q: There are can't resolve symbol error messages when using gdbserver on Linux for ARC target

    A: This error message might appear when gdbserver is a statically linked application. Even though it is linked statically, gdbserver still opens libthread_db.so library using dlopen() function. There is a circular dependency here, as libthread_db.so expects several dynamic symbols to be already defined in the loading application (gdbserver in this case). However statically linked gdbserver doesn't export those dynamic symbols, therefore dlopen() invocation causes those error messages. In practice there haven't been noticed any downside of this, even when debugging applications with threads, however that was tried only with simple test cases. To fix this issue, either rebuild gdbserver as a dynamically linked application, or pass option --with-libthread-db=-lthread_db to configure script of script. In this case gdbserver will link with libthread_db statically, instead of opening it with dlopen() and dependency on symbols will be resolved at link time.

Clone this wiki locally