3 # This script creates a source file for the GNU assembler which shuold
4 # result in an object file equivalent to that of
6 # objcopy -I binary -B $(DEFAULT_ARCH) -O $(ELF_DEFAULT_ARCH) <in> <out>
11 die "usage: $0 <in> <out>\n" if @ARGV != 2;
13 my ($infile, $outfile) = @ARGV;
15 open my $ifh, '<', $infile or die "open $infile: $!";
16 open my $ofh, '>', $outfile or die "open $outfile: $!";
19 /* This file has been automatically generated from $infile by $0 */
21 \t.globl\t_binary_${infile}_start
22 \t.globl\t_binary_${infile}_end
23 \t.globl\t_binary_${infile}_size
26 _binary_${infile}_start:
30 while ( $i = read $ifh, $buf, 12 ) {
31 print $ofh "\t.byte\t"
32 . join( ',', map { sprintf '0x%02x', ord $_ } split //, $buf ) . "\n";
35 die "read $infile (at offset $sz): $!\n" if not defined $i;
40 _binary_${infile}_end:
42 \t.equ _binary_${infile}_size, $sz