working (?) tcc build
This commit is contained in:
parent
e900dd8d6f
commit
e94266df3d
9 changed files with 79 additions and 26 deletions
1
05/.gitignore
vendored
1
05/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
in04
|
||||
address_map.txt
|
||||
|
|
|
@ -2580,6 +2580,15 @@ function generate_statement
|
|||
local c
|
||||
local d
|
||||
|
||||
if codegen_second_pass == 0 goto skip_addrmap_write
|
||||
d = code_output - output_file_data
|
||||
fputx32(address_map_fd, d)
|
||||
fputc(address_map_fd, ':)
|
||||
fputc(address_map_fd, 32)
|
||||
fprint_statement_location(address_map_fd, statement)
|
||||
fputc(address_map_fd, 10)
|
||||
:skip_addrmap_write
|
||||
|
||||
prev_continue_refs = continue_refs
|
||||
prev_break_refs = break_refs
|
||||
|
||||
|
|
42
05/main.b
42
05/main.b
|
@ -77,7 +77,8 @@ global function_param_names
|
|||
global function_param_has_no_name
|
||||
; ident list of number of bytes of stack space needed by local variables in each function
|
||||
global functions_required_stack_space
|
||||
|
||||
; a map from pc addresses to program locations will be outputted to this file
|
||||
global address_map_fd
|
||||
|
||||
#include util.b
|
||||
#include idents.b
|
||||
|
@ -123,13 +124,19 @@ function types_init
|
|||
*8ptypes_bytes_used = p - types
|
||||
return
|
||||
|
||||
function print_token_location
|
||||
function fprint_token_location
|
||||
argument fd
|
||||
argument token
|
||||
token += 2
|
||||
print_filename(*2token)
|
||||
fprint_filename(fd, *2token)
|
||||
token += 2
|
||||
putc(':)
|
||||
putn(*4token)
|
||||
fputc(fd, ':)
|
||||
fputn(fd, *4token)
|
||||
return
|
||||
|
||||
function print_token_location
|
||||
argument token
|
||||
fprint_token_location(1, token)
|
||||
return
|
||||
|
||||
function print_statement_location
|
||||
|
@ -137,15 +144,28 @@ function print_statement_location
|
|||
; statements & tokens have the same format for locations!
|
||||
print_token_location(statement)
|
||||
return
|
||||
|
||||
function fprint_statement_location
|
||||
argument fd
|
||||
argument statement
|
||||
; statements & tokens have the same format for locations!
|
||||
fprint_token_location(fd, statement)
|
||||
return
|
||||
|
||||
; accepts EITHER file index OR pointer to filename
|
||||
function print_filename
|
||||
function fprint_filename
|
||||
argument fd
|
||||
argument file
|
||||
if file ] 65535 goto print_filename_string
|
||||
file = file_get(file)
|
||||
; (fallthrough)
|
||||
:print_filename_string
|
||||
puts(file)
|
||||
fputs(fd, file)
|
||||
return
|
||||
|
||||
function print_filename
|
||||
argument file
|
||||
fprint_filename(1, file)
|
||||
return
|
||||
|
||||
; accepts EITHER file index OR pointer to filename
|
||||
|
@ -328,11 +348,15 @@ function main
|
|||
|
||||
debug_puts(.str_parsing)
|
||||
parse_tokens(tokens)
|
||||
|
||||
address_map_fd = open_w(.str_addrmap_filename, 420)
|
||||
|
||||
generate_code()
|
||||
|
||||
p = output_file_data + RODATA_ADDR
|
||||
munmap(output_file_data, RWDATA_END)
|
||||
close(output_fd)
|
||||
close(address_map_fd)
|
||||
|
||||
;ident_list_printx64(global_variables)
|
||||
;puts(.str_types_bytes_used)
|
||||
|
@ -340,6 +364,10 @@ function main
|
|||
|
||||
exit(0)
|
||||
|
||||
:str_addrmap_filename
|
||||
string address_map.txt
|
||||
byte 0
|
||||
|
||||
:str_types_bytes_used
|
||||
string types_bytes_used:
|
||||
byte 32
|
||||
|
|
29
05/main.c
29
05/main.c
|
@ -1,17 +1,18 @@
|
|||
#define _STDLIB_DEBUG
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <float.h>
|
||||
#include <setjmp.h>
|
||||
/* #define _STDLIB_DEBUG */
|
||||
/* #include <math.h> */
|
||||
/* #include <stdio.h> */
|
||||
/* #include <signal.h> */
|
||||
/* #include <stdlib.h> */
|
||||
/* #include <string.h> */
|
||||
/* #include <time.h> */
|
||||
/* #include <float.h> */
|
||||
/* #include <setjmp.h> */
|
||||
/* */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
jmp_buf test;
|
||||
setjmp(test);
|
||||
longjmp(test, 5);
|
||||
return 0;
|
||||
char *p = "a";
|
||||
char s[] = "hello\0there";
|
||||
|
||||
int _main(int argc, char **argv) {
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef CONFIG_TCCDIR
|
||||
# define CONFIG_TCCDIR "/usr/local/lib/tcc-bootstrap"
|
||||
#endif
|
||||
#define TCC_VERSION "0.9.27"
|
||||
#define TCC_VERSION "0.9.25"
|
||||
#define CONFIG_TCC_STATIC 1
|
||||
#define TCC_TARGET_X86_64 1
|
||||
#define CONFIG_TCC_ELFINTERP "/XXX"
|
||||
|
|
|
@ -2178,7 +2178,7 @@ typedef struct FlagDef {
|
|||
const char *name;
|
||||
} FlagDef;
|
||||
|
||||
static const FlagDef warning_defs[] = {
|
||||
static FlagDef warning_defs[] = {
|
||||
{ 0, 0, "unsupported" },
|
||||
{ 0, 0, "write-strings" },
|
||||
{ 0, 0, "error" },
|
||||
|
@ -2235,7 +2235,7 @@ int tcc_set_warning(TCCState *s, const char *warning_name, int value)
|
|||
}
|
||||
}
|
||||
|
||||
static const FlagDef flag_defs[] = {
|
||||
static FlagDef flag_defs[] = {
|
||||
{ 0, 0, "unsigned-char" },
|
||||
{ 0, FD_INVERT, "signed-char" },
|
||||
{ 0, FD_INVERT, "common" },
|
||||
|
|
|
@ -37,6 +37,13 @@
|
|||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#include <time.h>
|
||||
#ifdef __GNUC__
|
||||
#include <inttypes.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
|
||||
static const char tcc_keywords[] =
|
||||
#define DEF(id, str) str "\0"
|
||||
#define DEF(id, str) str "\n"
|
||||
#include "tcctok.h"
|
||||
#undef DEF
|
||||
;
|
||||
|
@ -862,6 +862,7 @@ static inline void define_push(int v, int macro_type, int *str, Sym *first_arg)
|
|||
|
||||
s = sym_push2(&define_stack, v, macro_type, (long)str);
|
||||
s->next = first_arg;
|
||||
|
||||
table_ident[v - TOK_IDENT]->sym_define = s;
|
||||
}
|
||||
|
||||
|
@ -2883,7 +2884,7 @@ void preprocess_new()
|
|||
r = p;
|
||||
for(;;) {
|
||||
c = *r++;
|
||||
if (c == '\0')
|
||||
if (c == '\n')
|
||||
break;
|
||||
}
|
||||
ts = tok_alloc(p, r - p - 1);
|
||||
|
|
|
@ -541,6 +541,12 @@ function putx32ln
|
|||
fputx32(1, n)
|
||||
fputc(1, 10)
|
||||
return
|
||||
function fputx32ln
|
||||
argument fd
|
||||
argument n
|
||||
fputx32(fd, n)
|
||||
fputc(fd, 10)
|
||||
return
|
||||
|
||||
function putn
|
||||
argument n
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue