Sorry about the patch, I had to edit it out for some other changes that got pulled into the file and accidentally deleted a line that should have been there. This patch should be better.

And I also did a svn diff one level up in the tree (flags.patch)

I made a test script and ran it and it sets build_id = 1 properly. I have also included this script.
/*********************
Marc Karasek
MTS
Sun Microsystems
mailto:[EMAIL PROTECTED]
ph:770.360.6415
*********************/



Ed Swierk wrote:
On 1/4/08, Marc Karasek <[EMAIL PROTECTED]> wrote:
Ed sorry for the duplicate, but I only originally replied to you.

I will take a look at it.   When I ran it it did add the option on my
system.   The only question I had was for an older ld version would it
behave properly.

Try running this snippet from buildtarget in a shell and you'll see what I mean:

ld --help | awk '{for (i=1;i<=NF;i++) if ($i ~ /build-id/){n++} }; END
{exit n}'; build_id=$?; echo -n 'ld supports --build-id? '; if [
$build_id \
]; then echo 'yes'; else echo 'no'; fi

I did the patch using svn diff from the tree.  Is there another way to
generate it?

Not sure...

--Ed
Index: src/config/Config.lb
===================================================================
--- src/config/Config.lb	(revision 3007)
+++ src/config/Config.lb	(working copy)
@@ -8,7 +8,7 @@
 makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
 
 makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
-makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
+makedefine CFLAGS := $(CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
 
 makedefine HOSTCFLAGS:= -Os -Wall
 
@@ -38,14 +38,15 @@
         action  "ar cr linuxbios.a $(OBJECTS)"
 end
 
+
 makerule linuxbios_ram.o
 	depends	"$(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)" 
-	action	"$(CC) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
 end
 
 makerule linuxbios_ram
 	depends	"linuxbios_ram.o $(TOP)/src/config/linuxbios_ram.ld ldoptions" 
-	action	"$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_ram.ld linuxbios_ram.o"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_ram.ld linuxbios_ram.o"
 	action 	"$(CROSS_COMPILE)nm -n linuxbios_ram | sort > linuxbios_ram.map"
 end
 
@@ -83,12 +84,12 @@
 
 	makerule linuxbios_apc.o
 		depends "linuxbios_apc.a c_start.o $(LIBGCC_FILE_NAME)"
-        action  "$(CC) -nostdlib -r -o $@ c_start.o linuxbios_apc.a $(LIBGCC_FILE_NAME)"
+        action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o linuxbios_apc.a $(LIBGCC_FILE_NAME)"
 	end
 
 	makerule linuxbios_apc
 		depends "linuxbios_apc.o $(TOP)/src/config/linuxbios_apc.ld ldoptions"
-		action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_apc.ld linuxbios_apc.o"
+		action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_apc.ld linuxbios_apc.o"
 		action  "$(CROSS_COMPILE)nm -n linuxbios_apc | sort > linuxbios_apc.map"
 	end
 
@@ -121,7 +122,7 @@
 
 makerule linuxbios   
 	depends	"crt0.o $(INIT-OBJECTS) $(LINUXBIOS_APC) $(LINUXBIOS_RAM_ROM) ldscript.ld"
-	action	"$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
 	action	"$(CROSS_COMPILE)nm -n linuxbios | sort > linuxbios.map"
 end

Index: src/arch/i386/lib/id.lds
===================================================================
--- src/arch/i386/lib/id.lds	(revision 3007)
+++ src/arch/i386/lib/id.lds	(working copy)
@@ -1,5 +1,11 @@
 SECTIONS {
-	. = (_ROMBASE + ROM_IMAGE_SIZE - 0x10) - (__id_end - __id_start);
+
+/*
+ *           . = (_ROMBASE + (ROM_IMAGE_SIZE - 0x10)) - (__id_end - __id_start);
+ *  		This is a temporary fix.  Under Fedora 8 ld does not like it if the .id section is above address 0xFFFF_EF00          
+*/
+        _ROMTEMP = 0xffffef00;
+        . = _ROMTEMP;
 	.id (.): {
 		*(.id)
 	}
Index: targets/buildtarget
===================================================================
--- targets/buildtarget	(revision 3007)
+++ targets/buildtarget	(working copy)
@@ -53,4 +53,32 @@
 export PYTHONPATH=$config_dir
 $PYTHON $config_py $config_lb $lbpath
 
+# now start checking for distro-specific breakage. 
+## This check is for the no stack protector mess.
+EXTRA_CFLAGS=
+
+if [ -z "$CC" ]; then
+       CC=gcc
+fi
+
+$CC -fno-stack-protector -S -xc /dev/null -o .$$.tmp
+
+if [ $? -eq 0 ]; then
+       EXTRA_CFLAGS=-fno-stack-protector
+fi
+
+rm -rf .$$.tmp
+
+ld --help | awk '{for (i=1;i<=NF;i++) if ($i ~ /build-id/){n++} }; END {exit n}' 
+build_id=$?
+if [ $build_id ] ; then
+	EXTRA_LFLAGS+=" -Wl,--build-id=none"
+fi
+
+for i in $build_dir/Makefile.settings $build_dir/*/Makefile.settings
+do
+	echo DISTRO_CFLAGS+=$EXTRA_CFLAGS >>$i
+	echo DISTRO_LFLAGS+=$EXTRA_LFLAGS >>$i
+done
+
 exit $?
ld --help | awk '{for (i=1;i<=NF;i++) if ($i ~ /build-id/){n++} }; END {exit n}'
build_id=$?
echo $build_id
echo -n 'ld supports --build-id?' 
if [ $build_id ]; then 
	echo ' yes'
else 
	echo ' no'
fi
Index: LinuxBIOSv2/src/config/Config.lb
===================================================================
--- LinuxBIOSv2/src/config/Config.lb	(revision 3007)
+++ LinuxBIOSv2/src/config/Config.lb	(working copy)
@@ -8,7 +8,7 @@
 makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
 
 makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
-makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
+makedefine CFLAGS := $(CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
 
 makedefine HOSTCFLAGS:= -Os -Wall
 
@@ -38,14 +38,15 @@
         action  "ar cr linuxbios.a $(OBJECTS)"
 end
 
+
 makerule linuxbios_ram.o
 	depends	"$(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)" 
-	action	"$(CC) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
 end
 
 makerule linuxbios_ram
 	depends	"linuxbios_ram.o $(TOP)/src/config/linuxbios_ram.ld ldoptions" 
-	action	"$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_ram.ld linuxbios_ram.o"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_ram.ld linuxbios_ram.o"
 	action 	"$(CROSS_COMPILE)nm -n linuxbios_ram | sort > linuxbios_ram.map"
 end
 
@@ -83,12 +84,12 @@
 
 	makerule linuxbios_apc.o
 		depends "linuxbios_apc.a c_start.o $(LIBGCC_FILE_NAME)"
-        action  "$(CC) -nostdlib -r -o $@ c_start.o linuxbios_apc.a $(LIBGCC_FILE_NAME)"
+        action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o linuxbios_apc.a $(LIBGCC_FILE_NAME)"
 	end
 
 	makerule linuxbios_apc
 		depends "linuxbios_apc.o $(TOP)/src/config/linuxbios_apc.ld ldoptions"
-		action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_apc.ld linuxbios_apc.o"
+		action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_apc.ld linuxbios_apc.o"
 		action  "$(CROSS_COMPILE)nm -n linuxbios_apc | sort > linuxbios_apc.map"
 	end
 
@@ -121,7 +122,7 @@
 
 makerule linuxbios   
 	depends	"crt0.o $(INIT-OBJECTS) $(LINUXBIOS_APC) $(LINUXBIOS_RAM_ROM) ldscript.ld"
-	action	"$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
 	action	"$(CROSS_COMPILE)nm -n linuxbios | sort > linuxbios.map"
 end

Index: LinuxBIOSv2/src/arch/i386/lib/id.lds
===================================================================
--- LinuxBIOSv2/src/arch/i386/lib/id.lds	(revision 3007)
+++ LinuxBIOSv2/src/arch/i386/lib/id.lds	(working copy)
@@ -1,5 +1,11 @@
 SECTIONS {
-	. = (_ROMBASE + ROM_IMAGE_SIZE - 0x10) - (__id_end - __id_start);
+
+/*
+ *           . = (_ROMBASE + (ROM_IMAGE_SIZE - 0x10)) - (__id_end - __id_start);
+ *  		This is a temporary fix.  Under Fedora 8 ld does not like it if the .id section is above address 0xFFFF_EF00          
+*/
+        _ROMTEMP = 0xffffef00;
+        . = _ROMTEMP;
 	.id (.): {
 		*(.id)
 	}
Index: LinuxBIOSv2/targets/buildtarget
===================================================================
--- LinuxBIOSv2/targets/buildtarget	(revision 3007)
+++ LinuxBIOSv2/targets/buildtarget	(working copy)
@@ -53,4 +53,32 @@
 export PYTHONPATH=$config_dir
 $PYTHON $config_py $config_lb $lbpath
 
+# now start checking for distro-specific breakage. 
+## This check is for the no stack protector mess.
+EXTRA_CFLAGS=
+
+if [ -z "$CC" ]; then
+       CC=gcc
+fi
+
+$CC -fno-stack-protector -S -xc /dev/null -o .$$.tmp
+
+if [ $? -eq 0 ]; then
+       EXTRA_CFLAGS=-fno-stack-protector
+fi
+
+rm -rf .$$.tmp
+
+ld --help | awk '{for (i=1;i<=NF;i++) if ($i ~ /build-id/){n++} }; END {exit n}' 
+build_id=$?
+if [ $build_id ] ; then
+	EXTRA_LFLAGS+=" -Wl,--build-id=none"
+fi
+
+for i in $build_dir/Makefile.settings $build_dir/*/Makefile.settings
+do
+	echo DISTRO_CFLAGS+=$EXTRA_CFLAGS >>$i
+	echo DISTRO_LFLAGS+=$EXTRA_LFLAGS >>$i
+done
+
 exit $?
-- 
linuxbios mailing list
linuxbios@linuxbios.org
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to