Modules/InitRD - Fixed to not convert files into hex
authorJohn Hodge <[email protected]>
Wed, 23 Nov 2011 05:30:11 +0000 (13:30 +0800)
committerJohn Hodge <[email protected]>
Wed, 23 Nov 2011 05:30:11 +0000 (13:30 +0800)
Modules/Filesystems/InitRD/GenerateInitRD.php
Modules/Filesystems/InitRD/Makefile
Modules/Makefile.tpl

index 8757f0e..af967d5 100644 (file)
@@ -15,7 +15,8 @@ $ARCH = getenv("ARCH");
 
 $gInputFile = $argv[1];
 $gOutputFile = $argv[2];
-$gDepFile = ($argc > 3 ? $argv[3] : false);
+$gOutputLDOptsFile = $argv[3];
+$gDepFile = ($argc > 4 ? $argv[4] : false);
 
 $gDependencies = array();
 
@@ -66,11 +67,13 @@ function hd8($fp)
 }
 
 $inode = 0;
+$gSymFiles = array();
 function ProcessFolder($prefix, $items)
 {
        global  $gOutput, $gDependencies;
        global  $ACESSDIR, $ARCH;
        global  $inode;
+       global  $gSymFiles;
        foreach($items as $i=>$item)
        {
                $inode ++;
@@ -119,10 +122,12 @@ EOF;
                                exit(1);
                        }
                        $size = filesize($path);
-                       
+       
+/*             
+                       $_sym = $prefix."_".$i."_data";
                        $fp = fopen($path, "rb");
                        
-                       $gOutput .= "Uint8 {$prefix}_{$i}_data[] = {\n";
+                       $gOutput .= "Uint8 $_sym[] = {\n";
                        for( $j = 0; $j + 16 < $size; $j += 16 ) {
                                $gOutput .= "\t";
                                $gOutput .= hd8($fp).",".hd8($fp).",";
@@ -141,6 +146,13 @@ EOF;
                        }
                        fclose($fp);
                        $gOutput .= "\n};\n";
+*/
+                       
+//*
+                       $_sym = "_binary_".str_replace(array("/","-","."), "_", $path)."_start";
+                       $gOutput .= "extern Uint8 {$_sym}[];";
+                       $gSymFiles[] = $path;
+//*/
                        $gOutput .= <<<EOF
 tVFS_Node {$prefix}_{$i} = {
        .NumACLs = 1,
@@ -148,7 +160,7 @@ tVFS_Node {$prefix}_{$i} = {
        .Flags = 0,
        .Size = $size,
        .Inode = {$inode},
-       .ImplPtr = {$prefix}_{$i}_data,
+       .ImplPtr = $_sym,
        .Read = InitRD_ReadFile
 };
 
@@ -214,6 +226,15 @@ $fp = fopen($gOutputFile, "w");
 fputs($fp, $gOutput);
 fclose($fp);
 
+// - Create options call
+$fp = fopen($gOutputLDOptsFile, "w");
+fputs($fp, "--format binary\n");
+foreach($gSymFiles as $sym=>$file)
+{
+       fputs($fp, "$file\n");
+//     fputs($fp, "--defsym $sym=_binary_".$sym_filename."_start\n");
+}
+fclose($fp);
 
 if($gDepFile !== false)
 {
index 205ad7b..0c19c0f 100644 (file)
@@ -5,11 +5,12 @@ OBJ = main.o files.$(ARCH).o
 EXTRA = files.c
 NAME = InitRD
 EXTRA = files.$(ARCH).c files.$(ARCH).c.dep
+LDFLAGS += @files.$(ARCH).c.ldopts
 
 -include ../Makefile.tpl
 
 
 files.$(ARCH).c: GenerateInitRD.php files.lst
-       ARCH=$(ARCH) ACESSDIR=$(ACESSDIR) php GenerateInitRD.php files.lst $@ [email protected]
+       ARCH=$(ARCH) ACESSDIR=$(ACESSDIR) php GenerateInitRD.php files.lst $@ $@.ldopts $@.dep
 
 -include files.$(ARCH).c.dep
index 04a0c04..53a059f 100644 (file)
@@ -58,12 +58,12 @@ endif
 ifneq ($(BUILDTYPE),static)
 $(BIN): %.kmd.$(ARCH): $(OBJ)
        @echo --- $(LD) -o $@
-       @$(LD) --allow-shlib-undefined -shared -nostdlib -o $@ $(OBJ) -defsym=DriverInfo=_DriverInfo_$(FULLNAME)
+       @$(LD) --allow-shlib-undefined -shared -nostdlib -o $@ $(OBJ) -defsym=DriverInfo=_DriverInfo_$(FULLNAME) $(LDFLAGS)
        @$(DISASM) $(BIN) > $(BIN).dsm
 else
 $(BIN): %.xo.$(ARCH): $(OBJ)
        @echo --- $(LD) -o $@
-       @$(LD) -r -o $@ $(OBJ)
+       @$(LD) -r -o $@ $(OBJ) $(LDFLAGS)
 endif
 
 obj-$(_SUFFIX)/%.o: %.c Makefile $(CFGFILES)

UCC git Repository :: git.ucc.asn.au