I'm sorry I can't get this.
Here is some code.
.text
9: mov $TTYS0_LSR, %dx
inb %dx, %al
test $0x20, %al
je 9b
mov $TTYS0_TBR, %dx
mov $'A', %al
outb %al, %dx
jmp 9b
Here is the assembly of the code:
gcc -o testserial.o -c testserial.S
ld -T elfImage.lds -o testserial.elf testserial.o
Here is the file I get:
-rwx------ 1 rminnich CIC-ACL 8651 Jan 25 14:50 testserial.elf
here is the objdump of that ./elf file:
testserial.elf: file format elf32-i386
testserial.elf
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x00010000
Program Header:
LOAD off 0x00001000 vaddr 0x00010000 paddr 0x00010000 align 2**12
filesz 0x00000014 memsz 0x00001000 flags rwx
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000014 00010000 00010000 00001000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00010000 00010000 00001000 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00010000 00010000 00002000 2**2
ALLOC
SYMBOL TABLE:
00010000 l d .text 00000000
00010000 l d .data 00000000
00010000 l d .bss 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
00010000 g O *ABS* 00000000 _text
Now, it looks to me like I have sections that start at 0x10000, the
assembly seems innocuous, and now I run mkelfImage on it:
bash-2.04$ bin/mkelfImage --kernel=9load/testserial.elf
Running gcc -O2 -DDEFAULT_ROOT_DEV='((unsigned short)((0x3<<16)| 0))'
-DDEFAULT_COMMAND_LINE='""' -c
/users/rminnich/src/bios/mkelf/share/mkelfImage/elf32-i386/convert_params.c
-o
/am/mother-v2-e5/vol/vol0/u0/rminnich/src/bios/mkelf/convert_params_28428.o
/users/rminnich/src/bios/mkelf/share/mkelfImage/elf32-i386/convert_params.c:
In function `convert_params':
/users/rminnich/src/bios/mkelf/share/mkelfImage/elf32-i386/convert_params.c:1513:
warning: initialization makes pointer from integer without a cast
Running gcc -O2 -DDEFAULT_ROOT_DEV='((unsigned short)((0x3<<16)| 0))'
-DDEFAULT_COMMAND_LINE='""' -c
/users/rminnich/src/bios/mkelf/share/mkelfImage/elf32-i386/head.S -o
/am/mother-v2-e5/vol/vol0/u0/rminnich/src/bios/mkelf/head_28428.o
Running ld -o elfImage -T
/users/rminnich/src/bios/mkelf/share/mkelfImage/elf32-i386/elfImage.lds
/am/mother-v2-e5/vol/vol0/u0/rminnich/src/bios/mkelf/kernel_piggy_28428.o
/am/mother-v2-e5/vol/vol0/u0/rminnich/src/bios/mkelf/ramdisk_piggy_28428.o
/am/mother-v2-e5/vol/vol0/u0/rminnich/src/bios/mkelf/convert_params_28428.o
/am/mother-v2-e5/vol/vol0/u0/rminnich/src/bios/mkelf/head_28428.o
to create:
elfImage: file format elf32-i386
elfImage
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x00011020
Program Header:
LOAD off 0x00001000 vaddr 0x00010000 paddr 0x00010000 align 2**12
filesz 0x000016b8 memsz 0x00005960 flags rwx
LOAD off 0x00003000 vaddr 0x00091000 paddr 0x00091000 align 2**12
filesz 0x00000028 memsz 0x00000028 flags rwx
LOAD off 0x00004000 vaddr 0x00100000 paddr 0x00100000 align 2**12
filesz 0x00000014 memsz 0x00000014 flags rw-
LOAD off 0x00005000 vaddr 0x00800000 paddr 0x00800000 align 2**12
filesz 0x00000000 memsz 0x00000000 flags rw-
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00001390 00010000 00010000 00001000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .rodata 00000310 00011390 00011390 00002390 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .data 00000018 000116a0 000116a0 000026a0 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .bss 000042a8 000116b8 000116b8 000026b8 2**5
ALLOC
4 .nokill 00000028 00091000 00091000 00003000 2**0
CONTENTS, ALLOC, LOAD, CODE
5 .kernel 00000014 00100000 00100000 00004000 2**0
CONTENTS, ALLOC, LOAD, DATA
6 .ramdisk 00000000 00800000 00800000 00005000 2**0
CONTENTS, ALLOC, LOAD, DATA
7 .comment 00000036 00000000 00000000 00005000 2**0
CONTENTS, READONLY
8 .note 00000014 00000000 00000000 00005036 2**0
CONTENTS, READONLY
(symbols not included)
OK, that doesn't look too bad.
If I run it:
(ELF)... done
1
hello world
Firmware type: linuxBIOS
EXT_MEM_K=0x0000FC00
ALT_MEM_K=0x0001FC00
0x00000000 0x00000055
0x00000001 0x00000089
0x00000002 0x000000E5
0x00000003 0x000000BA
0x00000004 0x000000FD
0x00000005 0x00000003
0x00000006 0x00000000
0x00000007 0x00000000
0x00000008 0x000000EC
0x00000009 0x00000083
0x0000000A 0x000000E0
0x0000000B 0x00000020
0x0000000C 0x00000074
0x0000000D 0x000000FA
0x0000000E 0x000000BA
0x0000000F 0x000000F8
0x00000010 0x00000003
0x00000011 0x00000000
0x00000012 0x00000000
0x00000013 0x0000008A
0x00000014 0x00000045
0x00000015 0x00000008
0x00000016 0x000000EE
0x00000017 0x00000083
0x00000018 0x000000C2
0x00000019 0x00000005
0x0000001A 0x00000089
0x0000001B 0x000000F6
0x0000001C 0x000000EC
0x0000001D 0x00000083
0x0000001E 0x000000E0
0x0000001F 0x00000040
2
2
2
�
That dump is a dump 0f 0x10000 where I expect the code to land. It's the
wrong data.
Any hint on what I'm doing wrong?
thanks
ron