From d348a9a51d32cece842b7885d27a411436d7887b Mon Sep 17 00:00:00 2001 From: grischka Date: Tue, 12 Dec 2017 17:57:20 +0100 Subject: final update for 0.9.27 tccgen.c: - fix ldouble asm hack - fix a VLA problem on Win64 (also x86_64-gen.c) - patch_type(): make sure that no symbol ever changes from global to static tcc.c: - tcc -vv: print libtcc1.a path also on win32 tccpe.c, tcctools.c: - use unix LF mode to for .def output files (that is for creating reproducible output trees) Makefile: - suppress some warnings when makeinfo is missing - call 'which install' only on win32 tests/Makefile: - change PATH only on WINNT systems (i.e. not if cross-compiling on linux for win32) - asm-c-connect.test: slim output and do diff tccrun.c tccpe.c *-link.c: - integrate former 'pe_relocate_rva()' into normal relocation This also fixes linkage of the unwind data on WIN64 for -run (reported by Janus Lynggaard Thorborg) tccasm.c, tests/tcctest.c: - fix dot (sym_index of -1 crashed in put_elf_reloc) - massage .set a bit (see test) other: - #define SECTION_ABS removed - ST_DATA Section *strtab_section: removed - put_extern_sym2(): take int section number Conflicts: tccelf.c tccpe.c Conflicts: tccelf.c --- tests/Makefile | 10 +++++----- tests/asm-c-connect-1.c | 17 +++++++++++++---- tests/asm-c-connect-2.c | 21 +++++++++++++++++++-- tests/tcctest.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index f06f39c..5f6777d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -51,9 +51,8 @@ ifndef CONFIG_cross TESTS := $(filter-out cross-%,$(TESTS)) endif -ifdef CONFIG_WIN32 - SEP = $(if $(findstring :\,$(PATH)),;,:) - PATH := $(CURDIR)/$(TOP)$(SEP)$(PATH) # for libtcc_test to find libtcc.dll +ifeq ($(OS),Windows_NT) # for libtcc_test to find libtcc.dll + PATH := $(CURDIR)/$(TOP)$(if $(findstring :\,$(PATH)),;,:)$(PATH) endif RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) @@ -243,8 +242,9 @@ asm-c-connect-sep$(EXESUF): asm-c-connect-1.o asm-c-connect-2.o asm-c-connect-test: asm-c-connect$(EXESUF) asm-c-connect-sep$(EXESUF) @echo ------------ $@ ------------ - ./asm-c-connect$(EXESUF) - ./asm-c-connect-sep$(EXESUF) + ./asm-c-connect$(EXESUF) > asm-c-connect.out1 && cat asm-c-connect.out1 + ./asm-c-connect-sep$(EXESUF) > asm-c-connect.out2 && cat asm-c-connect.out2 + @diff -u asm-c-connect.out1 asm-c-connect.out2 && echo "ok" cross-test : @echo ------------ $@ ------------ diff --git a/tests/asm-c-connect-1.c b/tests/asm-c-connect-1.c index 1849b56..8a28d78 100644 --- a/tests/asm-c-connect-1.c +++ b/tests/asm-c-connect-1.c @@ -8,7 +8,7 @@ static int x1_c(void) { - printf("x1\n"); + printf(" x1"); return 1; } @@ -16,21 +16,30 @@ asm(".text;"_"x1: call "_"x1_c; ret"); void callx4(void); void callx5_again(void); + +void x6() +{ + printf(" x6-1"); +} + int main(int argc, char *argv[]) { + printf("*"); asm("call "_"x1"); asm("call "_"x2"); asm("call "_"x3"); callx4(); asm("call "_"x5"); callx5_again(); + x6(); + printf(" *\n"); return 0; } static int x2(void) { - printf("x2\n"); + printf(" x2"); return 2; } @@ -38,11 +47,11 @@ extern int x3(void); void x4(void) { - printf("x4\n"); + printf(" x4"); } void x5(void); void x5(void) { - printf("x5\n"); + printf(" x5"); } diff --git a/tests/asm-c-connect-2.c b/tests/asm-c-connect-2.c index 5dad26c..3440b40 100644 --- a/tests/asm-c-connect-2.c +++ b/tests/asm-c-connect-2.c @@ -1,19 +1,36 @@ #include +#if defined _WIN32 && !defined __TINYC__ +# define _ "_" +#else +# define _ +#endif + int x3(void) { - printf("x3\n"); + printf(" x3"); return 3; } /* That callx4 is defined globally (as if ".globl callx4") is a TCC extension. GCC doesn't behave like this. */ void callx4(void); -__asm__("callx4: call x4; ret"); +__asm__(_"callx4: call "_"x4; ret;" +#ifndef __TINYC__ + " .global "_"callx4" +#endif +); extern void x5(void); + void callx5_again(void); void callx5_again(void) { x5(); + asm("call "_"x6"); +} + +static void x6() +{ + printf(" x6-2"); } diff --git a/tests/tcctest.c b/tests/tcctest.c index 000523e..57670be 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -3370,6 +3370,37 @@ void test_asm_call(void) #endif } +#if defined __x86_64__ +# define RX "(%rip)" +#else +# define RX +#endif + +void asm_dot_test(void) +{ + int x; + for (x = 1;; ++x) { + int r = x; + switch (x) { + case 1: + asm(".text; lea S"RX",%eax; lea ."RX",%ecx; sub %ecx,%eax; S=.; jmp p0"); + case 2: + asm(".text; jmp .+6; .int 123; mov .-4"RX",%eax; jmp p0"); + case 3: + asm(".data; Y=.; .int 999; X=Y; .int 456; X=.-4"); + asm(".text; mov X"RX",%eax; jmp p0"); + case 4: + asm(".data; X=.; .int 789; Y=.; .int 999"); + asm(".text; mov X"RX",%eax; X=Y; jmp p0"); + case 0: + asm(".text; p0=.; mov %%eax,%0;" : "=m"(r)); break; + } + if (r == x) + break; + printf("asm_dot_test %d: %d\n", x, r); + } +} + void asm_test(void) { char buf[128]; @@ -3457,6 +3488,7 @@ void asm_test(void) trace_console(8, 8); test_asm_dead_code(); test_asm_call(); + asm_dot_test(); return; label1: goto label2; -- cgit v1.3.1