spl: remove forced linking of commands into SPL
PATCH 1/1 spl: remove forced linking of commands into SPL
Remove linker command line options from the SPL makefile that force the inclusion of unreferenced command code from linked object files. As commands are not used in the SPL, these options resulted in an unnecessary increase in the image size, in addition to introducing the possibility of tricky link errors in the case where the command code contained symbols that were not resolved by linking in the limited objects compiled in the SPL build.
--- spl/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
spl/Makefile +1 -3
@@ -126,9 +126,7 @@ $(obj)u-boot-spl.bin: $(obj)u-boot-spl $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@ GEN_UBOOT = \ - UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) | \ - sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ - cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__START) \ + cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \ --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot-spl.map -o u-boot-spl
Signature · 1 line
1.7.9.5
PATCH 1/1 spl: remove forced linking of commands into SPL
Quoted 10 lines · Tyler Olmstead
Remove linker command line options from the SPL makefile that force the inclusion of unreferenced command code from linked object files. As commands are not used in the SPL, these options resulted in an unnecessary increase in the image size, in addition to introducing the possibility of tricky link errors in the case where the command code contained symbols that were not resolved by linking in the limited objects compiled in the SPL build.
Signed-off-by Tyler Olmstead <[email protected]>
Without either figuring out how to make the strings be garbage collected automatically (I'm talking with a toolchain friend of mine about how to try and do this) or whacking U_BOOT_CMD to do this for us, we will start adding bloat to SPL after we do this.
Signature · 1 line
Tom
PATCH 1/1 spl: remove forced linking of commands into SPL
Hi Tom,
Quoted 13 lines · Tom Rini
Quoted 10 lines · Tyler Olmstead
Remove linker command line options from the SPL makefile that force the inclusion of unreferenced command code from linked object files. As commands are not used in the SPL, these options resulted in an unnecessary increase in the image size, in addition to introducing the possibility of tricky link errors in the case where the command code contained symbols that were not resolved by linking in the limited objects compiled in the SPL build.
Signed-off-by Tyler Olmstead <[email protected]>
Quoted 7 lines
Without either figuring out how to make the strings be garbage collected automatically (I'm talking with a toolchain friend of mine about how to try and do this) or whacking
U_BOOT_CMDto do this for us, we will start adding bloat to SPL after we do this.--
Tom
I absolutely agree that bloat in the SPL should be avoided wherever possible, but I don't understand how this patch would increase the image size by *not* forcing commands to be linked in. There are numerous examples where the linker is relied upon to not include unused code into SPL. Is there something unique about U_BOOT_CMD that makes it especially troublesome?
Thanks for your insight.
-- Tyler
PATCH 1/1 spl: remove forced linking of commands into SPL
Quoted 22 lines · Tyler Olmstead
Hi Tom,
Quoted 11 lines · Tom Rini
Quoted 9 lines · Tyler Olmstead
Remove linker command line options from the SPL makefile that force the inclusion of unreferenced command code from linked object files. As commands are not used in the SPL, these options resulted in an unnecessary increase in the image size, in addition to introducing the possibility of tricky link errors in the case where the command code contained symbols that were not resolved by linking in the limited objects compiled in the SPL build.
Quoted 7 lines
Quoted 1 line
Signed-off-by Tyler Olmstead <[email protected]>Without either figuring out how to make the strings be garbage collected automatically (I'm talking with a toolchain friend of mine about how to try and do this) or whacking
U_BOOT_CMDto do this for us, we will start adding bloat to SPL after we do this.
Quoted 6 lines
I absolutely agree that bloat in the SPL should be avoided wherever possible, but I don't understand how this patch would increase the image size by *not* forcing commands to be linked in. There are numerous examples where the linker is relied upon to not include unused code into SPL. Is there something unique about
U_BOOT_CMDthat makes it especially troublesome?
It doesn't bloat today, true. It bloats as soon as someone else adds in code that links in a new U_BOOT_CMD that wasn't guarded as now the string literals that before would have been guarded and not linked in will now be un-guarded and not garbage collected (while the command will be). The linker is in fact getting this wrong already in a number of cases (run a 'strings' on an SPL binary) and this needs to be fixed too. I don't want to make the problem potentially worse until we have a fix for the general problem.
To see what I mean, build omap3_beagle with this patch and then un-guard nandecc in arch/arm/cpu/armv7/omap3/board.c. The command will be collected but the command/help string will be in the binary.
Signature · 1 line
Tom
PATCH 1/1 spl: remove forced linking of commands into SPL
In reply to Tyler OlmsteadQuoted 10 lines · Tyler Olmstead
Remove linker command line options from the SPL makefile that force the inclusion of unreferenced command code from linked object files. As commands are not used in the SPL, these options resulted in an unnecessary increase in the image size, in addition to introducing the possibility of tricky link errors in the case where the command code contained symbols that were not resolved by linking in the limited objects compiled in the SPL build.
Signed-off-by Tyler Olmstead <[email protected]>
OK, I've done some more poking at the specific problem I found and, well, we're doing everything right and I don't have a solution, but I think this patch moves us forward. Based on what I'm seeing so far, new U_BOOT_CMDs would be removed correctly, including strings. Or be fixed when I fix the current problem.
Signature · 1 line
Tom
PATCH 1/1 spl: remove forced linking of commands into SPL
Thanks Tom. I've been looking at this some too, and while the commands are removed from the build I've been playing with (hawkboard), they seem to not be removed completely from omap3_beagle. This is confusing as both use -ffunction-sections, -fdata-sections, and --gc-sections. I noticed the hawkboard has it's own linker script for SPL builds, and I'm wondering if this doesn't account for the difference. spl/u-boot-spl.lds uses wild cards for data where u-boot-spl-hawk.lds explicitly names the data sections to link. I'm far from an expert on linker scripts, so I can't test this theory without fear of messing up something.
-- Tyler
Quoted 23 lines · Tom Rini
Quoted 10 lines · Tyler Olmstead
Remove linker command line options from the SPL makefile that force the inclusion of unreferenced command code from linked object files. As commands are not used in the SPL, these options resulted in an unnecessary increase in the image size, in addition to introducing the possibility of tricky link errors in the case where the command code contained symbols that were not resolved by linking in the limited objects compiled in the SPL build.
Signed-off-by Tyler Olmstead <[email protected]>OK, I've done some more poking at the specific problem I found and, well, we're doing everything right and I don't have a solution, but I think this patch moves us forward. Based on what I'm seeing so far, new
U_BOOT_CMDswould be removed correctly, including strings. Or be fixed when I fix the current problem.Acked-by Tom Rini <[email protected]>--
Tom
Quoted 11 lines · Tyler Olmstead
Remove linker command line options from the SPL makefile that force the inclusion of unreferenced command code from linked object files. As commands are not used in the SPL, these options resulted in an unnecessary increase in the image size, in addition to introducing the possibility of tricky link errors in the case where the command code contained symbols that were not resolved by linking in the limited objects compiled in the SPL build.
Signed-off-by Tyler Olmstead <[email protected]>Acked-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120918/0d3e651c/attachment.pgp>