History

x86-64: use uplong for symbol values

grischka committed 16 years ago

Commit 52991421 parent 2341ee54 files · +13 −15Browse files

Unified · Split

4 files
  1. libtcc.c +1 −1
  2. libtcc.h +1 −1
  3. tcc.h +1 −1
  4. tccelf.c +10 −12
libtcc.c+1−1
@@ -1213,7 +1213,7 @@ LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname) · 1212 unmodified lines
1213 return -1;1213 return -1;
1214}1214}
1215 1215
1216LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, void *val)1216LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val)
1217{1217{
1218#ifdef TCC_TARGET_PE1218#ifdef TCC_TARGET_PE
1219 pe_putimport(s, 0, name, val);1219 pe_putimport(s, 0, name, val);
libtcc.h+1−1
@@ -80,7 +80,7 @@ LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname); · 79 unmodified lines
80LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);80LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
81 81
82/* add a symbol to the compiled program */82/* add a symbol to the compiled program */
83LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, void *val);83LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val);
84 84
85/* output an executable, library or object file. DO NOT call85/* output an executable, library or object file. DO NOT call
86 tcc_relocate() before. */86 tcc_relocate() before. */
tcc.h+1−1
@@ -1062,7 +1062,7 @@ typedef struct { · 1061 unmodified lines
1062ST_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);1062ST_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);
1063 1063
1064ST_FUNC int put_elf_str(Section *s, const char *sym);1064ST_FUNC int put_elf_str(Section *s, const char *sym);
1065ST_FUNC int put_elf_sym(Section *s, unsigned long value, unsigned long size, int info, int other, int shndx, const char *name);1065ST_FUNC int put_elf_sym(Section *s, uplong value, unsigned long size, int info, int other, int shndx, const char *name);
1066ST_FUNC int add_elf_sym(Section *s, uplong value, unsigned long size, int info, int other, int sh_num, const char *name);1066ST_FUNC int add_elf_sym(Section *s, uplong value, unsigned long size, int info, int other, int sh_num, const char *name);
1067ST_FUNC int find_elf_sym(Section *s, const char *name);1067ST_FUNC int find_elf_sym(Section *s, const char *name);
1068ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol);1068ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol);
tccelf.c+10−12
@@ -97,9 +97,8 @@ static void rebuild_hash(Section *s, unsigned int nb_buckets) · 96 unmodified lines
97}97}
98 98
99/* return the symbol number */99/* return the symbol number */
100ST_FUNC int put_elf_sym(Section *s, 100ST_FUNC int put_elf_sym(Section *s, uplong value, unsigned long size,
101 unsigned long value, unsigned long size,101 int info, int other, int shndx, const char *name)
102 int info, int other, int shndx, const char *name)
103{102{
104 int name_offset, sym_index;103 int name_offset, sym_index;
105 int nbuckets, h;104 int nbuckets, h;
@@ -483,7 +482,7 @@ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve) · 377 unmodified lines
483#ifndef TCC_TARGET_PE482#ifndef TCC_TARGET_PE
484#ifdef TCC_TARGET_X86_64483#ifdef TCC_TARGET_X86_64
485#define JMP_TABLE_ENTRY_SIZE 14484#define JMP_TABLE_ENTRY_SIZE 14
486static unsigned long add_jmp_table(TCCState *s1, unsigned long val)485static uplong add_jmp_table(TCCState *s1, uplong val)
487{486{
488 char *p = s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset;487 char *p = s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset;
489 s1->runtime_plt_and_got_offset += JMP_TABLE_ENTRY_SIZE;488 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) · 1 unmodified line
491 p[0] = 0xff;490 p[0] = 0xff;
492 p[1] = 0x25;491 p[1] = 0x25;
493 *(int *)(p + 2) = 0;492 *(int *)(p + 2) = 0;
494 *(unsigned long *)(p + 6) = val;493 *(uplong *)(p + 6) = val;
495 return (unsigned long)p;494 return (uplong)p;
496}495}
497 496
498static unsigned long add_got_table(TCCState *s1, unsigned long val)497static uplong add_got_table(TCCState *s1, uplong val)
499{498{
500 unsigned long *p =(unsigned long *)(s1->runtime_plt_and_got +499 uplong *p = (uplong *)(s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset);
501 s1->runtime_plt_and_got_offset);500 s1->runtime_plt_and_got_offset += sizeof(uplong);
502 s1->runtime_plt_and_got_offset += sizeof(void *);
503 *p = val;501 *p = val;
504 return (unsigned long)p;502 return (uplong)p;
505}503}
506#endif504#endif
507#endif505#endif
@@ -514,7 +512,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 6 unmodified lines
514 ElfW(Sym) *sym;512 ElfW(Sym) *sym;
515 int type, sym_index;513 int type, sym_index;
516 unsigned char *ptr;514 unsigned char *ptr;
517 unsigned long val, addr;515 uplong val, addr;
518#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64516#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
519 int esym_index;517 int esym_index;
520#endif518#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t