From mboxrd@z Thu Jan 1 00:00:00 1970 From: richardretanubun Date: Fri, 27 Jun 2008 12:08:55 -0400 Subject: [U-Boot-Users] How to specify the starting function of aU-boot standalone application. In-Reply-To: <48624EB8.3070300@tqs.de> References: <48616AED.50205@ruggedcom.com> <4861DB22.9090201@tqs.de> <1214401321.1418.27.camel@mcmullan-linux.cifs.lab.netapp.com> <48624EB8.3070300@tqs.de> Message-ID: <48651097.8090302@ruggedcom.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Guys, I found this in the u-boot FAQ (is there anything that thing can't answer? :D) http://www.denx.de/wiki/view/DULG/MyStandaloneProgramDoesNotWork Of course, Jason's solution is also nice. Thanks for that! Regards, - Richard Retanubun Jens Gehrlein wrote: > Hi Jason, > > McMullan, Jason schrieb: >> On Wed, 2008-06-25 at 07:44 +0200, Jens Gehrlein wrote: >>> I have the same problem. When I modify the source code the compiler >>> may or may not rearrange the functions. It is not guaranteed, that >>> the main function always starts at the same address. >>> >>> How can this be solved? Is it possible/meaningful to put the main >>> function into a separate linker segment? Any suggestions? >> >> The simplest way I've found is to make the following C file: >> >> --- _start.c --- >> void _start(void) >> { >> extern int main(int argc, char **argv); >> char *args[] = { "myprogramname", "-foo", "bar", /* etc. etc. */ }; >> main(sizeof(args)/sizeof(args[0]), args); >> /* Wait forever after the program ends */ >> for (;;); >> } >> ----------------- >> >> Then, link '_start.o' before *any* other objects in your link step. >> >> Voila! The text entry should be _start! >> >> Feel free to add BSS initialization, etc. in _start as needed. > > Very nice. Thank you for this tip! > > Best Regards, > Jens