From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Functions added to extern for stand alone programs
Date: Thu, 24 May 2007 01:06:52 +0200 [thread overview]
Message-ID: <E1Hr00e-0007up-VI@mail.sourceforge.net> (raw)
In-Reply-To: Your message of "Wed, 23 May 2007 16:47:19 EDT." <e68c55e80705231347w76d86bf8o1a1f6001e93f3f72@mail.gmail.com>
In message <e68c55e80705231347w76d86bf8o1a1f6001e93f3f72@mail.gmail.com> you wrote:
>
> it could't really be that simple, could it? I bet my sintax is wrong,
Maybe.
> and I still do not compleatly understand how the compiler intreprets
> "weak" and "set". But I can see how this would work.
I never used this assembler trickery before myself. So far, I only
played with the C variant of it. Like that:
-> cat foo.c
#include <stdio.h>
int func(int, int);
int main (void)
{
int i = func (2, 7);
printf ("i = %d\n", i);
return 0;
}
-> cat func.c
#include <stdio.h>
int __func (int a, int b)
{
printf ("Default func called: %d + %d\n", a, b);
return (a + b);
}
int func(int a, int b) __attribute__ ((weak, alias ("__func")));
-> cat private.c
#include <stdio.h>
int func (int a, int b)
{
printf ("Private func called: %d * %d\n", a, b);
return (a * b);
}
-> gcc -c *.c
-> gcc -o foo foo.o func.o
-> ./foo
Default func called: 2 + 7
i = 9
-> gcc -o bar foo.o func.o private.o
-> ./bar
Private func called: 2 * 7
i = 14
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It is a human characteristic to love little animals, especially if
they're attractive in some way.
-- McCoy, "The Trouble with Tribbles", stardate 4525.6
next prev parent reply other threads:[~2007-05-23 23:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-09 19:00 [U-Boot-Users] [PATCH] Functions added to extern for stand alone programs Jeff Mann
2007-05-09 22:30 ` Wolfgang Denk
2007-05-10 9:48 ` Amnon Cohen
2007-05-10 13:52 ` Jeff Mann
2007-05-18 22:32 ` Håvard Skinnemoen
2007-05-23 19:51 ` Jeffrey Mann
2007-05-23 19:59 ` Wolfgang Denk
[not found] ` <e68c55e80705231347w76d86bf8o1a1f6001e93f3f72@mail.gmail.com>
2007-05-23 20:48 ` Jeffrey Mann
2007-05-23 23:06 ` Wolfgang Denk [this message]
[not found] <1defaf580705241041l77ac1d4jd4e7cf3cb91a455d@mail.gmail.com>
2007-05-24 20:04 ` Jeff Mann
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=E1Hr00e-0007up-VI@mail.sourceforge.net \
--to=wd@denx.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.