AMOS HELP

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
gmoney
Member
Member
Posts: 106
Joined: Mon Jan 03, 2005 12:00 am
Location: Texas, Usa

AMOS HELP

Post by gmoney »

im having a problem compiling some source code. to start off my env is windows xp with djgpp as the compiler and eclipse as a ide. via cvs i recieved the AMOS project and compiled it. everything work 'cept the user apps. the original map looks like this
init.map

Code: Select all

    1 Archive member included because of file (symbol)
    2 
    3 ../../../bin/lib/libc.a(amos.o)
    4                               init.o (_exit)
    5 ../../../bin/lib/libc.a(stdio.o)
    6                               init.o (_printf)
    7 ../../../bin/lib/libc.a(string.o)
    8                               ../../../bin/lib/libc.a(stdio.o) (_strlen)
    9 
   10 Memory Configuration
   11 
   12 Name             Origin             Length             Attributes
   13 *default*        0x00000000         0xffffffff
   14 
   15 Linker script and memory map
   16 
   17                 0x00000000                phys = 0x0
   18                 0x10000000                virt = 0x10000000
   19 
   20 .text           0x10000000      0xa50 load address 0x00000000
   21  *(.text)
   22  .text          0x10000000      0x130 init.o
   23                 0x100000ca                _realmain
   24                 0x10000000                _main
   25  .text          0x10000130      0x2b0 ../../../bin/lib/libc.a(amos.o)
   26                 0x10000335                _morecore
   27                 0x10000392                _sleep
   28                 0x100002e9                _mount
   29                 0x1000035b                _spawn
   30                 0x10000130                _open
   31                 0x10000167                _clone
   32                 0x100002b7                _list
   33                 0x10000288                _copy
   34                 0x1000023f                _delete
   35                 0x100001e5                _seek
   36                 0x100003b8                _wait
   37                 0x1000039e                _wake
   38                 0x10000259                _rename
   39                 0x10000225                _create
   40                 0x1000031b                _unmount
   41                 0x10000205                _control
   42                 0x100001b3                _write
   43                 0x10000378                _kill
   44                 0x10000181                _read
   45                 0x1000034f                _exit
   46                 0x1000014d                _close
   47  .text          0x100003e0      0x470 ../../../bin/lib/libc.a(stdio.o)
   48                 0x10000804                _putchar
   49                 0x10000787                _get
   50                 0x100003e0                _printf_putuint
   51                 0x10000822                _puts
   52                 0x10000504                _printf_puthex
   53                 0x100004aa                _printf_putint
   54                 0x1000076a                _getch
   55                 0x100005ac                _print
   56                 0x10000751                _printf
   57  .text          0x10000850      0x200 ../../../bin/lib/libc.a(string.o)
   58                 0x10000892                _strcmp
   59                 0x1000091c                _strncpy
   60                 0x100009de                _memcpy
   61                 0x100009b7                _memset
   62                 0x10000904                _strcpy
   63                 0x10000a04                _memcmp
   64                 0x100008b2                _strncmp
   65                 0x10000869                _strrchr
   66                 0x10000850                _strlen
   67                 0x1000095d                _strstr
   68                 0x10000a50                . = ALIGN (0x4)
   69  *(.data)
   70                 0x10000a50                . = ALIGN (0x4)
   71  *(COMMON)
   72                 0x10000a50                . = ALIGN (0x4)
   73  *(.bss)
   74                 0x10000a50                . = ALIGN (0x4)
   75 LOAD init.o
   76 LOAD ../../../bin/lib/libc.a
   77 OUTPUT(../../../bin/apps/init.bin binary)
   78 
   79 .comment
link.ld

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(_main)
phys = 0x00000000;
virt = 0x10000000;
SECTIONS
{
  .text virt : AT( phys )
  {
    *(.text)
    . = ALIGN(4096);
    *(.data)
    . = ALIGN(4096);
    *(COMMON)
    . = ALIGN(4096);
  	*(.bss)
    . = ALIGN(4096);
  }
}

makefile

Code: Select all

MAKEFILE=Makefile

TARGET_BIN=init.bin

TARGET_DIR=../../../bin/apps/

INCLUDE_DIR=../../../include/

AMOS_LIBC=../../../bin/lib/libc.a

CC=gcc
LD=ld
RM=del

LDFLAGS=-T ../apps.ld -s -nostdlib -Map $(TARGET_DIR)init.map
CCFLAGS=-Wall -O -nostdlib -fno-builtin -nostdinc -I $(INCLUDE_DIR)

OBJ=init.o
	
all: $(TARGET_BIN)

$(TARGET_BIN): $(OBJ)
	$(LD) $(LDFLAGS) -o $(TARGET_DIR)$(TARGET_BIN) $(OBJ) $(AMOS_LIBC)

%.o: %.c
	$(CC) $(CCFLAGS) -c -o $@ $<

clean:
	$(RM) *.o

afterwards
init.map

Code: Select all

Archive member included because of file (symbol)

../../../bin/lib/libc.a(stdio.o)
                              init.o (_printf)
../../../bin/lib/libc.a(amos.o)
                              ../../../bin/lib/libc.a(stdio.o) (_read)
../../../bin/lib/libc.a(string.o)
                              ../../../bin/lib/libc.a(stdio.o) (_strlen)

Discarded input sections

 .comment       0x00000000        0x0 init.o
 .comment       0x00000000        0x0 ../../../bin/lib/libc.a(stdio.o)
 .comment       0x00000000        0x0 ../../../bin/lib/libc.a(amos.o)
 .comment       0x00000000        0x0 ../../../bin/lib/libc.a(string.o)

Memory Configuration

Name             Origin             Length             Attributes
*default*        0x00000000         0xffffffff

Linker script and memory map

                0x00000000                phys = 0x0
                0x10000000                virt = 0x10000000

.text           0x10000000     0x1000 load address 0x00000000
 *(.text)
 .text          0x10000000       0x90 init.o
                0x1000003e                _realmain
                0x10000055                _main
 .text          0x10000090      0x440 ../../../bin/lib/libc.a(stdio.o)
                0x10000090                _putchar
                0x1000017e                _get
                0x10000216                _printf_putuint
                0x100000ae                _puts
                0x100000dd                _printf_puthex
                0x100002c9                _printf_putint
                0x100001fa                _getch
                0x1000030f                _print
                0x100004a4                _printf
 .text          0x100004d0      0x270 ../../../bin/lib/libc.a(amos.o)
                0x10000695                _morecore
                0x100006f2                _sleep
                0x10000655                _mount
                0x100006bb                _spawn
                0x100004d0                _open
                0x10000507                _clone
                0x10000627                _list
                0x10000604                _copy
                0x100005c7                _delete
                0x1000056d                _seek
                0x10000718                _wait
                0x100006fe                _wake
                0x100005e1                _rename
                0x100005ad                _create
                0x1000067b                _unmount
                0x1000058d                _control
                0x10000547                _write
                0x100006d8                _kill
                0x10000521                _read
                0x100006af                _exit
                0x100004ed                _close
 .text          0x10000740      0x200 ../../../bin/lib/libc.a(string.o)
                0x10000780                _strcmp
                0x1000081d                _strncpy
                0x10000875                _memcpy
                0x10000852                _memset
                0x100007fe                _strcpy
                0x1000089b                _memcmp
                0x100007a8                _strncmp
                0x10000757                _strrchr
                0x10000740                _strlen
                0x100008dd                _strstr
                0x10001000                . = ALIGN (0x1000)
 *fill*         0x10000940      0x6c0 00
 *(.data)
 .data          0x10001000        0x0 init.o
 .data          0x10001000        0x0 ../../../bin/lib/libc.a(stdio.o)
 .data          0x10001000        0x0 ../../../bin/lib/libc.a(amos.o)
 .data          0x10001000        0x0 ../../../bin/lib/libc.a(string.o)
                0x10001000                . = ALIGN (0x1000)
 *(COMMON)
                0x10001000                . = ALIGN (0x1000)
 *(.bss)
 .bss           0x10001000        0x0 init.o
 .bss           0x10001000        0x0 ../../../bin/lib/libc.a(stdio.o)
 .bss           0x10001000        0x0 ../../../bin/lib/libc.a(amos.o)
 .bss           0x10001000        0x0 ../../../bin/lib/libc.a(string.o)
                0x10001000                . = ALIGN (0x1000)
