fixed += bug with non-char pointers
tcc 0.9.25 can't compile musl (or any libc, probably). will probably need to write libc for tcc, then compile gcc or a later version of tcc with it
This commit is contained in:
parent
e94266df3d
commit
c42c5d94b8
4 changed files with 15 additions and 8 deletions
|
@ -1566,6 +1566,7 @@ function generate_push_expression
|
|||
local addr1
|
||||
local addr2
|
||||
local type
|
||||
local type2
|
||||
|
||||
type = expr + 4
|
||||
type = *4type
|
||||
|
@ -1721,6 +1722,8 @@ function generate_push_expression
|
|||
:generate_assign_add
|
||||
expr += 8
|
||||
p = expression_get_end(expr)
|
||||
type2 = p + 4
|
||||
type2 = *4type2
|
||||
p = generate_push_expression_casted(statement, p, type)
|
||||
generate_push_address_of_expression(statement, expr)
|
||||
expr = p
|
||||
|
@ -1729,7 +1732,7 @@ function generate_push_expression
|
|||
generate_stack_dereference(statement, type)
|
||||
emit_mov_rax_qword_rsp_plus_imm32(16) ; mov rax, [rsp+16] (addend)
|
||||
emit_push_rax() ; push rax
|
||||
generate_stack_add(statement, type, type, type)
|
||||
generate_stack_add(statement, type, type2, type)
|
||||
emit_mov_rax_qword_rsp_plus_imm32(8) ; mov rax, [rsp+8] (address)
|
||||
emit_push_rax() ; push rax
|
||||
generate_stack_assign(statement, type)
|
||||
|
@ -1740,6 +1743,8 @@ function generate_push_expression
|
|||
:generate_assign_sub
|
||||
expr += 8
|
||||
p = expression_get_end(expr)
|
||||
type2 = p + 4
|
||||
type2 = *4type2
|
||||
p = generate_push_expression_casted(statement, p, type)
|
||||
generate_push_address_of_expression(statement, expr)
|
||||
expr = p
|
||||
|
@ -1748,7 +1753,7 @@ function generate_push_expression
|
|||
generate_stack_dereference(statement, type)
|
||||
emit_mov_rax_qword_rsp_plus_imm32(16) ; mov rax, [rsp+16] (2nd operand)
|
||||
emit_push_rax() ; push rax
|
||||
generate_stack_sub(statement, type, type, type)
|
||||
generate_stack_sub(statement, type, type2, type)
|
||||
emit_mov_rax_qword_rsp_plus_imm32(8) ; mov rax, [rsp+8] (address)
|
||||
emit_push_rax() ; push rax
|
||||
generate_stack_assign(statement, type)
|
||||
|
|
12
05/main.c
12
05/main.c
|
@ -1,6 +1,6 @@
|
|||
/* #define _STDLIB_DEBUG */
|
||||
/* #include <math.h> */
|
||||
/* #include <stdio.h> */
|
||||
#include <stdio.h>
|
||||
/* #include <signal.h> */
|
||||
/* #include <stdlib.h> */
|
||||
/* #include <string.h> */
|
||||
|
@ -9,10 +9,10 @@
|
|||
/* #include <setjmp.h> */
|
||||
/* */
|
||||
|
||||
char *p = "a";
|
||||
char s[] = "hello\0there";
|
||||
|
||||
int _main(int argc, char **argv) {
|
||||
return s;
|
||||
int main(int argc, char **argv) {
|
||||
int *p = 0x100;
|
||||
p += 1;
|
||||
printf("%p\n",p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -264,6 +264,7 @@ int wait4(int pid, int *status, int options, struct rusage *rusage) {
|
|||
#define SIGSEGV 11
|
||||
#define SIGTERM 15
|
||||
#define SIGBUS 7
|
||||
#define SIGTRAP 5
|
||||
void abort(void) {
|
||||
kill(getpid(), SIGABRT);
|
||||
}
|
||||
|
|
|
@ -264,6 +264,7 @@ int wait4(int pid, int *status, int options, struct rusage *rusage) {
|
|||
#define SIGSEGV 11
|
||||
#define SIGTERM 15
|
||||
#define SIGBUS 7
|
||||
#define SIGTRAP 5
|
||||
void abort(void) {
|
||||
kill(getpid(), SIGABRT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue