From: richardretanubun <richardretanubun@ruggedcom.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] How to specify the starting function of aU-boot standalone application.
Date: Fri, 27 Jun 2008 12:08:55 -0400 [thread overview]
Message-ID: <48651097.8090302@ruggedcom.com> (raw)
In-Reply-To: <48624EB8.3070300@tqs.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
prev parent reply other threads:[~2008-06-27 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-24 21:45 [U-Boot-Users] How to specify the starting function of a U-boot standalone application richardretanubun
2008-06-25 5:44 ` Jens Gehrlein
2008-06-25 13:42 ` [U-Boot-Users] How to specify the starting function of aU-boot " McMullan, Jason
2008-06-25 13:57 ` Jens Gehrlein
2008-06-27 16:08 ` richardretanubun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48651097.8090302@ruggedcom.com \
--to=richardretanubun@ruggedcom.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox