From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Thu, 24 May 2007 01:06:52 +0200 Subject: [U-Boot-Users] [PATCH] Functions added to extern for stand alone programs In-Reply-To: Your message of "Wed, 23 May 2007 16:47:19 EDT." Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de In message 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 int func(int, int); int main (void) { int i = func (2, 7); printf ("i = %d\n", i); return 0; } -> cat func.c #include 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 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