Search code examples
linuxassemblylinux-kernelarmdisassembly

can't do objdump for linux kernel image


For arm's N1 SDP (system design platform for N1 chip), after I build the software as directed by the Getting Started, I have an output file linux/out/n1sdp/arch/arm64/boot/Image. I saw when I pass the file as kernel to qemu-system-aarch64, linux boot started and ran to some stage. so it is clearly arm64 code. The file starts like this when seen in hex data, ..

00000000: 4d5a 0091 ff3f 4914 0000 0800 0000 0000  MZ...?I.........
00000010: 0040 9b01 0000 0000 0a00 0000 0000 0000  .@..............
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 4152 4d64 4000 0000  ........ARMd@...
00000040: 5045 0000 64aa 0200 0000 0000 0000 0000  PE..d...........
00000050: 0000 0000 a000 0602 0b02 0214 0060 3001  .............`0.
00000060: 00d0 6a00 0000 0000 7850 2501 0010 0000  ..j.....xP%.....
00000070: 0000 0000 0000 0000 0010 0000 0002 0000  ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................ 
00000090: 0040 9b01 0010 0000 0000 0000 0a00 0000  .@..............
000000a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000c0: 0000 0000 0600 0000 0000 0000 0000 0000  ................
000000d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000f0: 0000 0000 0000 0000 2e74 6578 7400 0000  .........text...
00000100: 0060 3001 0010 0000 0060 3001 0010 0000  .`0......`0.....
00000110: 0000 0000 0000 0000 0000 0000 2000 0060  ............ ..`
00000120: 2e64 6174 6100 0000 00d0 6a00 0070 3001  .data.....j..p0.
00000130: 00da 6100 0070 3001 0000 0000 0000 0000  ..a..p0.........
00000140: 0000 0000 4000 00c0 1f20 03d5 1f20 03d5  ....@.... ... ..
00000150: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000160: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000170: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000180: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000190: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
000001a0: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
000001b0: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
000001c0: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
000001d0: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
000001e0: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
000001f0: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000200: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000210: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000220: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000230: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..
00000240: 1f20 03d5 1f20 03d5 1f20 03d5 1f20 03d5  . ... ... ... ..

From the first pattern, I can see it's the linux's start.S code (The first two bytes are meaning-less jump instruction to make the magic pattern "MZ", I learned this before). Here is the problem. I think I've done this in the past before, but when I tried to disassemble it I get error as below.

ckim@chan-ubuntu:~/N1SDP/arm-reference-platforms$ aarch64-none-elf-objdump -d linux/out/n1sdp/arch/arm64/boot/Image aarch64-none-elf-objdump: linux/out/n1sdp/arch/arm64/boot/Image: file format not recognized

What's the correct command to disassemble it?

ADD : I tried disassembling using a web site's service (https://onlinedisassembler.com/odaweb/) and it correctly disassembles it. I can see the mark MZ and the branch instruction. So it should be possible to disassemble it with aarch-none-eabi-objdump I think.:
enter image description here


Solution

  • See the helps in the comments.
    The correct method for disassembling Image file was :

    aarch64-none-elf-objdump -b binary -D Image -m aarch64