l4-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

create_archive_ia32.pl (ddf)


From: Etienne Robillard
Subject: create_archive_ia32.pl (ddf)
Date: Fri, 18 Jun 2004 11:29:44 -0400
User-agent: Mozilla Thunderbird 0.6 (X11/20040615)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

It's nice to see that the l4-hurd is still 'work-in-progress' :)

Here is a unified diff for create_archive_ia32.pl.

I've added the ability to retrieve OUTPUT_FORMAT|OUTPUT_ARCH from the
linker, but as a side-effect, it might not work for every systems,
depending on whether your GNU ld returns OUTPUT_FORMAT with some \"foo\"
separators or not.

Also, I've changed the output filename to return
per-architecture ("ddf-archive-script-$ARCH") names instead of
"ddf-archive-script".

Regards,
Etienne
-----BEGIN PGP SIGNATURE-----

iD8DBQFA0wpnfhO/J4JSDfYRAvarAKDluqqO2Z5lmTlq6DhFXQIkZ5DMTACeKYRb
+GsrMjmpswmVPlCakhUxiVQ=
=AZFM
-----END PGP SIGNATURE-----
--- create_archive_ia32.pl      Tue Apr  6 08:59:58 2004
+++ tmp/create_archive_ia32.pl  Fri Jun 18 11:12:41 2004
@@ -20,17 +20,38 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
 use strict;
+# Maintain backward compatibility
+use 5.004;
 
-my $file_name;
-my $ARCHFILE;
-my $arch_file_name = "ddf-archive-script";
+# Define the target architecture here (e.g: 'i386')
+my $ARCH       =       q{i386};
+my $arch_file_name = "ddf-archive-script-$ARCH";
 
+# See perlsub: Temporary values via local()
+local *ARCHFILE;
 open(ARCHFILE, ">$arch_file_name") || die "cannot create $arch_file_name: $!";
 
 # These formats need to be extracted from the default linker script
 # that can be retrieved from the ld --verbose output. 
-print ARCHFILE "OUTPUT_FORMAT(\"elf32-i386\")\n";
-print ARCHFILE "OUTPUT_ARCH(i386)\n\n";
+
+my ($OUTPUT_FORMAT,$OUTPUT_ARCH) = '';
+
+my @tmp                = grep(/$ARCH/, `ld --verbose`);
+$OUTPUT_FORMAT         = join('',$tmp[1],$tmp[2]);
+
+# Returns "argument not numeric" when warnings are enabled.    
+#$OUTPUT_ARCH  = substr($tmp[3],$OUTPUT_FORMAT);
+
+$OUTPUT_ARCH   = $tmp[3];
+
+# OUTPUT_FORMAT not the same from host to host;
+# the native GNU ld 2.12.1 on FreeBSD dont care much 
+# about the \"foo\" separator..
+
+#print ARCHFILE "OUTPUT_FORMAT(\"elf32-i386\")\n";
+#print ARCHFILE "OUTPUT_ARCH(i386)\n\n";
+
+print ARCHFILE $OUTPUT_FORMAT,$OUTPUT_ARCH, "\n\n";
 
 # This must be defined to the minimal page size on the system.
 print ARCHFILE "page_size = 0x1000;\n\n";
@@ -46,7 +67,7 @@
 print ARCHFILE "}\n\n";
 
 # One for each input file.
-foreach $file_name (@ARGV) {
+foreach my $file_name (@ARGV) {
     my @name = split("/", $file_name);
     print ARCHFILE "INPUT(\"$name[-1]\")\n";
 }
@@ -56,17 +77,32 @@
 print ARCHFILE "SECTIONS\n";
 print ARCHFILE "{\n";
 print ARCHFILE "  . = SIZEOF_HEADERS;\n\n";
-foreach $file_name (@ARGV) {
+foreach my $file_name (@ARGV) {
     my @name = split("/", $file_name);
     print ARCHFILE "  $name[-1] ALIGN(page_size): { \"$name[-1]\" }\n"; 
 }
 print ARCHFILE "\n";
-  # This moves the ELF section headers out of the last page of the
-  # last file as a precaution.  Might not be necessary. 
+# This moves the ELF section headers out of the last page of the
+# last file as a precaution.  Might not be necessary. 
 print ARCHFILE "  foo ALIGN(page_size): { BYTE(1) }\n";
 
-  #  Put all sections into the file_list segment. 
+#  Put all sections into the file_list segment. 
 print ARCHFILE "  :file_list\n";
 print ARCHFILE "}\n";
 
 close(ARCHFILE) || die "can't close  $arch_file_name: $!";
+
+1;
+__END__;
+
+=head1 NAME 
+
+create_archive_ia32.pl - perl script for creating a boot archive.
+
+=head1 SYNOPSIS 
+
+       <define this package methods and constructors into this block>
+
+=head1 DESCRIPTION 
+
+       <small and updated description of what this package should do>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]