No subject


Fri Jan 23 11:48:37 CET 2009


-ffunction-sections
-fdata-sections

Place each function or data item into its own section in the output file if the
target supports arbitrary sections.  The name of the function or the name of the
data item determines the section's name in the output file.

Use these options on systems where the linker can perform optimizations to
improve locality of reference in the instruction space.  Most systems using the
ELF object format and SPARC processors running Solaris 2 have linkers with such
optimizations. AIX may have these optimizations in the future.

Only use these options when there are significant benefits from doing so.  When
you specify these options, the assembler and linker will create larger object
and executable files and will also be slower. You will not be able to use "gprof"
on all systems if you specify this option and you may have problems with
debugging if you specify both this option and -g.

Signed-off-by: Luigi 'Comio' Mantellini <luigi.mantellini at idf-hit.com>
---
 config.mk |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/config.mk b/config.mk
index c6d6f7b..94ca033 100644
--- a/config.mk
+++ b/config.mk
@@ -97,6 +97,8 @@ HOSTCFLAGS	+= -pedantic
 #
 cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
 		> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+ld-option = $(shell if $(CC) -Wl,$(1) -nostdlib -xc /dev/null -o /dev/null \
+		> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
 
 #
 # Include the make variables (CC, etc...)
@@ -191,6 +193,13 @@ endif
 
 CFLAGS += $(call cc-option,-fno-stack-protector)
 
+# Create a section for each function or data (useful for sections garbage collector)
+CFLAGS += $(call cc-option,-ffunction-sections)
+CFLAGS += $(call cc-option,-fdata-sections)
+
+# Enable sections garbage collector
+LDFLAGS += $(call ld-option,--gc-sections)
+
 # $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
 # option to the assembler.
 AFLAGS_DEBUG :=
-- 
1.7.3



More information about the U-Boot mailing list