This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Segger Embedded Studio Link Errors - Undefined References

First - thanks to those who answered my question about the Segger Embedded Studio code size limit.  It appears to have be fixed when I switch the build configuration from "Internal and External" to just "Internal".  

This question may relate to the SDK rather than the Segger Embedded Studio, but my project did compile, link, and run with IAR and now I am getting these link errors with SES.  

Linking hm_chair.elf

_build/nrf_sdh.o:(.rodata.sdh_req_observers+0x0): undefined reference to `__start_sdh_req_observers'

_build/nrf_sdh.o:(.rodata.sdh_req_observers+0x4): undefined reference to `__stop_sdh_req_observers'

_build/nrf_sdh.o:(.rodata.sdh_state_observers+0x0): undefined reference to `__start_sdh_state_observers'

_build/nrf_sdh.o:(.rodata.sdh_state_observers+0x4): undefined reference to `__stop_sdh_state_observers'

Parents
  • put "section variables segger embedded" into the search box and that will give you a mixed bag of posts, some of which explain how section variables work and how you need to add extra sections to the linker script and load code. 

    Regrettably section variables are one of those things which IAR's auto-section-creation makes work out of the box so someone used them a couple of years ago. They are a pain however under gcc and other non IAR  toolchains which require them added to the ld script (for gcc) or the xml file which generates the ld script for SES/crossworks and also, since they have defined initial values, a chunk of code to the loader stub to populate them. 

    I haven't seen nor thought up a better solution to this for SES. 

  • I think your suggestion to look at section variables is going to lead me to the fix.  I have not gotten a compile yet, but I do notice that sdh_req_observers (one of the undefined reference errors) is in a section called sdh_req_observers that is created using the NRF_SECTION_SET_DEF call in nrf_sdh.c.  

    On more basic level for someone new to the Segger Embedded Studio, which project file is the makefile?  When I browse the project directory, there are numerous files with the name Makefile.

  • I do not quite understand what you mean by "which project file is the makefile?" Often makefiles are used for the GCC toolchain, but instead SES has its own project file (ending in .emProject) which is really an xml file containing include paths, files, defines, options, etc.

    For makefiles it is not uncommon that one Makefile includes another (or even several other) Makefiles.

Reply
  • I do not quite understand what you mean by "which project file is the makefile?" Often makefiles are used for the GCC toolchain, but instead SES has its own project file (ending in .emProject) which is really an xml file containing include paths, files, defines, options, etc.

    For makefiles it is not uncommon that one Makefile includes another (or even several other) Makefiles.

Children
  • When I search the project directory, I find several instances of Makefile, as well as makefiles with the extension .common, .posix, and .windows.  I assume the relevant makefiles when I use the internal build configuration are those in the /components/toolchain/gcc directory. 

    The issue I'm having is probably related to section variables.  In the Nordic-supplied source file, I notice the following lines:

    // Create section "sdh_req_observers".
    NRF_SECTION_SET_DEF(sdh_req_observers, nrf_sdh_req_observer_t, NRF_SDH_REQ_OBSERVER_PRIO_LEVELS);

    This somehow creates a section sdh_req_observers, which does indeed show up in the map file after building externally with the IAR.  When I try building internally, the link errors listed in my initial question above show up, and I assume that no map file gets created because these are linker errors and the linker therefore never completes successfully.

Related