This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to get section address and size

Hi

I want to get the BSS section and .constdata seciton's base address and size in C code. Does anyone knows how to get them ? Thanks very much !

Parents
  • The linker will define symbols; for gcc-arm-none-eabi at least, they look like:  __bss_start__, __bss_end__, __data_start__, and __data_end__

    In C, use their addresses:

    extern uint8_t  __bss_start__, __bss_end__, __data_start__,  __data_end__;
    
      printf("BSS Start = %08x, size = %d\n", &__bss_start__, &__bss_end__ - &__bss_start__);

    (I believe Keil does the same thing)

Reply
  • The linker will define symbols; for gcc-arm-none-eabi at least, they look like:  __bss_start__, __bss_end__, __data_start__, and __data_end__

    In C, use their addresses:

    extern uint8_t  __bss_start__, __bss_end__, __data_start__,  __data_end__;
    
      printf("BSS Start = %08x, size = %d\n", &__bss_start__, &__bss_end__ - &__bss_start__);

    (I believe Keil does the same thing)

Children