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

starup *.s file for KEIL

The startup *.s file is placed in a library project, then the app project link this library.
When I compile, error:
error: L6236E: No section matches selector - no section to be FIRST/LAST.

but place *.s file in app project, it's OK.

Parents Reply Children
  • But what variables or functions implemented in your startup file does the code you have outside of the library try to access?

    The regions are there to group code. They do not represent variables or functions.

    Think about it - if a program wants the linker to place symbols of type "data" in a specific memory range, should the linker then bring in everything in a library that happens to reference "data"? That would mean that any module in the C runtime library that happens to contain an initialized variable would match and would have to be included. Same of the linker was forced to include everything that specifies "bss" - then all CRTL modules with uninitialized data would get included. Same of the linker was forced to include everything that specified "text" - in goes all modules that happens to contain any code.

  • linkfile for keil (*.scf) contain the codes as follow:
    * (RESET,+FIRST)

    And the 'RESET' section is defined in starup file (*.s) of startup libray as follow:
    AREA RESET, DATA, READONLY

    The the linker of KEIL don't find the section 'RESET'

  • Does it really not find it, or does it simply discard it because it has no symbol dependency requiring it's presence?

    A library is a collection of objects, the linker is free to pick and choose which it includes as it navigates the dependency tree. That it doesn't include the object you want suggests that it can get closure without it. When you grasp this, and the appropriateness of dumping everything into a library you might be able to make some progress.

  • Why should the linker care more about the section RESET than it should about other sections?

    A section is just a grouping. As I already indicated in my previous post - it isn't a variable or function.

    The day one of your source files not hidden in the library tries to access an exported symbol from that startup file - like maybe Reset_Handler, assuming you have something like

                    EXPORT  Reset_Handler
    Reset_Handler
    


    then the linker would have a reason to go hunting for an object file that can supply that Reset_Handler reference.

    But your area RESET is no more interesting when digging out object files from the library than the area CODE. If it was, then the concept with libraries would fail because the linker would suck in every single object file from the library that happened to mention an area that you want in your program. So all of the CRTL would be included even of the tiniest Hello World!

    It's time to stop blaming the tools for doing what they are explicitly designed to do, and start using them as they were intended to be used. You'll get much better progress that way.