[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] bootstrap code
dear all,
attached are two patches that let you create "correct"
kernel+filesystem elf files (correct means: with proper program header
for romfs segments). one of them is for the uClinux-dist, the other is for
the uClinux-2.4.x directory.
it is a post-linking solution: a perl script creates a linker script
based on the compiled kernel, and ld links the kernel and the
romfs elf together. the linker script makes sure that the sections
in the kernel image are not moved around within memory.
the resulting file is images/image.elf
the usual image.bin file is also created. i seems to be ok, but let me
know if you have any problems with it (or the elf file).
good luck,
--
mazsi
----------------------------------------------------------------
Strawberry fields forever! Jozsef.Imrek@strawberry.dnsalias.org
----------------------------------------------------------------
--- vendors/Insight/mbvanilla_net/Makefile 15 Apr 2004 01:49:15 -0000 1.1.1.2
+++ vendors/Insight/mbvanilla_net/Makefile 14 May 2004 02:31:55 -0000
@@ -7,6 +7,7 @@
# IMAGEZ = $(IMAGEDIR)/imagez.bin
# ELFIMAGE = $(IMAGEDIR)/linux
ROMFSIMG = $(IMAGEDIR)/romfs.img
+ROMFSELF = $(IMAGEDIR)/romfs.elf
IMAGE = $(IMAGEDIR)/image.bin
IMAGEZ = $(IMAGEDIR)/imagez.bin
ELFIMAGE = $(IMAGEDIR)/image.elf
@@ -139,16 +140,19 @@
echo -ne "\000" >> $(IMAGEZ)
echo -n $(CONFIG_PRODUCT) >> $(IMAGEZ)
$(ROOTDIR)/tools/cksum -b -o 2 $(IMAGEZ) >> $(IMAGEZ)
- BSS=`$(CROSS)objdump --headers $(ROOTDIR)/$(LINUXDIR)/linux | \
- grep "\.bss"` ; \
- ADDR=`set -- $${BSS} ; echo 0x$${4}` ; \
- mb-objcopy --add-section=.romfs=$(ROMFSIMG) \
- --adjust-section-vma=.romfs=$${ADDR} --no-adjust-warnings \
- --set-section-flags=.romfs=alloc,load,data \
- $(ROOTDIR)/$(LINUXDIR)/linux $(ELFIMAGE)
+
+ echo | $(CROSS)as -o $(ROMFSELF) -
+ $(CROSS)objcopy --add-section=.romfs=$(ROMFSIMG) \
+ --set-section-flags=.romfs=alloc,load,data --only-section=.romfs \
+ $(ROMFSELF)
+ $(CROSS)readelf -e $(ROOTDIR)/$(LINUXDIR)/linux | perl -- makelinkscript.pl > $(IMAGEDIR)/image.ld
+ $(CROSS)ld --warn-section-align -T $(IMAGEDIR)/image.ld $(ROMFSELF) $(ROOTDIR)/$(LINUXDIR)/linux -o $(ELFIMAGE)
+ $(CROSS)strip $(ELFIMAGE)
mb-objcopy -O binary --remove-section=.stab --remove-section=.stabstr $(ELFIMAGE) $(IMAGE)
+
[ -n "$(NO_BUILD_INTO_TFTPBOOT)" ] || cp $(IMAGE) /tftpboot
[ -n "$(NO_BUILD_INTO_TFTPBOOT)" ] || cp $(IMAGEZ) /tftpboot
+ [ -n "$(NO_BUILD_INTO_TFTPBOOT)" ] || cp $(ELFIMAGE) /tftpboot
vendor_flash:
$(ROOTDIR)/bin/make_flash
--- vendors/Insight/mbvanilla_net/makelinkscript.pl 2004-05-14 04:04:57.000000000 +0200
+++ vendors/Insight/mbvanilla_net/makelinkscript.pl 2004-05-14 04:04:57.000000000 +0200
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+##
+## uncomment this if you want to detect the entry point autmaticly
+##
+#my $entry;
+#while (<>){
+# if( /Entry point address:\s+(0x[[:xdigit:]]+)/ ){
+# $entry = $1;
+# last;
+# }
+#}
+#if( !defined($entry) ){ die "could not find entry point in output!"; }
+#print "start = $entry ;\n";
+#
+print "ENTRY( start )\n";
+
+
+print "SECTIONS {\n";
+while (<>){
+ if( /\[([ \d]\d)\] (\.\w+)\s+(\w+)\s+([[:xdigit:]]+) [[:xdigit:]]+ ([[:xdigit:]]+) .. ... +\d+\s+\d+\s+(\d+)/){
+# if($3 ne "PROGBITS" || $5 eq "000000"){ next; }
+# print "\t$2 ALIGN( $6 ) : { *($2) }\n";
+ print "\t$2 0x$4 : { *($2) }\n";
+ }
+}
+print "}\n";
--- arch/microblaze/mbvanilla.ld 13 Apr 2004 01:53:03 -0000 1.8
+++ arch/microblaze/mbvanilla.ld 14 May 2004 03:12:41 -0000
@@ -75,7 +75,7 @@
} > OPB
- .data ALIGN (0x4) : {
+ .data ALIGN (0x2000) : {
_sdata = . ;
__data_start = . ;
@@ -157,5 +157,11 @@
_end = . ;
} > OPB
+ .romfs : {
+ _romfs_start = . ;
+ *(.romfs)
+ _romfs_end = . ;
+ } > OPB
+
}