Thanks a lot everybody!
My linker script goes like this
Code: Select all
SECTIONS
{
. = 0x10000;
.text : { *(.text) }
.rodata : { *(.rodata) }
.data : { *(.data) }
.bss : { *(.bss) }
}
My compilation is like this
Code: Select all
gcc -c kernel.c
ld -o kernel -TLinker.ld -e main -N kernel.o --verbose
objcopy -R .note -R .comment -S -O binary kernel kernel.000
My ndisasm shows this
Code: Select all
ndisasm kernel.000 -u -o 0x10000
00010000 8D4C2404 lea ecx,[esp+0x4]
00010004 83E4F0 and esp,byte -0x10
00010007 FF71FC push dword [ecx-0x4]
0001000A 55 push ebp
0001000B 89E5 mov ebp,esp
0001000D 51 push ecx
0001000E 83EC10 sub esp,byte +0x10
00010011 C745F400800B00 mov dword [ebp-0xc],0xb8000
00010018 C745F82C000100 mov dword [ebp-0x8],0x1002c
0001001F 8B45F8 mov eax,[ebp-0x8]
00010022 0FB610 movzx edx,byte [eax]
00010025 8B45F4 mov eax,[ebp-0xc]
00010028 8810 mov [eax],dl
0001002A EBFE jmp short 0x1002a
0001002C 48 dec eax
0001002D 45 inc ebp
0001002E 00 db 0x00
My objdump shows this
Code: Select all
objdump --disassemble-all kernel
kernel: file format elf32-i386
Disassembly of section .text:
00010000 <main>:
10000: 8d 4c 24 04 lea 0x4(%esp),%ecx
10004: 83 e4 f0 and $0xfffffff0,%esp
10007: ff 71 fc pushl 0xfffffffc(%ecx)
1000a: 55 push %ebp
1000b: 89 e5 mov %esp,%ebp
1000d: 51 push %ecx
1000e: 83 ec 10 sub $0x10,%esp
10011: c7 45 f4 00 80 0b 00 movl $0xb8000,0xfffffff4(%ebp)
10018: c7 45 f8 2c 00 01 00 movl $0x1002c,0xfffffff8(%ebp)
1001f: 8b 45 f8 mov 0xfffffff8(%ebp),%eax
10022: 0f b6 10 movzbl (%eax),%edx
10025: 8b 45 f4 mov 0xfffffff4(%ebp),%eax
10028: 88 10 mov %dl,(%eax)
1002a: eb fe jmp 1002a <main+0x2a>
Disassembly of section .rodata:
0001002c <.rodata>:
1002c: 48 dec %eax
1002d: 45 inc %ebp
...
Disassembly of section .comment:
00000000 <.comment>:
0: 00 47 43 add %al,0x43(%edi)
3: 43 inc %ebx
4: 3a 20 cmp (%eax),%ah
6: 28 47 4e sub %al,0x4e(%edi)
9: 55 push %ebp
a: 29 20 sub %esp,(%eax)
c: 34 2e xor $0x2e,%al
e: 31 2e xor %ebp,(%esi)
10: 32 20 xor (%eax),%ah
12: 32 30 xor (%eax),%dh
14: 30 37 xor %dh,(%edi)
16: 30 35 30 32 20 28 xor %dh,0x28203230
1c: 52 push %edx
1d: 65 64 20 48 61 and %cl,%fs:%gs:0x61(%eax)
22: 74 20 je 44 <main-0xffbc>
24: 34 2e xor $0x2e,%al
26: 31 2e xor %ebp,(%esi)
28: 32 2d 31 32 29 00 xor 0x293231,%ch
I know everybody out there has done it before and hence fault lies with me, so please help me.
One more think I tried unmounting and then remounting and even tried sync and manual mounting like this
mount /dev/sda4 /mnt/CodeName/ -o sync
But still the changes are not reflected by qemu!