public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] Code duplication...
@ 2007-06-22 21:32 Robin Getz
  2007-06-22 22:16 ` Wolfgang Denk
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Robin Getz @ 2007-06-22 21:32 UTC (permalink / raw)
  To: u-boot

I was looking to try to prune the code size of U-Boot down a bit, and noticed with:

rgetz at imhotep:~/u-boot> bfin-elf-nm u-boot | grep " [tT] " | awk '{ print $3}' | sort |  uniq -c | grep -v " 1 "

      3 ___fswab16   (12 bytes each)
      6 ___fswab32   (36 bytes each)
      2 _NetCopyIP   ( 6 bytes each)
      2 _NetWriteIP  (22 bytes each)
      2 _zalloc      (12 bytes each)
      2 _zfree       ( 6 bytes each)

because these functions are included in .h files, as functions:

include/linux/byteorder/swab.h

static __inline__ __attribute__((const)) __u16 __fswab16(__u16 x)
{
        return __arch__swab16(x);
}

And when compiling with gcc -Os, __inline__  is a suggestion, not a requirement.

From:
http://gcc.gnu.org/onlinedocs/gcc-4.2.0/gcc/Function-Attributes.html

always_inline
    Generally, functions are not inlined unless optimization is specified. 
    For functions declared inline, this attribute inlines the function even 
    if no optimization level was specified. 

http://gcc.gnu.org/onlinedocs/gcc-4.2.0/gcc/Inline.html#Inline makes the suggestion:

The combination of inline and extern has almost the effect of a macro. The way 
to use it is to put a function definition in a header file with these 
keywords, and put another copy of the definition (lacking inline and 
extern) in a library file. The definition in the header file will cause 
most calls to the function to be inlined. If any uses of the function
remain, they will refer to the single copy in the library.

Today - they get included in every .o file which includes it, and when the link happens, duplicates are not removed.

For grep ___fswab16 * -R, I get
Binary file net/bootp.o matches
Binary file net/tftp.o matches
Binary file net/net.o matches

and bfin-elf-objdump -d net/libnet.a | grep "___fswab16>:" tells me:

00000000 <___fswab16>:
00000000 <___fswab16>:
00000000 <___fswab16>:

it was included 3 times from the three .o files.

First question is - does anyone see the same thing on their platform - or is it something wonky with my toolchain.

Next question is - for a savings of 250 bytes, does anyone care?

-Robin

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-06-25 15:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-22 21:32 [U-Boot-Users] Code duplication Robin Getz
2007-06-22 22:16 ` Wolfgang Denk
2007-06-23  0:38   ` [U-Boot-Users] MPC8439E + Marvell 888E1111 (blah!) David Hawkins
2007-06-23  0:48     ` David Hawkins
2007-06-23  0:59       ` David Hawkins
2007-06-25 15:12       ` Timur Tabi
2007-06-23 19:00     ` Andy Fleming
2007-06-23 19:19       ` David Hawkins
2007-06-25  4:33   ` [U-Boot-Users] Code duplication Robin Getz
2007-06-25  5:58     ` Stefan Roese
2007-06-25  7:00     ` Wolfgang Denk
2007-06-22 22:53 ` Kim Phillips
2007-06-22 23:01 ` Håvard Skinnemoen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox