summaryrefslogtreecommitdiff
path: root/extra/scripts
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-03-13 23:43:02 +0000
committerEric Andersen <andersen@codepoet.org>2002-03-13 23:43:02 +0000
commit9121e41f4629b82bf628456b10ab211f5c1e33aa (patch)
tree0a2d539b21952992d899925978a55aa110c4e3b6 /extra/scripts
parent94e5ab630be58fa6d008fbfa735492bd6ce2a568 (diff)
Build our own crti.o and crtn.o with a cross arch method that I
can live with much better the what glibc does. -Erik
Diffstat (limited to 'extra/scripts')
-rwxr-xr-xextra/scripts/initfini.pl140
1 files changed, 140 insertions, 0 deletions
diff --git a/extra/scripts/initfini.pl b/extra/scripts/initfini.pl
new file mode 100755
index 000000000..9a5c3ba09
--- /dev/null
+++ b/extra/scripts/initfini.pl
@@ -0,0 +1,140 @@
+#!/usr/bin/perl
+
+use strict;
+use Getopt::Long;
+
+my($initfini) = "initfini.s";
+my($crti) = "crti.S";
+my($crtn) = "crtn.S";
+my($alignval) = "";
+my($endp) = 0;
+my($end) = 0;
+my($omitcrti) = 0;
+my($omitcrtn) = 0;
+my($line);
+
+# Get commandline parameters
+Getopt::Long::Configure("no_ignore_case", "bundling");
+&GetOptions( "initfini=s" => \$initfini,
+ "crti=s" => \$crti,
+ "crtn=s" => \$crtn,
+ );
+
+chomp($initfini);
+chomp($crti);
+chomp($crtn);
+
+
+if ($initfini) {
+ open(INITFINI,"<$initfini") or
+ die "(fatal) Can't open $initfini$!";
+} else {
+ die "(fatal) Please give me an --initfini argument$!";
+}
+while($line = <INITFINI>) {
+ if ($line =~ /^\w\.endp/) {
+ $endp=1;
+ next;
+ }
+ if ($line =~ /^\w\.end/) {
+ $end=1;
+ next;
+ }
+ if ($line =~ /\w\.align\(.*\)/) {
+ $alignval=$1;
+ next;
+ }
+}
+close(INITFINI);
+
+
+
+
+
+if ($initfini) {
+ open(INITFINI,"<$initfini") or
+ die "(fatal) Can't open $initfini$!";
+} else {
+ die "(fatal) Please give me an --initfini argument$!";
+}
+
+if ($crti) {
+ open(CRTI,">$crti") or
+ die "(fatal) Can't open $crti$!";
+} else {
+ die "(fatal) Please give me a --asm argument$!";
+}
+if ($crtn) {
+ open(CRTN,">$crtn") or
+ die "(fatal) Can't open $crtn$!";
+} else {
+ die "(fatal) Please give me a --asm argument$!";
+}
+
+while(<INITFINI>) {
+ if (/HEADER_ENDS/) {
+ $omitcrti = 1;
+ $omitcrtn = 1;
+ next;
+ }
+ if (/PROLOG_BEGINS/) {
+ $omitcrti = 0;
+ next;
+ }
+ if (/PROLOG_ENDS/) {
+ $omitcrti = 1;
+ next;
+ }
+ if (/EPILOG_BEGINS/) {
+ $omitcrtn = 0;
+ next;
+ }
+ if (/EPILOG_ENDS/) {
+ $omitcrtn = 1;
+ next;
+ }
+ if (/TRAILER_BEGINS/) {
+ $omitcrti = 0;
+ $omitcrtn = 0;
+ next;
+ }
+ if (/END_INIT/) {
+ if ($endp) {
+ s/END_INIT/.endp _init/;
+ } else {
+ if($end) {
+ s/END_INIT/.end _init/;
+ } else {
+ s/END_INIT//;
+ }
+ }
+ }
+ if (/END_FINI/) {
+ if ($endp) {
+ s/END_FINI/.endp _fini/;
+ } else {
+ if($end) {
+ s/END_FINI/.end _fini/;
+ } else {
+ s/END_FINI//;
+ }
+ }
+ }
+ if (/ALIGN/) {
+ if($alignval) {
+ s/ALIGN/.align $alignval/;
+ } else {
+ s/ALIGN//;
+ }
+ }
+ if (!$omitcrti) {
+ print CRTI;
+ }
+ if (!$omitcrtn) {
+ print CRTN;
+ }
+}
+close(INITFINI);
+close(CRTI);
+close(CRTN);
+