Skip to content

Commit f67c6f3

Browse files
committed
allow passing uncompressed Images to kernelutil
1 parent a834922 commit f67c6f3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

kernelutil.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
var dumpKernel = flag.String("dump_kernel", "", "dump uncompressed kernel to the filename given")
1616
var dumpSymtab = flag.String("dump_symtab", "", "dump symbol table to the filename given")
17+
var isUncompressed = flag.Bool("is_uncompressed", false, "whether the passed zImage is an Image")
1718

1819
// lzop tries decompressing in with lzop, ignoring warnings (i.e. trailing garbage).
1920
func lzop(in []byte) ([]byte, error) {
@@ -102,9 +103,9 @@ func (s *symbol) lds() string {
102103
// 0x00
103104
//
104105
// The code relies on being able to spot an entry in the list of names by a
105-
// well-known and expected name (currently: kallsyms_lookup_name).
106+
// well-known and expected name (currently: cpu_active_mask).
106107
func getSymtab(kernel []byte) ([]*symbol, error) {
107-
const sym = "\x00kallsyms_lookup_name\x00"
108+
const sym = "\x00cpu_active_mask\x00"
108109

109110
// Find the symbol in the string table.
110111
i := bytes.Index(kernel, []byte(sym))
@@ -210,9 +211,14 @@ func main() {
210211
log.Fatalf("Can't read zImage: %v", err)
211212
}
212213

213-
kernel, err := findKernel(zImage)
214-
if err != nil {
215-
log.Fatalf("Kernel not found in zImage: %v", err)
214+
var kernel []byte
215+
if *isUncompressed {
216+
kernel = zImage
217+
} else {
218+
kernel, err = findKernel(zImage)
219+
if err != nil {
220+
log.Fatalf("Kernel not found in zImage: %v", err)
221+
}
216222
}
217223
zImage = nil
218224

0 commit comments

Comments
 (0)