Date: Sat, 16 Dec 2000 16:44:32 -0800 From: Marcel Moolenaar <marcel@cup.hp.com> To: arch@FreeBSD.org Subject: A perlified gensetdefs Message-ID: <3A3C0C70.848F5057@cup.hp.com>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------34B57FFE194884664E44F09C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
In order to reduce the number of ELF specific tools, I rewrote
gensetdefs(1) in perl, using objdump(1). When put in /sys/kern, we
further reduce the chicken/egg problem when building a kernel. This
definitely helps porting FreeBSD.
take a look at it and let me know if it's a good idea or not. Any perl
specific improvements, including style, are welcomed as well. I'm no
Perl programmer by any means...
--
Marcel Moolenaar
mail: marcel@cup.hp.com / marcel@FreeBSD.org
tel: (408) 447-4222
--------------34B57FFE194884664E44F09C
Content-Type: application/x-perl;
name="gensetdefs.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="gensetdefs.pl"
#!/usr/bin/perl
my %sz = ();
my $ptrsz = 0;
my $objdump = $ENV{OBJDUMP};
$objdump =~ s/^$/objdump/;
foreach $objfile (@ARGV) {
open(SECTION, "$objdump -h $objfile |");
while($line = <SECTION>) {
($idx, $name, $size, $vma, $lma, $ofs, $align) = split(" ", $line);
if ($name =~ /^.set./) {
$name =~ s/^.set.//;
$sz{$name} = $sz{$name} + eval "0x$size";
if ($ptrsz < eval $align) {
$ptrsz = eval $align;
}
}
}
close SECTION;
}
open(SETDEFS_H, "| sort > setdefs.h");
while (($name, $size) = each %sz) {
my $elts = $size / $ptrsz;
print SETDEFS_H "DEFINE_SET($name, $elts);\n";
}
close SETDEFS_H;
open(SETDEF0_C, "> setdef0.c");
print SETDEF0_C "/* THIS FILE IS GENERATED, DO NOT EDIT. */\n\n";
print SETDEF0_C "#define DEFINE_SET(set, count)\t\t\t\\\n";
print SETDEF0_C "__asm__(\".section .set.\" #set \",\\\"aw\\\"\");\t\\\n";
print SETDEF0_C "__asm__(\".globl \" #set);\t\t\t\\\n";
print SETDEF0_C "__asm__(\".type \" #set \",\@object\");\t\t\\\n";
print SETDEF0_C "__asm__(\".p2align 3\");\t\t\t\t\\\n";
print SETDEF0_C "__asm__(#set \":\");\t\t\t\t\\\n";
print SETDEF0_C "__asm__(\".quad \" #count);\t\t\t\\\n";
print SETDEF0_C "__asm__(\".previous\")\n\n";
print SETDEF0_C "#include \"setdefs.h\"\n";
close SETDEF0_C;
open(SETDEF1_C, "> setdef1.c");
print SETDEF1_C "/* THIS FILE IS GENERATED, DO NOT EDIT. */\n\n";
print SETDEF1_C "#define DEFINE_SET(set, count)\t\t\t\\\n";
print SETDEF1_C "__asm__(\".section .set.\" #set \",\\\"aw\\\"\");\t\\\n";
print SETDEF1_C "__asm__(\".quad 0\");\t\t\t\t\\\n";
print SETDEF1_C "__asm__(\".previous\")\n\n";
print SETDEF1_C "#include \"setdefs.h\"\n";
close SETDEF1_C;
--------------34B57FFE194884664E44F09C--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A3C0C70.848F5057>