LOAD init.o
LOAD ../../../bin/lib/libc.a
OUTPUT(../../../bin/apps/init.bin binary)

.comment
and this is what bochs output is

Code: Select all

ALIEN 0.6.0
--------------------------------------------------------------------------[1]---
[KERNEL] KERNEL ALIVE
[KERNEL] [PCI] Intel 82371AB PIIX4 ACPI (Bridge device)
[KERNEL] [PCI] Intel 82371SB PIIX3 IDE (Mass storage controller)
[KERNEL] [PCI] Intel 82371SB PIIX3 ISA (Bridge device)
[KERNEL] [PCI] Intel 82441FX Natoma (Bridge device)
[KERNEL] Page Fault at CS:EIP 0x1B:0x10000001 Address 0x0
[KERNEL]     CS:0x1B EIP:0x10000001
[KERNEL]     DS:0x23 ES:0x23 FS:0x23 GS:0x23
[KERNEL]     EDI:0x0 ESI:0x0 EBP:0x0 ESP:0xD000CFF0
[KERNEL]     EBX:0x0 EDX:0x0 ECX:0x0 EAX:0x0
[KERNEL]     EFLAGS:0x10202  SS0:0x23 ESP0:0x20000FFC
ß
If you have any suggestions let me know
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: AMOS HELP

Post by Troy Martin »

/bin/lib/libc.a is part of the host OS's C compiler. It's part of the C library, so unless this AMOS has libc ported to it, there's part of your problem.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
gmoney
Member
Member
Posts: 106
Joined: Mon Jan 03, 2005 12:00 am
Location: Texas, Usa

Re: AMOS HELP

Post by gmoney »

i thought the ld command -nostdlib took care of that
gmoney
Member
Member
Posts: 106
Joined: Mon Jan 03, 2005 12:00 am
Location: Texas, Usa

Re: AMOS HELP

Post by gmoney »

i changed the name of the lib from libc to libkern, recompiled the whole project and same results
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: AMOS HELP

Post by Combuster »

start with putting .rodata in your linker script.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
gmoney
Member
Member
Posts: 106
Joined: Mon Jan 03, 2005 12:00 am
Location: Texas, Usa

Re: AMOS HELP

Post by gmoney »

its not a elf file so why do i need .rodata section in a flat binary?
gmoney
Member
Member
Posts: 106
Joined: Mon Jan 03, 2005 12:00 am
Location: Texas, Usa

Re: AMOS HELP

Post by gmoney »

i put the .rodata section in the linker script and same thing

Code: Select all

Archive member included because of file (symbol)

../../../bin/lib/libc.a(stdio.o)
                              init.o (_printf)
../../../bin/lib/libc.a(amos.o)
                              ../../../bin/lib/libc.a(stdio.o) (_read)
../../../bin/lib/libc.a(string.o)
                              ../../../bin/lib/libc.a(stdio.o) (_strlen)

Discarded input sections

 .comment       0x00000000        0x0 init.o
 .comment       0x00000000        0x0 ../../../bin/lib/libc.a(stdio.o)
 .comment       0x00000000        0x0 ../../../bin/lib/libc.a(amos.o)
 .comment       0x00000000        0x0 ../../../bin/lib/libc.a(string.o)

Memory Configuration

Name             Origin             Length             Attributes
*default*        0x00000000         0xffffffff

Linker script and memory map

                0x00000000                phys = 0x0
                0x10000000                virt = 0x10000000

