Commit graph

118 commits

Author SHA1 Message Date
Jan Nieuwenhuizen 06e9dd4bce
mescc: Mes C Library: Support make: Implement clock_gettime, time.
* include/linux/x86/syscall.h (SYS_time, SYS_clock_gettime,
SYS_gettimeofday): New macro.
* include/linux/x86_64/syscall.h (SYS_time, SYS_clock_gettime,
SYS_gettimeofday): New macro.
* lib/linux/tcc.c (gettimeofday, time): New function.
* lib/linux/gnu.c (clock_gettime): New function.
* include/time.h: Declare it.
* lib/stub/gettimeofday.c: Remove.
* lib/stub/time.c: Remove.
2018-08-27 00:34:13 +02:00
Jan Nieuwenhuizen 2fe2e556e8
mescc: Mes C Library: Support make: Support main with envp.
* lib/linux/x86-mes-gcc/crt1.c (_start): Also push envp.
* lib/linux/x86-mes/crt1.c (_start): Also push envp.
* lib/linux/x86_64-mes-gcc/crt1.c (_start): Also mov environment,%rdx.
2018-08-26 23:39:43 +02:00
Jan Nieuwenhuizen 8b9d51e4a4
mescc: Mes C Library: Support make: Add chdir, getlogin, setvbuf, sigblock.
* lib/stub/getlogin.c: New file.
* lib/stub/setvbuf.c: New file.
* lib/stub/sigblock.c: New file.
* lib/libc+gnu.c: Include them.
* include/linux/x86/syscall.h (SYS_chdir): New macro.
* include/linux/x86_64/syscall.h (SYS_chdir): New macro.
* include/stdio.h (_IOFBF, _IOLBF, _IONBF): New macro.
* include/errno.h (ENOEXEC, ECHILD): New macro.
* include/sys/wait.h (WNOHANG): New macro.
* lib/linux/gnu.c (chdir): New function.
* include/ar.h: New file.
2018-08-26 22:41:52 +02:00
Jan Nieuwenhuizen 543ae4df32
mescc: Mes C Library: Support diffutils: Add execl.
* include/limits.h (CHAR_MAX): New macro.
* lib/posix/execl.c: New file.
* include/unistd.h: Declare it.
2018-08-26 20:54:29 +02:00
Jan Nieuwenhuizen fa4ba916ea
mescc: Mes C Library: Add closedir, opendir, readdir.
* include/dirent.h: New file.  Import from glibc-2.2.5.
* include/dirstream.h: Likewise.
* lib/dirent/__getdirentries.c: Likewise.
* lib/dirent/closedir.c: Likewise.
* lib/dirent/readdir.c (readdir): Likewise.
* lib/libc+gnu.c: Include them.
* include/linux/x86/syscall.h (SYS_getdents): New macro.
* include/linux/x86_64/syscall.h (SYS_getdents): Likewise.
* lib/linux/gnu.c (getdents): New function.
* include/limits.h (NAME_MAX): New macro.
* include/fcntl.h (O_DIRECTORY): New macro.
* scaffold/tests/readdir.dir: New directory.
* scaffold/tests/99-readdir.c: New file, use it.
* build-aux/check-mescc.sh (tests): Run it.
2018-08-26 18:34:53 +02:00
Jan Nieuwenhuizen 457d120770
mescc: Mes C Library: Explode libc+gnu.c.
* modified:   include/math.h: Add declarations.
* lib/posix/getopt.c: Rename from lib/getopt.c.
* lib/gcc.c: Remove.
* lib/m4.c: Remove.
* lib/ctype/isalnum.c: New file, explode from libc+gnu.c.
* lib/ctype/isalpha.c: Likewise.
* lib/ctype/isascii.c: Likewise.
* lib/ctype/iscntrl.c: Likewise.
* lib/ctype/isnumber.c: Likewise.
* lib/ctype/isprint.c: Likewise.
* lib/ctype/ispunct.c: Likewise.
* lib/math/fabs.c: Likewise.
* lib/posix/alarm.c: Likewise.
* lib/posix/mktemp.c: Likewise.
* lib/posix/raise.c: Likewise.
* lib/posix/sbrk.c: Likewise.
* lib/posix/sleep.c: Likewise.
* lib/posix/unsetenv.c: Likewise.
* lib/stdio/clearerr.c: Likewise.
* lib/stdio/fdgets.c: Likewise.
* lib/stdio/feof.c: Likewise.
* lib/stdio/fgets.c: Likewise.
* lib/stdio/fileno.c: Likewise.
* lib/stdio/freeopen.c: Likewise.
* lib/stdio/freopen.c: Likewise.
* lib/stdio/perror.c: Likewise.
* lib/stdlib/__exit.c: Likewise.
* lib/stdlib/abs.c: Likewise.
* lib/stdlib/atexit.c: Likewise.
* lib/stdlib/atol.c: Likewise.
* lib/stdlib/bsearch.c: Likewise.
* lib/stdlib/mbstowcs.c: Likewise.
* lib/string/bcmp.c: Likewise.
* lib/string/bcopy.c: Likewise.
* lib/string/bzero.c: Likewise.
* lib/string/index.c: Likewise.
* lib/string/rindex.c: Likewise.
* lib/string/strcspn.c: Likewise.
* lib/string/strdup.c: Likewise.
* lib/string/strerror.c: Likewise.
* lib/string/strncat.c: Likewise.
* lib/string/strpbrk.c: Likewise.
* lib/string/strspn.c: Likewise.
* lib/stub/__cleanup.c: Likewise.
* lib/stub/atof.c: Likewise.
* lib/stub/chown.c: Likewise.
* lib/stub/ctime.c: Likewise.
* lib/stub/fpurge.c: Likewise.
* lib/stub/freadahead.c: Likewise.
* lib/stub/frexp.c: Likewise.
* lib/stub/fscanf.c: Likewise.
* lib/stub/getpwnam.c: Likewise.
* lib/stub/gmtime.c: Likewise.
* lib/stub/pclose.c: Likewise.
* lib/stub/popen.c: Likewise.
* lib/stub/rewind.c: Likewise.
* lib/stub/setbuf.c: Likewise.
* lib/stub/sigsetmask.c: Likewise.
* lib/stub/strftime.c: Likewise.
* lib/stub/sys_siglist.c: Likewise.
* lib/stub/system.c: Likewise.
* lib/stub/times.c: Likewise.
* lib/stub/umask.c: Likewise.
* lib/stub/utime.c: Likewise.
* lib/libc+gnu.c: Include explodings.
* lib/libg.c: Likewise.
* lib/libgetopt.c: Include explodings.
2018-08-24 20:57:34 +02:00
Jan Nieuwenhuizen e9d9e80980
mescc: Mes C Library: Explode libc+tcc.c.
* include/libmes.h: Add declarations.
* include/string.h: Likewise.
* lib/ctype/islower.c: New file, explode from lib/libc+tcc.c.
* lib/ctype/isupper.c: Likewise.
* lib/ctype/tolower.c: Likewise.
* lib/ctype/toupper.c: Likewise.
* lib/mes/search-path.c: Likewise.
* lib/posix/execvp.c: Likewise.
* lib/stdio/fclose.c: Likewise.
* lib/stdio/fdopen.c: Likewise.
* lib/stdio/ferror.c: Likewise.
* lib/stdio/fflush.c: Likewise.
* lib/stdio/fopen.c: Likewise.
* lib/stdio/fprintf.c: Likewise.
* lib/stdio/fread.c: Likewise.
* lib/stdio/fseek.c: Likewise.
* lib/stdio/ftell.c: Likewise.
* lib/stdio/fwrite.c: Likewise.
* lib/stdio/printf.c: Likewise.
* lib/stdio/remove.c: Likewise.
* lib/stdio/snprintf.c: Likewise.
* lib/stdio/sprintf.c: Likewise.
* lib/stdio/sscanf.c: Likewise.
* lib/stdio/vfprintf.c: Likewise.
* lib/stdio/vprintf.c: Likewise.
* lib/stdio/vsnprintf.c: Likewise.
* lib/stdio/vsprintf.c: Likewise.
* lib/stdio/vsscanf.c: Likewise.
* lib/stdlib/calloc.c: Likewise.
* lib/stdlib/qsort.c: Likewise.
* lib/stdlib/strtof.c: Likewise.
* lib/stdlib/strtol.c: Likewise.
* lib/stdlib/strtold.c: Likewise.
* lib/stdlib/strtoll.c: Likewise.
* lib/stdlib/strtoul.c: Likewise.
* lib/stdlib/strtoull.c: Likewise.
* lib/string/memcmp.c: Likewise.
* lib/string/memmem.c: Likewise.
* lib/string/memmove.c: Likewise.
* lib/string/memset.c: Likewise.
* lib/string/strcat.c: Likewise.
* lib/string/strchr.c: Likewise.
* lib/string/strlwr.c: Likewise.
* lib/string/strncpy.c: Likewise.
* lib/string/strrchr.c: Likewise.
* lib/string/strstr.c: Likewise.
* lib/string/strupr.c: Likewise.
* lib/stub/gettimeofday.c: Likewise.
* lib/stub/ldexp.c: Likewise.
* lib/stub/localtime.c: Likewise.
* lib/stub/mprotect.c: Likewise.
* lib/stub/sigaction.c: Likewise.
* lib/stub/sigemptyset.c: Likewise.
* lib/stub/strtod.c: Likewise.
* lib/stub/time.c: Likewise.
* lib/libc+tcc.c: Include explodings.
2018-08-22 07:23:27 +02:00
Jan Nieuwenhuizen a08baf2d48
mescc: Mes C Library: Explode libmes.c.
* include/libmes.h: Add declarations.
* lib/abtol.c: New file, explode from lib/libmes.c.
* lib/ctype/isdigit.c: Likewise.
* lib/ctype/isnumber.c: Likewise.
* lib/ctype/isspace.c: Likewise.
* lib/ctype/isxdigit.c: Likewise.
* lib/mes/abtol.c: Likewise.
* lib/mes/eputc.c: Likewise.
* lib/mes/eputs.c: Likewise.
* lib/mes/fdgetc.c: Likewise.
* lib/mes/fdputc.c: Likewise.
* lib/mes/fdputs.c: Likewise.
* lib/mes/fdungetc.c: Likewise.
* lib/mes/itoa.c: Likewise.
* lib/mes/ltoab.c: Likewise.
* lib/mes/ntoab.c: Likewise.
* lib/mes/utoa.c: Likewise.
* lib/stdlib/atoi.c: Likewise.
* lib/libmes.c: Include explodings.
2018-08-16 11:43:27 +02:00
Jan Nieuwenhuizen 38a7077b72
mescc: Mes C Library: Explode libc-mini.c.
* include/libmes.h: Add declarations.
* lib/mes/eputs.c: New file, explode from lib/libc-mini.c.
* lib/mes/oputs.c: Likewise.
* lib/stdlib/exit.c: Likewise.
* lib/stdlib/puts.c: Likewise.
* lib/string/strlen.c: Likewise.
* lib/libc-mini.c: Include explodings.
2018-08-16 11:07:33 +02:00
Jan Nieuwenhuizen 3e4a56a05b
mescc: Mes C Library: Explode libc.c.
* lib/libc.c: New file, explode from lib/libc.c.
* lib/posix/execv.c: Likewise.
* lib/posix/isatty.c: Likewise.
* lib/posix/wait.c: Likewise.
* lib/stdio/fgetc.c: Likewise.
* lib/stdio/fputc.c: Likewise.
* lib/stdio/fputs.c: Likewise.
* lib/stdio/getc.c: Likewise.
* lib/stdio/getchar.c: Likewise.
* lib/stdio/putc.c: Likewise.
* lib/stdio/putchar.c: Likewise.
* lib/stdio/ungetc.c: Likewise.
* lib/stdlib/free.c: Likewise.
* lib/stdlib/getenv.c: Likewise.
* lib/stdlib/realloc.c: Likewise.
* lib/stdlib/setenv.c: Likewise.
* lib/string/strcmp.c: Likewise.
* lib/string/strcpy.c: Likewise.
* lib/string/strncmp.c: Likewise.
* lib/libc.c: Include explodings.
2018-08-16 10:50:53 +02:00
Jan Nieuwenhuizen d93e63f743
mescc: Mes C Library: Support oputs for POSIX.
* lib/libmes.c (oputs)[POSIX]: New function.
2018-08-12 18:38:43 +02:00
Jan Nieuwenhuizen 9273a64098
mescc: Mes C Library: Cleanup start files.
* lib/linux/x86-mes-gcc/crt0.c: Split from lib/linux/crt0.c.
* lib/linux/x86-mes-gcc/crt1.c: Split from lib/linux/crt1.c.
* lib/linux/x86-mes-gcc/crti.c: Split from lib/linux/crti.c.
* lib/linux/x86-mes-gcc/crtn.c: Split from lib/linux/crtn.c.
* lib/linux/x86-mes/crt0.c: Split from lib/linux/crt0.c.
* lib/linux/x86-mes/crt1.c: Split from lib/linux/crt1.c.
* lib/linux/x86-mes/crti.c: Split from lib/linux/crti.c.
* lib/linux/x86-mes/crtn.c: Split from lib/linux/crtn.c.
* build-aux/build-cc.sh: Update.
* build-aux/build-cc32.sh: Update.
* build-aux/build-mes.sh: Update.
2018-08-12 08:45:04 +02:00
Jan Nieuwenhuizen fe055ba344
mescc: Mes C Library: Add x86_64 libc+gnu support.
* include/linux/x86/syscall.h: Move SYS_ defines from gnu.c.
* include/linux/x86_64/syscall.h: Add SYS_ defines for gnu.
* lib/linux/gnu.c: Update.
* lib/linux/gnu.c (signal)[__x86_64__]: Implement using rt_sigaction.
* lib/stdlib/abort.c: Support x86_64.
2018-08-11 19:04:01 +02:00
Jan Nieuwenhuizen 50dff52c99
mescc: Mes C Library: Add x86_64 libc+tcc support.
* include/linux/x86/syscall.h: Move SYS_ defines from tcc.c.
* include/linux/x86_64/syscall.h: Add SYS_ defines for tcc.
* lib/x86-mes-gcc/setjmp.c: Rename from lib/libc+tcc-gcc.c
* lib/x86-mes/setjmp.c: Rename from lib/libc+tcc-mes.c
* lib/linux/tcc.c: Update.
2018-08-11 18:39:48 +02:00
Jan Nieuwenhuizen 5a6d8c21e0
mescc: Mes C Library: Add x86_64 libc support.
* include/linux/x86_64/syscall.h: New file.
* include/linux/x86/syscall.h: New file.
* lib/linux/x86_64-mes-gcc/mes.c: New file.
* lib/linux/x86-mes/mes.c: Rename from lib/linux/mes.c.
* lib/linux/x86-mes-gcc/mes.c: Rename from lib/linux/gcc.c.
* lib/linux/libc.c: Update includes.
(waitpid)[__x86_64__]: Use wait4.
* build-aux/build-cc.sh: Build libc too.
* lib/x86-mes/x86.M1 (mov____0x8(%ebp),%esi): New macro.
2018-08-11 11:42:30 +02:00
Jan Nieuwenhuizen 46e0641e9c
mescc: Mes C Library: Add x86_64 libc-mini support.
* lib/linux/x86-mes-gcc/mini.c: Rename from lib/linux/mini-gcc.c.
* lib/linux/x86-mes/mini.c: Rename from lib/linux/mini-mes.c.
* lib/linux/x86_64-mes-gcc/crt1.c: Rename from lib/linux/x86_64/crt1.c.
* lib/linux/x86_64-mes-gcc/mini.c: New file.
* build-aux/build-cc.sh: Build libc-mini, scaffold/main, scaffold/hello.
* build-aux/cc64.sh: New file.
2018-08-10 17:05:01 +02:00
Jan Nieuwenhuizen 75c54406ce
mescc: Add objdump'able x86_64-mes scaffold.
* lib/x86_64-mes/elf64-header.hex2: New file.
* lib/x86_64-mes/elf64-footer-single-main.hex2: New file.
* build-aux/build-x86_64-mes.sh: Enable second, objdump'able exit-42
  scaffold test.
