tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] TinyCC ported on NetBSD-i386


From: Marc Vertes
Subject: [Tinycc-devel] TinyCC ported on NetBSD-i386
Date: Thu, 19 Dec 2002 01:39:28 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826

Hello Fabrice, and tinyCC developers,

please find hereafter a patch against tinycc-0.9.15 which allows to compile and run tinycc on NetBSD-i386 (tested on 1.6).

Error report and bound checking are still disabled. Some work has to be done regarding signals and siginfo, to be more portable.

Use of dlsym has been slightly changed to not rely anymore on GNU convention, (portability again).

Best regards.
--
Marc Vertes
*** tcc-0.9.15/tccelf.c.orig    Sun Dec  8 15:40:32 2002
--- tcc-0.9.15/tccelf.c Thu Dec 19 01:23:11 2002
***************
*** 376,386 ****
      }
  }
  
- static void *resolve_sym(const char *sym)
- {
-     return dlsym(RTLD_DEFAULT, sym);
- }
- 
  /* relocate symbol table, resolve undefined symbols if do_resolve is
     true and output error if undefined symbol. */
  static void relocate_syms(TCCState *s1, int do_resolve)
--- 376,381 ----
***************
*** 389,395 ****
--- 384,392 ----
      int sym_bind, sh_num, sym_index;
      const char *name;
      unsigned long addr;
+     void *hd;
  
+     hd = dlopen(NULL, RTLD_GLOBAL);
      sym_end = (Elf32_Sym *)(symtab_section->data + 
symtab_section->data_offset);
      for(sym = (Elf32_Sym *)symtab_section->data + 1; 
          sym < sym_end;
***************
*** 399,405 ****
              name = strtab_section->data + sym->st_name;
              if (do_resolve) {
                  name = symtab_section->link->data + sym->st_name;
!                 addr = (unsigned long)resolve_sym(name);
                  if (addr) {
                      sym->st_value = addr;
                      goto found;
--- 396,402 ----
              name = strtab_section->data + sym->st_name;
              if (do_resolve) {
                  name = symtab_section->link->data + sym->st_name;
!                 addr = (unsigned long)dlsym(hd, name);
                  if (addr) {
                      sym->st_value = addr;
                      goto found;
*** tcc-0.9.15/Makefile.orig    Sun Dec  8 15:40:31 2002
--- tcc-0.9.15/Makefile Thu Dec 19 01:23:11 2002
***************
*** 1,11 ****
  #
  # Tiny C Compiler Makefile
  #
! prefix=/usr/local
  manpath=$(prefix)/man
  
  CFLAGS=-O2 -g -Wall
! LIBS=-ldl
  CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
  LIBS_P=
  
--- 1,13 ----
  #
  # Tiny C Compiler Makefile
  #
! prefix ?=/usr/local
  manpath=$(prefix)/man
  
+ OS = $(shell uname -s)
  CFLAGS=-O2 -g -Wall
! LIBS_Linux = -ldl
! LIBS=$(LIBS_$(OS))
  CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
  LIBS_P=
  
***************
*** 117,122 ****
--- 119,125 ----
        gcc -O2 -Wall -c -o $@ $<
  
  install: tcc libtcc1.o bcheck.o
+       mkdir -p $(prefix)/bin $(manpath)/man1
        $(INSTALL) -m755 tcc $(prefix)/bin
        $(INSTALL) tcc.1 $(manpath)/man1
        mkdir -p $(prefix)/lib/tcc
*** tcc-0.9.15/tcc.c.orig       Sun Dec  8 15:40:32 2002
--- tcc-0.9.15/tcc.c    Thu Dec 19 01:24:30 2002
***************
*** 34,41 ****
--- 34,43 ----
  #endif
  #ifndef WIN32
  #include <sys/time.h>
+ #ifndef __NetBSD__
  #include <sys/ucontext.h>
  #endif
+ #endif
  #include "elf.h"
  #include "stab.h"
  #ifndef CONFIG_TCC_STATIC
***************
*** 535,541 ****
  #define vsnprintf _vsnprintf
  #endif
  
! #if defined(WIN32) || defined(TCC_UCLIBC) || defined(__FreeBSD__)
  /* currently incorrect */
  long double strtold(const char *nptr, char **endptr)
  {
--- 537,543 ----
  #define vsnprintf _vsnprintf
  #endif
  
! #if defined(WIN32) || defined(TCC_UCLIBC) || defined(__FreeBSD__) || 
defined(__NetBSD__)
  /* currently incorrect */
  long double strtold(const char *nptr, char **endptr)
  {
***************
*** 8336,8342 ****
      fprintf(stderr, "\n");
  }
  
! #ifndef WIN32
  
  #ifdef __i386__
  
--- 8338,8345 ----
      fprintf(stderr, "\n");
  }
  
! //#ifndef WIN32
! #if ! defined(WIN32) && ! defined(__NetBSD__)
  
  #ifdef __i386__
  
***************
*** 8492,8497 ****
--- 8495,8502 ----
      if (do_debug) {
  #ifdef WIN32
          error("debug mode currently not available for Windows");
+ #elif defined(__NetBSD__)
+       error("debug mode currently not available for NetBSD");
  #else        
          struct sigaction sigact;
          /* install TCC signal handlers to print debug info on fatal
*** tcc-0.9.15/bcheck.c.orig    Sun Dec  8 15:40:32 2002
--- tcc-0.9.15/bcheck.c Thu Dec 19 01:23:11 2002
***************
*** 21,27 ****
  #include <stdio.h>
  #include <stdarg.h>
  #include <string.h>
! #ifndef __FreeBSD__
  #include <malloc.h>
  #endif
  
--- 21,27 ----
  #include <stdio.h>
  #include <stdarg.h>
  #include <string.h>
! #if ! defined(__FreeBSD__) || ! defined(__NetBSD__)
  #include <malloc.h>
  #endif
  
***************
*** 36,43 ****
  
  #define HAVE_MEMALIGN
  
! #ifdef __FreeBSD__
! #warning Bound checking not fully supported on FreeBSD
  #undef CONFIG_TCC_MALLOC_HOOKS
  #undef HAVE_MEMALIGN
  #endif
--- 36,43 ----
  
  #define HAVE_MEMALIGN
  
! #if defined (__FreeBSD__) || defined(__NetBSD__)
! #warning Bound checking not fully supported on BSD
  #undef CONFIG_TCC_MALLOC_HOOKS
  #undef HAVE_MEMALIGN
  #endif
***************
*** 782,788 ****
  {
      void *ptr;
      size = size * nmemb;
!     ptr = __bound_malloc(size);
      if (!ptr)
          return NULL;
      memset(ptr, 0, size);
--- 782,788 ----
  {
      void *ptr;
      size = size * nmemb;
!     ptr = __bound_malloc(size, NULL);
      if (!ptr)
          return NULL;
      memset(ptr, 0, size);

reply via email to

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