[LinuxBIOS] [PATCH] v3: duplicate less code

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Wed Nov 28 01:04:31 CET 2007


On 25.11.2007 16:26, Stefan Reinauer wrote:
> Carl-Daniel Hailfinger schrieb:
>   
>> On 21.11.2007 15:39, Carl-Daniel Hailfinger wrote:
>> [explanation snipped, see original post]
>>   
>>     
>>> To reduce code duplication, make sure STAGE2_*OBJ does not contain
>>> any object already mentioned in STAGE0_*_OBJ.
>>> Specifically, remove mem.o, delay.o, udelay_io.o from STAGE2_*OBJ.
>>> This saves 386 bytes in stage2 (~240 bytes after LZMA compression).
>>>
>>> In the future, automatically removing objects from STAGE2_OBJ which
>>> are already included in STAGE0_OBJ will be the way to go.
>>>
>>> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
>>>   
>>>     
>>>       
>> Opinions?
>>   
>>     
>
> Yes. We should think about this again when we sorted out the inter-stage 
> call issues.
>   

Now that these issues are mostly solved, can we consider an improved
patch to solve code duplication?

To reduce code duplication, make sure STAGE2_OBJ does not contain
any object already mentioned in STAGE0_OBJ.
This saves 386 bytes in qemu stage2 (~240 bytes after LZMA compression).

Build tested and runtime tested in Qemu.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>


Index: LinuxBIOSv3-filteroutduplicatedshared/arch/x86/Makefile
===================================================================
--- LinuxBIOSv3-filteroutduplicatedshared/arch/x86/Makefile	(Revision 529)
+++ LinuxBIOSv3-filteroutduplicatedshared/arch/x86/Makefile	(Arbeitskopie)
@@ -198,11 +198,16 @@
 STAGE2_OBJ += $(obj)/util/x86emu/libx86emu.a $(LIBGCC_FILE_NAME)
 endif
 
-$(obj)/linuxbios.stage2.o $(obj)/linuxbios.stage2.map: $(obj)/stage0.init $(STAGE2_OBJ)
+# To reduce code duplication, always make sure STAGE2_OBJ does not contain
+# any object from STAGE0_OBJ.
+
+STAGE2_OBJ_NEEDED = $(filter-out $(STAGE0_OBJ), $(STAGE2_OBJ))
+
+$(obj)/linuxbios.stage2.o $(obj)/linuxbios.stage2.map: $(obj)/stage0.init $(STAGE2_OBJ_NEEDED)
 	$(Q)# leave a .o with full symbols in it for debugging.
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(LD) -R $(obj)/stage0.o -Ttext 0x1000 --entry=stage2 \
-		  -o $(obj)/linuxbios.stage2.o $(STAGE2_OBJ)
+		  -o $(obj)/linuxbios.stage2.o $(STAGE2_OBJ_NEEDED)
 	$(Q)$(NM) $(obj)/linuxbios.stage2.o | sort -u > $(obj)/linuxbios.stage2.map
 
 #







More information about the coreboot mailing list