GCC new target os question

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
User avatar
lode
Posts: 15
Joined: Tue Oct 17, 2006 6:28 pm
Location: Oulu, Finland

GCC new target os question

Post by lode »

Could somebody who has added a new os target to gcc & binutils etc explain exactly what needs to be changed and where?
I seem to find only "adding a new cpu target for linux" tutorials by google.
(why on earth the stuff needs to be compiled inside the thing by default?)
Good links are also appreciated ;)
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

I only know of a one project (Now defunct?) that had a working binutils and gcc port (binutils ran natively.. gcc was used as a cross compiler as it didn't quite work well natively..)..

I made patches for the port, They might be useful for you to see what types of changes were made.. But the OS was considerably far along and was using newlib.

EDIT: Actually there might be others that have binutils ported now...
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
lode
Posts: 15
Joined: Tue Oct 17, 2006 6:28 pm
Location: Oulu, Finland

Post by lode »

At this point I'd be happy to have a working cross-compiler, since I doubt I could get anything but most basic programs to run natively.

Have you got those patches? I'd be interested in seeing them.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Right, I can help you with the specifics but it should at least give you some information on how he ported binutils to his OS.

The binutils patch is for 2.17 and the gcc patch is for 4.1.1 (But it isn't hard to manually apply the changes to another..)
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

[The extension patch has been deactivated and can no longer be displayed.]

Last edited by Brynet-Inc on Wed May 02, 2007 7:56 pm, edited 1 time in total.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post by binutils »

User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

How exactly is this in any way related... ?
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

C8H10N4O2 | #446691 | Trust the nodes.
User avatar
omin0us
Member
Member
Posts: 49
Joined: Tue Oct 17, 2006 6:53 pm
Location: Los Angeles, CA
Contact:

Post by omin0us »

Brynet-Inc wrote:I only know of a one project (Now defunct?) that had a working binutils and gcc port (binutils ran natively.. gcc was used as a cross compiler as it didn't quite work well natively..)..

I made patches for the port, They might be useful for you to see what types of changes were made.. But the OS was considerably far along and was using newlib.

EDIT: Actually there might be others that have binutils ported now...
The OS itself is dead, but the developer (Andrew Pammant) jumped onboard with my OS and has been contributing to it now. :]
http://ominos.sourceforge.net - my kernel
#ominos @ irc.freenode.net
http://dtors.ath.cx - my blog
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

Am working on it. Will put the diff online when it works.

Code: Select all

diff -urb binutils-2.17/bfd/config.bfd binutils-2.17.atlantisos/bfd/config.bfd
--- binutils-2.17/bfd/config.bfd	2006-04-05 14:41:57.000000000 +0200
+++ binutils-2.17.atlantisos/bfd/config.bfd	2007-05-03 23:25:31.000000000 +0200
@@ -545,6 +546,11 @@
     targ_selvecs="i386linux_vec bfd_efi_app_ia32_vec"
     targ64_selvecs=bfd_elf64_x86_64_vec
     ;;
+  i[3-7]86-*-atlantisos-*)
+    targ_defvec=bfd_elf32_i386_vec
+    targ_selvecs=i386atlantisos_vec
+    targ64_selvecs=bfd_elf64_x86_64_vec
+    ;;
 #ifdef BFD64
   x86_64-*-elf*)
     targ_defvec=bfd_elf64_x86_64_vec
@@ -562,6 +568,10 @@
     targ_defvec=bfd_elf64_x86_64_vec
     targ_selvecs="bfd_elf32_i386_vec i386linux_vec bfd_efi_app_ia32_vec"
     ;;
+  x86_64-*-atlantisos-*)
+    targ_defvec=bfd_elf64_x86_64_vec
+    targ_selvecs="bfd_elf32_i386_vec i386atlantisos_vec"
+    ;;
 #endif
   i[3-7]86-*-lynxos*)
     targ_defvec=bfd_elf32_i386_vec
diff -urb binutils-2.17/bfd/configure.in binutils-2.17.atlantisos/bfd/configure.in
--- binutils-2.17/bfd/configure.in	2006-06-23 20:17:07.000000000 +0200
+++ binutils-2.17.atlantisos/bfd/configure.in	2007-05-03 23:25:31.000000000 +0200
@@ -727,6 +727,7 @@
     hp300bsd_vec)		tb="$tb hp300bsd.lo aout32.lo" ;;
     hp300hpux_vec)		tb="$tb hp300hpux.lo aout32.lo" ;;
     i386aout_vec)		tb="$tb i386aout.lo aout32.lo" ;;
