Proposed changes for os specific toolchain

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
uglyoldbob
Member
Member
Posts: 62
Joined: Tue Feb 13, 2007 10:46 am

Proposed changes for os specific toolchain

Post by uglyoldbob »

I have some changes I want to propose for the os specific toolchain. It allows the newlib library to be used in the kernel and user space.

Binutils gets no changes.

For GCC, add these lines to the end of the gcc/config/myos.h
GCC suggests modifying libgcc/config.host in a similar manner to gcc/config.gcc

Code: Select all

#undef ENDFILE_SPEC
#define ENDFILE_SPEC "crtend.o%s \
				crtn.o%s"

#undef STARTFILE_SPEC
#define STARTFILE_SPEC "%{!shared: \
			 %{!symbolic: \
			  %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\
			crti.o%s \
			crtbegin.o%s"
For newlib, this is where I applied the most changes, although some are duplicate and could be eliminated.
Modify libgloss/configure.in and modify near the beginning so it looks like this.

Code: Select all

AC_CONFIG_SUBDIRS(libnosys)

case "${target}" in
  *-*-myos*)
	AC_CONFIG_SUBDIRS(myos)
	config_testsuite=true
	;;
  i[[3456]]86-*-elf* | i[[3456]]86-*-coff*)
	AC_CONFIG_SUBDIRS(i386)
	config_testsuite=true
	;;
Make the directory libgloss/myos and copy all files from the libnosys directory there.
Modify the libgloss/myos/Makefile.in and replace libnosys with libmyos.
Also modify this line to say the following.

Code: Select all

OUTPUTS = libmyos.a crti.o crtn.o
Modify CRT0.s to say this

Code: Select all

 .global _start
 .extern main
 .extern exit
 _start:
 call _init
 call main
 call exit
 .wait: hlt
 jmp .wait
Create files crti.s and crtn.s and put these in them.
CRTN.S

Code: Select all

	.section	.init,"ax"
        ret

	.section	.fini,"ax"
        ret
CRTI.S

Code: Select all

	.section	.init,"ax"
	.align 1
	.globl _init
_init:	

	.section	.fini,"ax"
	.align 1
	.globl _fini
_fini:	
Alrighty then. Once all that is complete and you get your cross-compiler compiled, here is the way it is setup to be used. For the kernel, overrides for the newlib glue functions are provided (no need for syscalls because the kernel IS the system). In the kernels linker script, the entry point will not be _start, although control will be passed to _start. The kernel entry point will setup anything that is required before the "regular" initializers get called (for example setup the screen, memory managment, etc). Then call/jump to _start. This method eliminates the need for hand-written language specific initializer code (support.c). I didn't have to use any special linker flags for the kernel either.
For usermode programs, nothing is required besides the usual command (system name)-gcc source.c.

I didn't want to modify the page myself. Let me know what you guys think.
I have an 80386SX 20MHz 2MB RAM.
It is my testbed platform. Only has the 3.5" and 5.25" floppy drives.
uglyoldbob
Member
Member
Posts: 62
Joined: Tue Feb 13, 2007 10:46 am

Re: Proposed changes for os specific toolchain

Post by uglyoldbob »

Hehe... This probably belongs in the Wiki category. Oops.
I have an 80386SX 20MHz 2MB RAM.
It is my testbed platform. Only has the 3.5" and 5.25" floppy drives.
Post Reply