[En-Nut-Discussion] xnutboot entry point

Henrik Maier hmlists at focus-sw.com
Mon Aug 28 02:41:55 CEST 2006


1) One way to specify the order of functions in the binary code is to 
specify the order when passing the modules to the linker. Hence your 
main() function must be in a module by itself and the first file in the 
linker command line.

 > Currently ... the eboot.c is the first on the list, what makes
 > the ‘main’ function is the first one linked. But what if some day ‘main’
 > goes at the end?

To avoid this, put a comment into the makefile explaining that the order 
is a build requirement and another comment in main.c explaining that 
main() must be the _first_ function in this module.

This means you may have to separate your code into several modules which 
should not be too hard.

 > 2. files are linked in the order as they are in the linker command line
 > – it think the build process cannot depend on it.

In the area of system and embedded programming, the Makefile and it's 
content is equally important to a source file to achieve a certain 
outcome. This means you should choose a build environment which allows 
you to depend on it. That's why system programmers use Makefiles rather 
than IDEs.

2) You can also specify that main() goes into a different section and 
then specify the section order to the linker. Refer to gcc's man pages 
for further assistance on this topic.


Henrik
http://www.proconx.com




More information about the En-Nut-Discussion mailing list