2018-08-10 11:37:55 +02:00
Jan Nieuwenhuizen 521f97dfb3
mescc: Initial x86_64-mes scaffold.
* build-aux/GNUmakefile.in (x86_64-mes): New target.
* .gitignore: Ignore x86 and x86_64 out files.
* build-aux/build-mes.sh: Resurrect three initial exit42 scaffold tests.
* build-aux/build-x86_64-mes.sh: New file.  Add initial exit42
  scaffold test.
* lib/x86-mes/elf32-0header.hex2: Fix comment.
* lib/x86-mes/elf32-header.hex2: Likewise.
* lib/x86_64-mes/elf-0footer.hex2: New file.
* lib/x86_64-mes/elf64-0header.hex2: New file.
* lib/x86_64-mes/elf64-body-exit-42.hex2: New file.
* lib/x86_64-mes/exit-42.c: New file.
2018-08-10 11:15:43 +02:00
Jan Nieuwenhuizen 84a3e2e1fe
Add taken-from-Binutils and copyright line to alloca.c
* lib/stdlib/alloca.c: Add `taken from binutils' and copyright line to
  alloca.c for minor changes.
2018-07-23 19:13:40 +02:00
Jan Nieuwenhuizen 72cb975213
GNU Mes.
Throughout, make these changes

   Copyright headers: GNU Mes
   First mention of name: GNU Mes
   Website: https://www.gnu.org/software/mes
   Git:     git://git.savannah.gnu.org/mes.git
2018-07-22 14:24:36 +02:00
Jan Nieuwenhuizen 573896cc1c
core: Prepare for the Hurd.
* lib/linux/libc.c: Move from lib/linux.c.
* lib/linux/gcc.c: Move from lib/linux-gcc.c.
* lib/linux/gnu.c: Move from lib/linux+gnu.c.
* lib/linux/libc.c: Move from lib/linux.c.
* lib/linux/mes.c: Move from lib/linux-mes.c.
* lib/linux/mini-gcc.c: Move from lib/linux-mini-gcc.c.
* lib/linux/mini-mes.c: Move from lib/linux-mini-mes.c.
* lib/linux/tcc.c: Move from lib/linux+tcc.c.
* lib/linux/crt0.c: Move from lib/crt0.c.
* lib/linux/crt1.c: Move from lib/crt1.c.
* lib/linux/crti.c: Move from lib/crti.c.
* lib/linux/crtn.c: Move from lib/crtn.c.
* build-aux/build-cc.sh: Update for new layout.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc32-mes.sh: Likewise.
* lib/string/argz-count.c: New file taken from GNU C Library,
  relicensed.
* lib/string/argz-extract.c: New file taken from GNU C Library,
  relicensed.
* include/argz.h: New file.
* lib/string/memcpy.c: New file, extract from libc.
* lib/assert/assert.c: Likewise.
2018-06-30 13:11:03 +02:00
Jan Nieuwenhuizen 59c56ac72d
mescc: fwrite: Increase debug tracing threshold.
* lib/libc+tcc.c (fwrite): Increase debug tracing threshold.
2018-07-21 11:16:29 +02:00
Jan Nieuwenhuizen 58ca3ab6c0
mescc: Add proper includes.
* include/libmes.h (__mes_debug): Declare.
* lib/libtcc1.c: Add proper includes.
* lib/linux+gnu.c: Likewise.
* lib/m4.c: Likewise.
2018-07-21 11:15:48 +02:00
Jan Nieuwenhuizen 69813a6da3
build: Support Debian build, install.
* scripts/mescc: Support Debian build, install.
* lib/libmes.c (fdgetc): Allow Nyacc/ungetc conflict.
* build-aux/export.make (ARCH): Export.
* build-aux/build-mes.sh: Disable full build for non-bootstrap
  x86-only.
* check.sh (total): Use bash to invoke build-aux/check-mescc.sh.
* build-aux/build-guile.sh (SCM_FILES): Support guile-2.0.
* module/mes/guile.scm (guile-2.0): Support guile-2.0.
* build-aux/build-mes.sh: Use bash.
* build-aux/setup-mes.sh: New file.
2018-07-12 22:29:59 +02:00
Jan Nieuwenhuizen 16f4adfbc2
core: Fix compile warnings.
* lib/libmes.c: Fix warning.
* src/posix.c (execl_): Fix warning, add debug printing.
2018-06-26 06:19:51 +02:00
Jan Nieuwenhuizen 50d7036e03
mescc: Support binutils 2.10.1: strrchr: Stop at start of string.
* lib/libc+tcc.c (strrchr): Stop at start of string.
* scaffold/tests/88-strrchr.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-06-24 17:25:46 +02:00
Jan Nieuwenhuizen 350d94aa77
build: Support tcc, create tinycc-seed with tcc.
* configure: check for tcc.
* build-aux/cc32-mes.sh: Rename from cc-mes-gcc.sh.  Support
  tcc.  Update users.
* build-aux/build-cc32-mes.sh: Rename from build-mes-gcc.sh.  Update users.
* GNUmakefile (mes-tcc): New target.
* .gitignore: Ignore mes-tcc arch output.
* lib/crt1.c (_start): Add "rm" constraint so satisfy tcc.
* lib/linux-gcc.c (_sys_call, _sys_call1 _sys_call2 _sys_call3): Likewise.
2018-06-24 09:28:23 +02:00
Jan Nieuwenhuizen 41a6585295
mescc: Support binutils 2.20.1: vfprint, vsprintf: %llx.
* lib/libc+tcc.c (vfprintf, vsprintf): Handle %%llx.  Print error:
  should we skip another int, va_arg a long long?
2018-06-24 17:26:53 +02:00
Jan Nieuwenhuizen 2551eef953
mescc: Support binutils 2.14: vfprint, vsprintf: %12.10d.
* lib/libc+tcc.c (vfprintf, vsprintf): Handle %12.10d.
* scaffold/tests/70-printf.c: Test it.
2018-06-21 00:27:49 +02:00
Jan Nieuwenhuizen f245237f83
mescc: Support gnu toolchain: libtcc1.
* lib/libtcc1.c: New file.
* lib/libc+tcc-gcc.c: Remove libtcc1 stubs.
2018-06-19 20:29:25 +02:00
Jan Nieuwenhuizen 63bf9bb2f7
mescc: Support Tinycc 0.9.27: Drop dlclose, dlopen.
* lib/libc+tcc.c (dlclose, dlopen): Remove.
* include/dlfcn.h (RTLD_DEFAULT): Add.
2018-06-18 22:56:06 +02:00
Jan Nieuwenhuizen 22a22c1de8
mescc: Support binutils 2.25: fseek: Add debug printing.
* lib/libc+tcc.c (fseek): Add debug printing.
2018-06-17 14:17:39 +02:00
Jan Nieuwenhuizen 2062826435
mescc: Tinycc support: bcopy: Do not return void.
* lib/m4.c (bcopy): Do not return void.  Helps tcc.
2018-06-17 14:16:05 +02:00
Jan Nieuwenhuizen c6ae0f41a3
mescc: Support binutils 2.25: memcmp: Support size 0.
* lib/libc+tcc.c (memcmp): Support size 0.
2018-06-17 10:18:59 +02:00
Jan Nieuwenhuizen 0639e3faf1
mescc: Support binutils 2.25: vsscanf: Skip `l'.
* lib/libc+tcc.c (vsscanf): Skip `l'.
2018-06-17 09:26:34 +02:00
Jan Nieuwenhuizen 49bcea84fd
mescc: Debugging oops.
* lib/libc.c (__mes_debug): Oops, wrong direction.
2018-06-17 08:39:31 +02:00
Jan Nieuwenhuizen a9215931e8
mescc: Support binutils 2.15a: fread: read ungetc'd chars too.
* lib/libmes.c (_ungetc_fd): New variable.
  (fdgetc): Use it.
  (_fdungetc_p): New function.
* lib/libc+tcc.c (_fungetc_p): New function.
* lib/libc+tcc.c (fread): Use it to read ungetc'd chars too.
2018-06-16 20:51:16 +02:00
Jan Nieuwenhuizen 65d530f4ec
mescc: Support binutils-2.14: fopen: Return 0 upon failure.
* lib/libc+tcc.c (fopen): Return 0 upon failure.
2018-06-16 10:54:59 +02:00
Jan Nieuwenhuizen 125b43acc8
mescc: Update elf32-header for linux-4.17.
Previously, our binaries showed this

    $ readelf -s scaffold/main.mes-out
    There are 2 program headers, starting at offset 64

    Program Headers:
      Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
      LOAD           0x000000 0x01000000 0x01000000 0x0557c 0x0557c RWE 0x1
      LOAD           0x000000 0x01000000 0x01000000 0x0557c 0x0557c RWE 0x1

     Section to Segment mapping:
      Segment Sections...
       00     .text .data
       01     .text .data

Linux-4.17 refuses to run this and says

    Uhuuh, elf segment at 0000000001000000 requested but the memory is mapped already
    Segmentation fault

* lib/x86-mes/elf32-header.hex2: Remove unused data program header.
2018-06-16 08:32:12 +02:00
Jan Nieuwenhuizen c086f67cec
mescc: Support less-patched tcc/gcc: Add crti and crtn.
* lib/crt0.c[__MESC__]: Support MesCC.
* lib/crti.c: New file.
* lib/crtn.c: New file.
* build-aux/build-mes-gcc.sh: Build them.
2018-06-10 16:03:18 +02:00
Jan Nieuwenhuizen c2c3554884
mescc: Refactor debug and stub printing.
* lib/libc.c (__mes_debug): New function.  Use it for debug printing
  and in stubs throughout.
2018-06-10 14:07:19 +02:00
Jan Nieuwenhuizen 18194b1ae4
mescc: Support binutils-2.30: fopen fix.
* lib/libc+tcc.c (fopen): Set O_APPEND for 'a'.
2018-06-10 13:33:30 +02:00
Jan Nieuwenhuizen c349f6fdd8
mescc: Support binutils-2.30.
* lib/binutils.c (raise, strdup): New function.
  (mbstowcs): New stub.
* include/fcntl.h (O_APPEND, FD_CLOEXEC): New define.
2018-06-09 17:58:47 +02:00
Jan Nieuwenhuizen 53dd76ffc0
mescc: Support binutils-2.10.1: Stubs set errno to 0. 2018-06-09 11:28:31 +02:00
Jan Nieuwenhuizen bb3353a272
mescc: Silence some stubs.
* lib/libc+tcc.c: [!NOISY_FLOATS, !NOISY_TIMES]: Silence stubs.
* lib/gcc.c: Likewise.
* lib/binutils.c: Likewise.
2018-06-09 07:40:07 +02:00
Jan Nieuwenhuizen a744fd9ba4
mescc: Add debug printing: fopen, fwrite.
* lib/libc+tcc.c (fopen, fwrite)[MESC_DEBUG]: Print debug info.
2018-06-10 07:51:56 +02:00
Jan Nieuwenhuizen 3ba5b23dab
mescc: Support binutils-2.10.1: opentype `r+'.
* lib/libc+tcc.c (fopen): Support opentype `r+'.
2018-06-10 07:51:10 +02:00
Jan Nieuwenhuizen 831bd71a14
mescc: syscall: return only ever error -1, set errno. 2018-06-08 07:17:51 +02:00
Jan Nieuwenhuizen b7d913d7a0
mescc: Support gcc-2.95: Add getpwnam stub.
* lib/gcc.c (getpwnam): New stub.
2018-06-07 18:04:17 +02:00
Jan Nieuwenhuizen a70bc92857
mescc: Support gcc-3.0: Implement alarm, setitimer. 2018-06-07 18:03:51 +02:00