Fixes for various 64-bit hosting problems.

svn path=/trunk/; revision=17194
This commit is contained in:
Art Yerkes 2005-08-08 04:26:23 +00:00
parent a3bc4d9c07
commit 20732be74c
6 changed files with 65 additions and 42 deletions

View file

@ -44,7 +44,7 @@ typedef int LONG;
#define IMAGE_SCN_MEM_DISCARDABLE 0x2000000
#define IMAGE_SCN_MEM_NOT_PAGED 0x8000000
#define FIELD_OFFSET(t,f) ((LONG)&(((t*)0)->f))
#define IMAGE_FIRST_SECTION(h) ((PIMAGE_SECTION_HEADER) ((DWORD)h+FIELD_OFFSET(IMAGE_NT_HEADERS,OptionalHeader)+((PIMAGE_NT_HEADERS)(h))->FileHeader.SizeOfOptionalHeader))
#define IMAGE_FIRST_SECTION(h) ((PIMAGE_SECTION_HEADER) ((unsigned long)h+FIELD_OFFSET(IMAGE_NT_HEADERS,OptionalHeader)+((PIMAGE_NT_HEADERS)(h))->FileHeader.SizeOfOptionalHeader))
#define IMAGE_DIRECTORY_ENTRY_EXPORT 0
#pragma pack(push,2)

View file

@ -23,6 +23,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "rsym.h"
@ -809,6 +810,7 @@ int main(int argc, char* argv[])
PEFileHeader = (PIMAGE_FILE_HEADER)((char *) FileData + PEDosHeader->e_lfanew + sizeof(ULONG));
/* Locate optional header */
assert(sizeof(ULONG) == 4);
PEOptHeader = (PIMAGE_OPTIONAL_HEADER)(PEFileHeader + 1);
ImageBase = PEOptHeader->ImageBase;

View file

@ -11,15 +11,27 @@
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
typedef unsigned char BYTE;
typedef unsigned char UCHAR;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned short USHORT;
#if defined(__x86_64__) && defined(linux)
typedef signed int LONG;
typedef unsigned int ULONG;
typedef unsigned int DWORD;
#else
typedef signed long LONG;
typedef unsigned long ULONG;
typedef unsigned long DWORD;
#endif
#if defined(_WIN64)
typedef unsigned __int64 ULONG_PTR;
#else
#if defined(__x86_64__) && defined(linux)
typedef unsigned int ULONG_PTR;
#else
typedef unsigned long ULONG_PTR;
#endif
#endif
#pragma pack(push,2)
typedef struct _IMAGE_DOS_HEADER {
@ -129,42 +141,42 @@ typedef struct _IMAGE_BASE_RELOCATION {
typedef struct {
unsigned short f_magic; /* magic number */
unsigned short f_nscns; /* number of sections */
unsigned long f_timdat; /* time & date stamp */
unsigned long f_symptr; /* file pointer to symtab */
unsigned long f_nsyms; /* number of symtab entries */
unsigned short f_opthdr; /* sizeof(optional hdr) */
unsigned short f_flags; /* flags */
USHORT f_magic; /* magic number */
USHORT f_nscns; /* number of sections */
ULONG f_timdat; /* time & date stamp */
ULONG f_symptr; /* file pointer to symtab */
ULONG f_nsyms; /* number of symtab entries */
USHORT f_opthdr; /* sizeof(optional hdr) */
USHORT f_flags; /* flags */
} FILHDR;
typedef struct {
char s_name[8]; /* section name */
unsigned long s_paddr; /* physical address, aliased s_nlib */
unsigned long s_vaddr; /* virtual address */
unsigned long s_size; /* section size */
unsigned long s_scnptr; /* file ptr to raw data for section */
unsigned long s_relptr; /* file ptr to relocation */
unsigned long s_lnnoptr; /* file ptr to line numbers */
unsigned short s_nreloc; /* number of relocation entries */
unsigned short s_nlnno; /* number of line number entries */
unsigned long s_flags; /* flags */
ULONG s_paddr; /* physical address, aliased s_nlib */
ULONG s_vaddr; /* virtual address */
ULONG s_size; /* section size */
ULONG s_scnptr; /* file ptr to raw data for section */
ULONG s_relptr; /* file ptr to relocation */
ULONG s_lnnoptr; /* file ptr to line numbers */
USHORT s_nreloc; /* number of relocation entries */
USHORT s_nlnno; /* number of line number entries */
ULONG s_flags; /* flags */
} SCNHDR;
#pragma pack(pop)
typedef struct _SYMBOLFILE_HEADER {
unsigned long SymbolsOffset;
unsigned long SymbolsLength;
unsigned long StringsOffset;
unsigned long StringsLength;
ULONG SymbolsOffset;
ULONG SymbolsLength;
ULONG StringsOffset;
ULONG StringsLength;
} SYMBOLFILE_HEADER, *PSYMBOLFILE_HEADER;
typedef struct _STAB_ENTRY {
unsigned long n_strx; /* index into string table of name */
unsigned char n_type; /* type of symbol */
unsigned char n_other; /* misc info (usually empty) */
unsigned short n_desc; /* description field */
unsigned long n_value; /* value of symbol */
ULONG n_strx; /* index into string table of name */
UCHAR n_type; /* type of symbol */
UCHAR n_other; /* misc info (usually empty) */
USHORT n_desc; /* description field */
ULONG n_value; /* value of symbol */
} STAB_ENTRY, *PSTAB_ENTRY;
#define N_FUN 0x24
@ -234,17 +246,17 @@ typedef struct _COFF_SYMENT
char e_name[E_SYMNMLEN];
struct
{
unsigned long e_zeroes;
unsigned long e_offset;
ULONG e_zeroes;
ULONG e_offset;
}
e;
}
e;
unsigned long e_value;
ULONG e_value;
short e_scnum;
unsigned short e_type;
unsigned char e_sclass;
unsigned char e_numaux;
USHORT e_type;
UCHAR e_sclass;
UCHAR e_numaux;
} COFF_SYMENT, *PCOFF_SYMENT;
#pragma pack(pop)

