guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stage0/mescc-tools + patch + mescc -> hello world!


From: Jan Nieuwenhuizen
Subject: stage0/mescc-tools + patch + mescc -> hello world!
Date: Sun, 11 Jun 2017 13:30:43 +0200

Hi Jeremiah, all!

Stage0 and Mes+Mescc are almost connected which means that we have taken
a big step towards closing the bootstrap loop!

After a night of scheming on irc and hacking by Jeremiah and myself,
I've now been able to compile this amazing C program

--8<---------------cut here---------------start------------->8---
#include <stdio.h>

int
main (int argc, char *argv[])
{
  eputs ("Hello, Mescc!\n");
  return 33;
}
--8<---------------cut here---------------end--------------->8---

and Mescc's mini-libc[1] and link them into a working x86 executable
using MESCC_Tools's hex2_linker[2].

Mescc's hex2 output so that it's now fully compliant and I have added a
simplistic elf32 header[3] to Mes.

Using this patch

--8<---------------cut here---------------start------------->8---
12:36:34 address@hidden:~/src/MESCC_Tools [env]
$ git diff
diff --git a/hex2_linker.c b/hex2_linker.c
index c4d9bf9..591b4a4 100644
--- a/hex2_linker.c
+++ b/hex2_linker.c
@@ -22,6 +22,8 @@
 #include <string.h>
 #include <getopt.h>
 #define max_string 255
+// ELF32 virtual base address
+#define VADDR 0x8048000
 
 struct input_files
 {
@@ -212,7 +214,7 @@ int storePointer(char ch, FILE* source_file, int ip)
        }
        else if(38 == ch)
        { /* Deal with & */
-               outputPointer(target, 4);
+               outputPointer(target + VADDR, 4);
        }
        else if(37 == ch)
        { /* Deal with % */
--8<---------------cut here---------------end--------------->8---

we can build it

--8<---------------cut here---------------start------------->8---
guile/mescc.scm -c mlibc/mini-libc-mes.c
../MESCC_Tools/bin/hex2 -f stage0/elf32.hex2 -f mini-libc-mes.o -f hello.o 
--LittleEndian --Architecture 1 > a.out
chmod +x a.out
--8<---------------cut here---------------end--------------->8---

and run

--8<---------------cut here---------------start------------->8---
12:54:16 address@hidden:~/src/mes [env]
$ ./a.out 
Hello, Mescc!
[42]12:54:18 address@hidden:~/src/mes [env]
$ 
--8<---------------cut here---------------end--------------->8---

Greetings,
janneke

[1] https://gitlab.com/janneke/mes/blob/wip-hex2/mlibc/mini-libc-mes.c
[2] https://github.com/oriansj/MESCC_Tools/blob/master/hex2_linker.c
[3] https://gitlab.com/janneke/mes/blob/wip-hex2/stage0/elf32.hex2

-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]