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

query on startup code

1) Where from the startup.s gets the __main?--is it from the library? if yes then which library?
2) Where is the complete linker script?---as i hope appname.sct is not the only linker script.

it will be helpful if i get any direction of those as i need to make my students clear of the startup and linking process.

Thanks and regards,
-----------Biplab Roy

  • The library would normally contain a function with external linkage __main - which would be a C function with name _main().

    And then the startup would try to call a function with external linkage _main, which is the standard main() function.

    You normally just have file to control the linking. The scatter file tells what memory regions that are available and if they are flash or RAM. And it tells if some code or data with special attributes needs to be placed at some specific location.

    So the scatter file makes sure that the boot vectors etc will be placed where the processor expects them. Symbol-wise, the linker will just look at the symbols referenced from the object files you supply it with. And symbol not part of these files will be searched for in the available library files.

    With the exception of the memory regions specified by the scatter file, everything is very similar to what a normal PC linker does. Just that the PC linker normally doesn't need to know about absolute addresses and ranges since PC-class programs have stores information about all address fixups that the loader needs to perform when the program is loaded into RAM - and the fixups are adapted to where in RAM the program ends up being stored. The embedded linker would normally perform all fixups directly during the linking step so the binary can be loaded by a dumb copy function with no patching needed.