View file

@ -46,7 +46,7 @@ int display_warnings = 0;
int kill_at = 0;
int debugging = 0;
#ifdef __i386__
#if defined(__i386__) || defined(__x86_64__)
enum target_cpu target_cpu = CPU_x86;
#elif defined(__sparc__)
enum target_cpu target_cpu = CPU_SPARC;

View file

@ -43,6 +43,13 @@
#include "winuser.h"
#include "wine/unicode.h"
/* Fix 64-bit host, re: put_dword */
#if defined(linux) && defined(__x86_64__)
typedef unsigned int HOST_DWORD;
#else
typedef unsigned long HOST_DWORD;
#endif
#define SetResSize(res, tag) set_dword((res), (tag), (res)->size - get_dword((res), (tag)))
res_t *new_res(void)
@ -114,7 +121,9 @@ void put_word(res_t *res, unsigned w)
void put_dword(res_t *res, unsigned d)
{
if(res->allocsize - res->size < sizeof(DWORD))
assert(sizeof(HOST_DWORD) == 4);
if(res->allocsize - res->size < sizeof(HOST_DWORD))
grow_res(res, RES_BLOCKSIZE);
switch(byteorder)
{
@ -138,7 +147,7 @@ void put_dword(res_t *res, unsigned d)
res->data[res->size+0] = LOBYTE(LOWORD(d));
break;
}
res->size += sizeof(DWORD);
res->size += sizeof(HOST_DWORD);
}
static void put_pad(res_t *res)
@ -223,7 +232,7 @@ static void set_dword(res_t *res, int ofs, unsigned d)
* Remarks :
*****************************************************************************
*/
static DWORD get_dword(res_t *res, int ofs)
static HOST_DWORD get_dword(res_t *res, int ofs)
{
switch(byteorder)
{
@ -434,7 +443,7 @@ static void put_raw_data(res_t *res, raw_data_t *raw, int offset)
*****************************************************************************
*/
static int put_res_header(res_t *res, int type, name_id_t *ntype, name_id_t *name,
DWORD memopt, lvc_t *lvc)
HOST_DWORD memopt, lvc_t *lvc)
{
if(win32)
{
@ -452,8 +461,8 @@ static int put_res_header(res_t *res, int type, name_id_t *ntype, name_id_t *nam
put_dword(res, 0); /* DataVersion */
put_word(res, memopt); /* Memory options */
put_lvc(res, lvc); /* Language, version and characts */
set_dword(res, 0*sizeof(DWORD), res->size); /* Set preliminary resource */
set_dword(res, 1*sizeof(DWORD), res->size); /* Set HeaderSize */
set_dword(res, 0*sizeof(HOST_DWORD), res->size); /* Set preliminary resource */
set_dword(res, 1*sizeof(HOST_DWORD), res->size); /* Set HeaderSize */
res->dataidx = res->size;
return 0;
}
@ -1415,7 +1424,7 @@ static res_t *stringtable2res(stringtable_t *stt)
name_id_t name;
int i;
int restag;
DWORD lastsize = 0;
HOST_DWORD lastsize = 0;
assert(stt != NULL);
res = new_res();

View file

@ -1533,7 +1533,7 @@ typedef struct _ACL_SIZE_INFORMATION {
} ACL_SIZE_INFORMATION;
/* FIXME: add more machines */
#ifdef _X86_
#if defined(_X86_) || defined(linux)
#define SIZE_OF_80387_REGISTERS 80
#define CONTEXT_i386 0x10000
#define CONTEXT_i486 0x10000