mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-24 07:50:12 +08:00
x86-64: use uplong for symbol values
This commit is contained in:
parent
2341ee5142
commit
5299142286
2
libtcc.c
2
libtcc.c
@ -1213,7 +1213,7 @@ LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, void *val)
|
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val)
|
||||||
{
|
{
|
||||||
#ifdef TCC_TARGET_PE
|
#ifdef TCC_TARGET_PE
|
||||||
pe_putimport(s, 0, name, val);
|
pe_putimport(s, 0, name, val);
|
||||||
|
2
libtcc.h
2
libtcc.h
@ -80,7 +80,7 @@ LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
|
|||||||
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
|
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
|
||||||
|
|
||||||
/* add a symbol to the compiled program */
|
/* add a symbol to the compiled program */
|
||||||
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, void *val);
|
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val);
|
||||||
|
|
||||||
/* output an executable, library or object file. DO NOT call
|
/* output an executable, library or object file. DO NOT call
|
||||||
tcc_relocate() before. */
|
tcc_relocate() before. */
|
||||||
|
2
tcc.h
2
tcc.h
@ -1062,7 +1062,7 @@ typedef struct {
|
|||||||
ST_FUNC Section *new_symtab(TCCState *s1, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags);
|
ST_FUNC Section *new_symtab(TCCState *s1, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags);
|
||||||
|
|
||||||
ST_FUNC int put_elf_str(Section *s, const char *sym);
|
ST_FUNC int put_elf_str(Section *s, const char *sym);
|
||||||
ST_FUNC int put_elf_sym(Section *s, unsigned long value, unsigned long size, int info, int other, int shndx, const char *name);
|
ST_FUNC int put_elf_sym(Section *s, uplong value, unsigned long size, int info, int other, int shndx, const char *name);
|
||||||
ST_FUNC int add_elf_sym(Section *s, uplong value, unsigned long size, int info, int other, int sh_num, const char *name);
|
ST_FUNC int add_elf_sym(Section *s, uplong value, unsigned long size, int info, int other, int sh_num, const char *name);
|
||||||
ST_FUNC int find_elf_sym(Section *s, const char *name);
|
ST_FUNC int find_elf_sym(Section *s, const char *name);
|
||||||
ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol);
|
ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol);
|
||||||
|
20
tccelf.c
20
tccelf.c
@ -97,8 +97,7 @@ static void rebuild_hash(Section *s, unsigned int nb_buckets)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return the symbol number */
|
/* return the symbol number */
|
||||||
ST_FUNC int put_elf_sym(Section *s,
|
ST_FUNC int put_elf_sym(Section *s, uplong value, unsigned long size,
|
||||||
unsigned long value, unsigned long size,
|
|
||||||
int info, int other, int shndx, const char *name)
|
int info, int other, int shndx, const char *name)
|
||||||
{
|
{
|
||||||
int name_offset, sym_index;
|
int name_offset, sym_index;
|
||||||
@ -483,7 +482,7 @@ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve)
|
|||||||
#ifndef TCC_TARGET_PE
|
#ifndef TCC_TARGET_PE
|
||||||
#ifdef TCC_TARGET_X86_64
|
#ifdef TCC_TARGET_X86_64
|
||||||
#define JMP_TABLE_ENTRY_SIZE 14
|
#define JMP_TABLE_ENTRY_SIZE 14
|
||||||
static unsigned long add_jmp_table(TCCState *s1, unsigned long val)
|
static uplong add_jmp_table(TCCState *s1, uplong val)
|
||||||
{
|
{
|
||||||
char *p = s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset;
|
char *p = s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset;
|
||||||
s1->runtime_plt_and_got_offset += JMP_TABLE_ENTRY_SIZE;
|
s1->runtime_plt_and_got_offset += JMP_TABLE_ENTRY_SIZE;
|
||||||
@ -491,17 +490,16 @@ static unsigned long add_jmp_table(TCCState *s1, unsigned long val)
|
|||||||
p[0] = 0xff;
|
p[0] = 0xff;
|
||||||
p[1] = 0x25;
|
p[1] = 0x25;
|
||||||
*(int *)(p + 2) = 0;
|
*(int *)(p + 2) = 0;
|
||||||
*(unsigned long *)(p + 6) = val;
|
*(uplong *)(p + 6) = val;
|
||||||
return (unsigned long)p;
|
return (uplong)p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long add_got_table(TCCState *s1, unsigned long val)
|
static uplong add_got_table(TCCState *s1, uplong val)
|
||||||
{
|
{
|
||||||
unsigned long *p =(unsigned long *)(s1->runtime_plt_and_got +
|
uplong *p = (uplong *)(s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset);
|
||||||
s1->runtime_plt_and_got_offset);
|
s1->runtime_plt_and_got_offset += sizeof(uplong);
|
||||||
s1->runtime_plt_and_got_offset += sizeof(void *);
|
|
||||||
*p = val;
|
*p = val;
|
||||||
return (unsigned long)p;
|
return (uplong)p;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -514,7 +512,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
|
|||||||
ElfW(Sym) *sym;
|
ElfW(Sym) *sym;
|
||||||
int type, sym_index;
|
int type, sym_index;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
unsigned long val, addr;
|
uplong val, addr;
|
||||||
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
|
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
|
||||||
int esym_index;
|
int esym_index;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user