febootstrap*.8
febootstrap*.txt
febootstrap-*.tar.gz
+helper/ext2init.S
helper/febootstrap-supermin-helper
helper/init
html/febootstrap-supermin-helper.8.html
# http://www.doof.me.uk/2010/05/07/cute-objcopy-hack/
ELF_DEFAULT_ARCH = $(shell $(srcdir)/elf-default-arch | gawk '{ print $$1 }')
DEFAULT_ARCH = $(shell $(srcdir)/elf-default-arch | gawk '{ print $$2 }')
-ext2init.o: init
+
+CLEANFILES = ext2init.S
+
+ext2init.o: ext2init.S
+ $(CC) -o $@ -c $<
+
+ext2init.S: init
strip --strip-all $<
@file $< | grep -isq static || \
(echo "*** error: init is not staticly linked"; exit 1)
- objcopy -I binary -B $(DEFAULT_ARCH) -O $(ELF_DEFAULT_ARCH) $< $@
+ ./bin2s.pl $< $@
man_MANS = \
febootstrap-supermin-helper.8
EXTRA_DIST = \
febootstrap-supermin-helper.8 \
febootstrap-supermin-helper.pod \
- elf-default-arch
+ bin2s.pl
--- /dev/null
+#!/usr/bin/perl
+
+# This script creates a source file for the GNU assembler which shuold
+# result in an object file equivalent to that of
+#
+# objcopy -I binary -B $(DEFAULT_ARCH) -O $(ELF_DEFAULT_ARCH) <in> <out>
+
+use strict;
+use warnings;
+
+die "usage: $0 <in> <out>\n" if @ARGV != 2;
+
+my ($infile, $outfile) = @ARGV;
+my ($buf, $i, $sz);
+open my $ifh, '<', $infile or die "open $infile: $!";
+open my $ofh, '>', $outfile or die "open $outfile: $!";
+
+print $ofh <<"EOF";
+/* This file has been automatically generated from $infile by $0 */
+
+\t.globl\t_binary_${infile}_start
+\t.globl\t_binary_${infile}_end
+\t.globl\t_binary_${infile}_size
+
+\t.section\t.data
+_binary_${infile}_start:
+EOF
+
+$sz = 0;
+while ( $i = read $ifh, $buf, 12 ) {
+ print $ofh "\t.byte\t"
+ . join( ',', map { sprintf '0x%02x', ord $_ } split //, $buf ) . "\n";
+ $sz += $i;
+}
+die "read $infile (at offset $sz): $!\n" if not defined $i;
+close $ifh;
+
+print $ofh <<"EOF";
+
+_binary_${infile}_end:
+
+\t.equ _binary_${infile}_size, $sz
+EOF
+
+close $ofh;
+++ /dev/null
-#!/bin/sh -
-# Copyright (C) 2010 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-# Calculate the default ELF object architecture for this format.
-# There doesn't seem to be an easy way to derive this from binutils,
-# so instead we hard code it.
-
-case $(uname -m) in
- i[3456]86) echo "elf32-i386 i386" ;;
- x86_64) echo "elf64-x86-64 i386" ;;
- s390) echo "elf32-s390 s390:31-bit" ;;
- s390x) echo "elf64-s390 s390:31-bit" ;;
- ppc) echo "elf32-powerpc powerpc" ;;
- ppc64) echo "elf64-powerpc powerpc" ;;
- *)
- echo "This architecture is not recognized. Please update helper/elf-default-arch."
- exit 1
-esac