From da8c62f75d893449e232944fc62566c020b4d010 Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 11 Oct 2017 18:13:43 +0200 Subject: various stuff win32/Makefile ("for cygwin") removed - On cygwin, the normal ./configure && make can be used with either cygwin's "GCC for Win32 Toolchain" ./configure --cross-prefix=i686-w64-mingw32- or with an existing tcc: ./configure --cc=/tcc.exe tcctest.c: - exclude test_high_clobbers() on _WIN64 (does not work) tests2/95_bitfield.c: - use 'signed char' for ARM (where default 'char' is unsigned) tests: - remove -I "expr" diff option to allow tests with busybox-diff. libtcc.c, tcc.c: - removed -iwithprefix option. It is supposed to be combined with -iprefix which we don't have either. tccgen.c: - fix assignments and return of 'void', as in void f() { void *p, *q; *p = *q: return *p; } This appears to be allowed but should do nothing. tcc.h, libtcc.c, tccpp.c: - Revert "Introduce VIP sysinclude paths which are always searched first" This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1. The patch was giving tcc's system includes priority over -I which is not how it should be. tccelf.c: - add DT_TEXTREL tag only if text relocations are actually used (which is likely not the case on x86_64) - prepare_dynamic_rel(): avoid relocation of unresolved (weak) symbols tccrun.c: - for HAVE_SELINUX, use two mappings to the same (real) file. (it was so once except the RX mapping wasn't used at all). tccpe.c: - fix relocation constant used for x86_64 (by Andrei E. Warentin) - #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin. tccasm.c: - keep forward asm labels static, otherwise they will endup in dynsym eventually. configure, Makefile: - mingw32: respect ./configure options --bindir --docdir --libdir - allow overriding tcc when building libtcc1.a and libtcc.def with make XTCC= - use $(wildcard ...) for install to allow installing just a cross compiler for example make cross-arm make install - use name -libtcc1.a build-tcc.bat: - add options: -clean, -b bindir --- tccpe.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'tccpe.c') diff --git a/tccpe.c b/tccpe.c index 366f0e7..a67023d 100644 --- a/tccpe.c +++ b/tccpe.c @@ -26,10 +26,12 @@ #ifndef _WIN32 #define stricmp strcasecmp #define strnicmp strncasecmp +#include /* chmod() */ #endif #ifdef TCC_TARGET_X86_64 # define ADDR3264 ULONGLONG +# define PE_IMAGE_REL IMAGE_REL_BASED_DIR64 # define REL_TYPE_DIRECT R_X86_64_64 # define R_XXX_THUNKFIX R_X86_64_PC32 # define R_XXX_RELATIVE R_X86_64_RELATIVE @@ -38,6 +40,7 @@ #elif defined TCC_TARGET_ARM # define ADDR3264 DWORD +# define PE_IMAGE_REL IMAGE_REL_BASED_HIGHLOW # define REL_TYPE_DIRECT R_ARM_ABS32 # define R_XXX_THUNKFIX R_ARM_ABS32 # define R_XXX_RELATIVE R_ARM_RELATIVE @@ -46,6 +49,7 @@ #elif defined TCC_TARGET_I386 # define ADDR3264 DWORD +# define PE_IMAGE_REL IMAGE_REL_BASED_HIGHLOW # define REL_TYPE_DIRECT R_386_32 # define R_XXX_THUNKFIX R_386_32 # define R_XXX_RELATIVE R_386_RELATIVE @@ -54,22 +58,6 @@ #endif -#if 0 -#ifdef _WIN32 -void dbg_printf (const char *fmt, ...) -{ - char buffer[4000]; - va_list arg; - int x; - va_start(arg, fmt); - x = vsprintf (buffer, fmt, arg); - strcpy(buffer+x, "\n"); - OutputDebugString(buffer); -} -#endif -#endif - -/* ----------------------------------------------------------- */ #ifndef IMAGE_NT_SIGNATURE /* ----------------------------------------------------------- */ /* definitions below are from winnt.h */ @@ -241,14 +229,19 @@ typedef struct _IMAGE_BASE_RELOCATION { #define IMAGE_REL_BASED_MIPS_JMPADDR 5 #define IMAGE_REL_BASED_SECTION 6 #define IMAGE_REL_BASED_REL32 7 +#define IMAGE_REL_BASED_DIR64 10 #pragma pack(pop) /* ----------------------------------------------------------- */ #endif /* ndef IMAGE_NT_SIGNATURE */ /* ----------------------------------------------------------- */ -#pragma pack(push, 1) +#ifndef IMAGE_REL_BASED_DIR64 +# define IMAGE_REL_BASED_DIR64 10 +#endif + +#pragma pack(push, 1) struct pe_header { IMAGE_DOS_HEADER doshdr; @@ -281,7 +274,6 @@ struct pe_rsrc_reloc { DWORD size; WORD type; }; - #pragma pack(pop) /* ------------------------------------------------------------- */ @@ -732,6 +724,9 @@ static int pe_write(struct pe_info *pe) fseek(op, offsetof(struct pe_header, opthdr.CheckSum), SEEK_SET); pe_fwrite(&pe_header.opthdr.CheckSum, sizeof pe_header.opthdr.CheckSum, op, NULL); fclose (op); +#ifndef _WIN32 + chmod(pe->filename, 0777); +#endif if (2 == pe->s1->verbose) printf("-------------------------------\n"); @@ -1017,7 +1012,7 @@ static void pe_build_reloc (struct pe_info *pe) } if ((addr -= offset) < (1<<12)) { /* one block spans 4k addresses */ WORD *wp = section_ptr_add(pe->reloc, sizeof (WORD)); - *wp = addr | IMAGE_REL_BASED_HIGHLOW<<12; + *wp = addr | PE_IMAGE_REL<<12; ++count; continue; } @@ -1471,7 +1466,7 @@ static void pe_print_sections(TCCState *s1, const char *fname) /* ------------------------------------------------------------- */ /* helper function for load/store to insert one more indirection */ -#ifndef TCC_TARGET_ARM +#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2) { int r2; -- cgit v1.3.1