diff options
| author | grischka <grischka> | 2017-07-09 12:07:40 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2017-07-09 12:07:40 +0200 |
| commit | 9f79b62ec4d84d07cf4a2fba969cb67c8f6ed8e5 (patch) | |
| tree | 2ed2cab29b41d9b17c434d4a15565fb3e8387345 /tccpe.c | |
| parent | 6c468c10f70d74e962591a0584765e42ce1bcaf2 (diff) | |
| download | tinycc-9f79b62ec4d84d07cf4a2fba969cb67c8f6ed8e5.tar.gz tinycc-9f79b62ec4d84d07cf4a2fba969cb67c8f6ed8e5.tar.bz2 | |
unsorted adjustments
- configure
* use aarch64 instead of arm64
- Makefile
* rename the custom include file to "config-extra.mak"
* Also avoid "rm -r /*" if $(tccdir) is empty
- pp/Makefile
* fix .expect generation with gcc
- tcc.h
* cleanup #defines for _MSC_VER
- tccgen.c:
* fix const-propagation for &,|
* fix anonymous named struct (ms-extension) and enable
-fms-extension by default
- i386-gen.c
* clear VT_DEFSIGN
- x86_64-gen.c/win64:
* fix passing structs in registers
* fix alloca (need to keep "func_scratch" below each alloca area on stack)
(This allows to compile a working gnu-make on win64)
- tccpp.c
* alternative approach to 37999a4fbf3487b363fd0c2f9b7ab622401b202a
This is to avoid some slowdown with ## token pasting.
* get_tok_str() : return <eof> for TOK_EOF
* -funsigned-char: apply to "string" literals as well
- tccpe/tools.c: -impdef: support both 32 and 64 bit dlls anyway
Diffstat (limited to 'tccpe.c')
| -rw-r--r-- | tccpe.c | 37 |
1 files changed, 18 insertions, 19 deletions
@@ -1547,11 +1547,7 @@ PUB_FUNC int tcc_get_dllexports(const char *filename, char **pp) IMAGE_DOS_HEADER dh; IMAGE_FILE_HEADER ih; DWORD sig, ref, addr, ptr, namep; -#ifdef TCC_TARGET_X86_64 - IMAGE_OPTIONAL_HEADER64 oh; -#else - IMAGE_OPTIONAL_HEADER32 oh; -#endif + int pef_hdroffset, opt_hdroffset, sec_hdroffset; n = n0 = 0; @@ -1562,7 +1558,6 @@ PUB_FUNC int tcc_get_dllexports(const char *filename, char **pp) if (fd < 0) goto the_end_1; ret = 1; - if (!read_mem(fd, 0, &dh, sizeof dh)) goto the_end; if (!read_mem(fd, dh.e_lfanew, &sig, sizeof sig)) @@ -1572,22 +1567,26 @@ PUB_FUNC int tcc_get_dllexports(const char *filename, char **pp) pef_hdroffset = dh.e_lfanew + sizeof sig; if (!read_mem(fd, pef_hdroffset, &ih, sizeof ih)) goto the_end; - if (IMAGE_FILE_MACHINE != ih.Machine) { - if (ih.Machine == 0x014C) - ret = 32; - else if (ih.Machine == 0x8664) - ret = 64; - goto the_end; - } opt_hdroffset = pef_hdroffset + sizeof ih; - sec_hdroffset = opt_hdroffset + sizeof oh; - if (!read_mem(fd, opt_hdroffset, &oh, sizeof oh)) + if (ih.Machine == 0x014C) { + IMAGE_OPTIONAL_HEADER32 oh; + sec_hdroffset = opt_hdroffset + sizeof oh; + if (!read_mem(fd, opt_hdroffset, &oh, sizeof oh)) + goto the_end; + if (IMAGE_DIRECTORY_ENTRY_EXPORT >= oh.NumberOfRvaAndSizes) + goto the_end_0; + addr = oh.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + } else if (ih.Machine == 0x8664) { + IMAGE_OPTIONAL_HEADER64 oh; + sec_hdroffset = opt_hdroffset + sizeof oh; + if (!read_mem(fd, opt_hdroffset, &oh, sizeof oh)) + goto the_end; + if (IMAGE_DIRECTORY_ENTRY_EXPORT >= oh.NumberOfRvaAndSizes) + goto the_end_0; + addr = oh.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + } else goto the_end; - if (IMAGE_DIRECTORY_ENTRY_EXPORT >= oh.NumberOfRvaAndSizes) - goto the_end_0; - - addr = oh.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; //printf("addr: %08x\n", addr); for (i = 0; i < ih.NumberOfSections; ++i) { if (!read_mem(fd, sec_hdroffset + i * sizeof ish, &ish, sizeof ish)) |
