[coreboot] [PATCH] v3: section correctness checker

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Wed Aug 20 18:46:09 CEST 2008


On 20.08.2008 17:49, Stefan Reinauer wrote:
> Carl-Daniel Hailfinger wrote:
>   
>> On 20.08.2008 15:33, Carl-Daniel Hailfinger wrote:
>>   
>>     
>>> v3 does not handle .data and .bss sections in stage1 and initram. We
>>> simply hope they are unused/empty and will get runtime
>>> crashes/corruption/malfunction if they are not empty.
>>>
>>> Check for the emptiness of these sections and abort the build on error.
>>> This triggers on all stage1/initram global variables which are not
>>> declared the right way.
>>>
>>> This found a long-standing bug introduced in r729 and fixed in r576.
>>> It also breaks the build of every Geode target in the v3 tree because
>>> they have multiple bugs. And it breaks the build of the K8 code because
>>> of a bug there.
>>>
>>> Tested for all possible variations of .data and .bss usage.
>>>
>>> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
>>>   
>>>     
>>>       
>> Better checker follows. It does not only tell you the name of the object
>> file with the bug, it even gives you the variable name which caused the bug:
>>   CHECK   initram (non-empty .data sections)
>> /sources/tmptrees/corebootv3-check_illegal_global_vars/build/coreboot.initram_partiallylinked.o:
>> first_time.3526
>> make: ***
>> [/sources/tmptrees/corebootv3-check_illegal_global_vars/build/coreboot.initram]
>> Error 1
>>
>> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
>>   
>>     
>
> Hm.. should we pack this into a small shell script (similar to xcompile) ?
> Duplicating (almost) the same code 4 times is a bit ugly.
>
> Also,  please use $(OBJDUMP), as on any cross compiling system objdump
> will not be there, or for a different architecture.
>   

Script follows. It will be called with the correct $(OBJDUMP). What do
you think?

Regards,
Carl-Daniel

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

Index: util/sectionchecker/sectionchecker
===================================================================
--- util/sectionchecker/sectionchecker	(Revision 0)
+++ util/sectionchecker/sectionchecker	(Revision 0)
@@ -0,0 +1,22 @@
+#!/bin/bash
+OBJDUMP=$1
+SECTION=$2
+BASEDIR=$3
+shift 3
+$OBJDUMP -h $*|
+	grep "^$BASEDIR\|\\$SECTION"|
+	grep -v "\\$SECTION[[:blank:]]\+00000000[[:blank:]]"|
+	grep -B1 "\\$SECTION"|
+	grep "^$BASEDIR"|
+	cut -f 1 -d:|
+	while read a; do
+		echo -n "$a: "
+		$OBJDUMP -t --section=$SECTION $a|
+			grep -i "^[0-9a-f]\{8\}"|
+			grep -v "00000000 [^ ]\+$"|
+			sed "s/.* //"|
+			xargs echo
+	done|
+	grep "^$BASEDIR"
+# Invert the result
+test $? -ne 0



-- 
http://www.hailfinger.org/





More information about the coreboot mailing list