aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji _at_ gmail.com>2009-04-13 00:27:04 +0900
committergrischka <grischka>2009-04-18 15:08:01 +0200
commit830b7533c99f86203c4fbaf94897679678c3bad0 (patch)
treeed583dda98119b1248b857bdd20e22db457de0d5 /tcc.c
parent6c10429aa5e7c65e725ed1989ddb856bbf7283aa (diff)
downloadtinycc-830b7533c99f86203c4fbaf94897679678c3bad0.tar.gz
tinycc-830b7533c99f86203c4fbaf94897679678c3bad0.tar.bz2
Generate PIC code so that we can create shared objects properly.
- Add got_table in TCCState. This approach is naive and the distance between executable code and GOT can be longer than 32bit. - Handle R_X86_64_GOTPCREL properly. We use got_table for TCC_OUTPUT_MEMORY case for now. - Fix load() and store() so that they access global variables via GOT.
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tcc.c b/tcc.c
index 548440d..02da926 100644
--- a/tcc.c
+++ b/tcc.c
@@ -544,9 +544,12 @@ struct TCCState {
FILE *outfile;
#ifdef TCC_TARGET_X86_64
- /* buffer to store jump tables */
+ /* buffer to store jump tables used when the output is memory */
char *jmp_table;
int jmp_table_num;
+ /* buffer to store got tables used when the output is memory */
+ void **got_table;
+ int got_table_num;
#endif
};
@@ -10505,6 +10508,7 @@ TCCState *tcc_new(void)
#ifdef TCC_TARGET_X86_64
s->jmp_table = NULL;
+ s->got_table = NULL;
#endif
return s;
}
@@ -10544,6 +10548,7 @@ void tcc_delete(TCCState *s1)
#ifdef TCC_TARGET_X86_64
tcc_free(s1->jmp_table);
+ tcc_free(s1->got_table);
#endif
tcc_free(s1);
}