+    i386atlantisos_vec)         tb="$tb i386atlantisos.lo aout32.lo" ;;
     i386bsd_vec)		tb="$tb i386bsd.lo aout32.lo" ;;
     i386coff_vec)		tb="$tb coff-i386.lo cofflink.lo" ;;
     i386dynix_vec)		tb="$tb i386dynix.lo aout32.lo" ;;
diff -urb binutils-2.17/gas/configure.tgt binutils-2.17.atlantisos/gas/configure.tgt
--- binutils-2.17/gas/configure.tgt	2006-04-05 14:41:57.000000000 +0200
+++ binutils-2.17.atlantisos/gas/configure.tgt	2007-05-03 23:25:31.000000000 +0200
@@ -162,6 +162,7 @@
 
   i386-ibm-aix*)			fmt=coff em=i386aix ;;
   i386-sequent-bsd*)			fmt=aout em=dynix ;;
+  i386-*-atlantisos*)                   fmt=elf ;;
   i386-*-beospe*)			fmt=coff em=pe ;;
   i386-*-beos*)				fmt=elf ;;
   i386-*-coff)				fmt=coff ;;
diff -urb binutils-2.17/ld/Makefile.am binutils-2.17.atlantisos/ld/Makefile.am
--- binutils-2.17/ld/Makefile.am	2006-06-03 06:45:50.000000000 +0200
+++ binutils-2.17.atlantisos/ld/Makefile.am	2007-05-03 23:25:37.000000000 +0200
@@ -227,6 +227,7 @@
 	ehppanbsd.o \
 	ehppaobsd.o \
 	ei386aout.o \
+	ei386atlantisos.o \
 	ei386beos.o \
 	ei386bsd.o \
 	ei386coff.o \
@@ -1045,6 +1046,9 @@
 ei386linux.c: $(srcdir)/emulparams/i386linux.sh \
   $(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} i386linux "$(tdir_i386linux)"
+ei386atlantisos.c: $(srcdir)/emulparams/i386atlantisos.sh \
+  $(srcdir)/emultempl/atlantisos.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} i386atlantisos "$(tdir_i386atlantisos)"
 ei386lynx.c: $(srcdir)/emulparams/i386lynx.sh \
   $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} i386lynx "$(tdir_i386lynx)"
diff -urb binutils-2.17/ld/configure.tgt binutils-2.17.atlantisos/ld/configure.tgt
--- binutils-2.17/ld/configure.tgt	2006-04-05 14:41:57.000000000 +0200
+++ binutils-2.17.atlantisos/ld/configure.tgt	2007-05-03 23:25:37.000000000 +0200
@@ -160,6 +160,9 @@
 			targ_extra_libpath=elf_i386
 			tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
 			tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;;
+i[3-7]86-*-atlantisos-*)targ_emul=elf_i386 ;;
+x86_64-*-atlantisos-*)  targ_emul=elf_x86_64
+			targ_extra_emuls=elf_i386 ;;
 i[3-7]86-*-sysv[45]*)	targ_emul=elf_i386 ;;
 i[3-7]86-*-solaris2*)	targ_emul=elf_i386_ldso
                         targ_extra_emuls="elf_i386 elf_x86_64"
The diff. You need to rerun aclocal, autoconf and automake in the respective directories after, and then rebuild with the i686-atlantisos-elf target. Of course, you can probably just do a text substitution in the diff to make it your OS.

You need to add one file to the LD output configuration too:
binutils-2.17.atlantisos/ld/emulparams/i386atlantisos.sh

Code: Select all

SCRIPT_NAME=elf
OUTPUT_FORMAT="out.elf-i386-atlantisos"
TARGET_PAGE_SIZE=0x1000
TEXT_START_ADDR=0x1000
NONPAGED_TEXT_START_ADDR=0
ARCH=i386
TEMPLATE_NAME=atlantisos
Making it output PE or COFF should be fairly easy to do. I haven't tried to run any output executables but I'm fairly sure this is about it for binutils. I'm off to try GCC now.

Enjoy!
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

Code: Select all

candy@blackbox:~/atlantisos/port/build-gcc$ ../gcc-4.3-20070427/configure --pref
ix=$PREFIX --target=$TARGET --disable-nls
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-atlantisos-elf
checking for a BSD-compatible install... /usr/bin/ginstall -c
Looking good so far :)

(oh, this is a svn snapshot... somebody moved variadic templates to 4.3, so I had to move along. 4.2 isn't even out so I would really disrecommend this :))
Post Reply