#!/usr/bin/perl # This script patches the ELF program-header-count in a compiled Linux Kernel. # This is needed to enable the kernel to run under IBM Netvista 2200 (8363). # # You need Perl to run this. # usage: ./patch-kernel vmlinux # # Antonio Cardoso Martins (digiplan.pt@gmail.com) # # Version 2008090701 # # use strict; # use warnings; open (FH, "+<$ARGV[0]") or die "Couldn't open $ARGV[0] file for writing: $!"; binmode (FH); seek(FH, 0x2c, 0) or die "Died seeking: $!"; read(FH, my $value, 1) == 1 or die "died reading: $!"; print "ELF program-header-count (offset 0x2c) of $ARGV[0]\n"; print "Before patching was: " . unpack('C', $value) . "\n"; seek(FH, -1, 1) or die "Died seeking: $!"; print FH pack('C', 1); print "The value now is: 1\n"; close FH or die "Died closing: $!";