.text           0x10000000      0x910 load address 0x00000000
 *(.text)
 .text          0x10000000       0x90 init.o
                0x1000003e                _realmain
                0x10000055                _main
 .text          0x10000090      0x440 ../../../bin/lib/libc.a(stdio.o)
                0x10000090                _putchar
                0x10000180                _get
                0x10000219                _printf_putuint
                0x100000ae                _puts
                0x100000e0                _printf_puthex
                0x100002d7                _printf_putint
                0x100001fc                _getch
                0x1000031d                _print
                0x1000049a                _printf
 .text          0x100004d0      0x270 ../../../bin/lib/libc.a(amos.o)
                0x10000695                _morecore
                0x100006f2                _sleep
                0x10000655                _mount
                0x100006bb                _spawn
                0x100004d0                _open
                0x10000507                _clone
                0x10000627                _list
                0x10000604                _copy
                0x100005c7                _delete
                0x1000056d                _seek
                0x10000718                _wait
                0x100006fe                _wake
                0x100005e1                _rename
                0x100005ad                _create
                0x1000067b                _unmount
                0x1000058d                _control
                0x10000547                _write
                0x100006d8                _kill
                0x10000521                _read
                0x100006af                _exit
                0x100004ed                _close
 .text          0x10000740      0x1d0 ../../../bin/lib/libc.a(string.o)
                0x10000781                _strcmp
                0x10000803                _strncpy
                0x1000085b                _memcpy
                0x10000838                _memset
                0x100007eb                _strcpy
                0x10000881                _memcmp
                0x100007a3                _strncmp
                0x10000759                _strrchr
                0x10000740                _strlen
                0x100008b9                _strstr
                0x10000910                . = ALIGN (0x4)
 *(.data)
 .data          0x10000910        0x0 init.o
 .data          0x10000910        0x0 ../../../bin/lib/libc.a(stdio.o)
 .data          0x10000910        0x0 ../../../bin/lib/libc.a(amos.o)
 .data          0x10000910        0x0 ../../../bin/lib/libc.a(string.o)
                0x10000910                . = ALIGN (0x4)
 *(.rodata)
                0x10000910                . = ALIGN (0x4)
 *(.bss)
 .bss           0x10000910        0x0 init.o
 .bss           0x10000910        0x0 ../../../bin/lib/libc.a(stdio.o)
 .bss           0x10000910        0x0 ../../../bin/lib/libc.a(amos.o)
 .bss           0x10000910        0x0 ../../../bin/lib/libc.a(string.o)
                0x10000910                . = ALIGN (0x4)
 *(COMMON)
                0x10000910                . = ALIGN (0x4)
LOAD init.o
LOAD ../../../bin/lib/libc.a
OUTPUT(../../../bin/apps/init.bin binary)

.comment
i want this

Code: Select all

.text           0x10000000      0x910 load address 0x00000000
 *(.text)
 .text          0x10000000       0x90 init.o
                0x1000003e                _realmain
                0x10000055                _main
to say this

Code: Select all

.text           0x10000000      0x910 load address 0x00000000
 *(.text)
 .text          0x10000000       0x90 init.o
                0x1000003e                _realmain
                0x10000000                _main
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: AMOS HELP

Post by Troy Martin »

AFAIK, you make 0x10000055 be 0x10000000, the labels (and their respective offsets) are stuck where they are.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
gmoney
Member
Member
Posts: 106
Joined: Mon Jan 03, 2005 12:00 am
Location: Texas, Usa

Re: AMOS HELP

Post by gmoney »

i know this but the way the developer of AMOS compiled the user apps _main offsett is 0x10000000. so i was tryin to tweek the code so the offset would pure. the original init.map the came with AMOS is up top then you will see what im saying, or should i say "typing".
gmoney
Member
Member
Posts: 106
Joined: Mon Jan 03, 2005 12:00 am
Location: Texas, Usa

Re: AMOS HELP

Post by gmoney »

i'm looking thru the gnu link script manuals to see what i can add or do differently. if you find something before then let me no and thanks for the feedback.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: AMOS HELP

Post by Troy Martin »

Maybe the developer used some different version of ld than you are?
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
gmoney
Member
Member
Posts: 106
Joined: Mon Jan 03, 2005 12:00 am
Location: Texas, Usa

Re: AMOS HELP

Post by gmoney »

djgpp hasn't updated there stuff in a long time that includes the elf binutil
Post Reply