aboutsummaryrefslogtreecommitdiff
path: root/tccelf.c
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji _at_ gmail.com>2009-04-13 03:22:08 +0900
committergrischka <grischka>2009-04-18 15:08:01 +0200
commitfcf2e5981fe5e37e3aee633b414486311e54bc8e (patch)
treec6d2a56070f03622b184654bb2b37dc58a038ea8 /tccelf.c
parent830b7533c99f86203c4fbaf94897679678c3bad0 (diff)
downloadtinycc-fcf2e5981fe5e37e3aee633b414486311e54bc8e.tar.gz
tinycc-fcf2e5981fe5e37e3aee633b414486311e54bc8e.tar.bz2
x86-64: Combine buffers of sections before we call tcc_run().
- Now we can run tcc -run tcc.c successfully, though there are some bugs. - Remove jmp_table and got_table and use text_section for got and plt entries. - Combine buffers in tcc_relocate(). - Use R_X86_64_64 instead of R_X86_64_32 for R_DATA_32 (now the name R_DATA_32 is inappropriate...).
Diffstat (limited to 'tccelf.c')
-rw-r--r--tccelf.c30
1 files changed, 3 insertions, 27 deletions
diff --git a/tccelf.c b/tccelf.c
index 56ee75a..6cf11e2 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -479,22 +479,9 @@ static void relocate_syms(TCCState *s1, int do_resolve)
#ifdef TCC_TARGET_X86_64
#define JMP_TABLE_ENTRY_SIZE 14
-#define JMP_TABLE_ENTRY_MAX_NUM 4096
static unsigned long add_jmp_table(TCCState *s1, unsigned long val)
{
- char *p;
- if (!s1->jmp_table) {
- int size = JMP_TABLE_ENTRY_SIZE * JMP_TABLE_ENTRY_MAX_NUM;
- s1->jmp_table_num = 0;
- s1->jmp_table = (char *)tcc_malloc(size);
- set_pages_executable(s1->jmp_table, size);
- }
- if (s1->jmp_table_num == JMP_TABLE_ENTRY_MAX_NUM) {
- error("relocating >%d symbols are not supported",
- JMP_TABLE_ENTRY_MAX_NUM);
- }
- p = s1->jmp_table + s1->jmp_table_num * JMP_TABLE_ENTRY_SIZE;
- s1->jmp_table_num++;
+ char *p = (char *)section_ptr_add(text_section, JMP_TABLE_ENTRY_SIZE);
/* jmp *0x0(%rip) */
p[0] = 0xff;
p[1] = 0x25;
@@ -503,21 +490,10 @@ static unsigned long add_jmp_table(TCCState *s1, unsigned long val)
return (unsigned long)p;
}
-#define GOT_TABLE_ENTRY_MAX_NUM 4096
static unsigned long add_got_table(TCCState *s1, unsigned long val)
{
- unsigned long *p;
- if (!s1->got_table) {
- int size = sizeof(void *) * GOT_TABLE_ENTRY_MAX_NUM;
- s1->got_table_num = 0;
- s1->got_table = (char *)tcc_malloc(size);
- }
- if (s1->got_table_num == GOT_TABLE_ENTRY_MAX_NUM) {
- error("relocating >%d symbols are not supported",
- GOT_TABLE_ENTRY_MAX_NUM);
- }
- p = s1->got_table + s1->got_table_num;
- s1->got_table_num++;
+ unsigned long *p =
+ (unsigned long *)section_ptr_add(text_section, sizeof(void *));
*p = val;
return (unsigned long)p;
}