aboutsummaryrefslogtreecommitdiff
path: root/x86_64-gen.c
diff options
context:
space:
mode:
Diffstat (limited to 'x86_64-gen.c')
-rw-r--r--x86_64-gen.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/x86_64-gen.c b/x86_64-gen.c
index 86e097e..c94eb05 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -145,6 +145,8 @@ static int func_ret_sub;
ST_FUNC void g(int c)
{
int ind1;
+ if (nocode_wanted)
+ return;
ind1 = ind + 1;
if (ind1 > cur_text_section->data_allocated)
section_realloc(cur_text_section, ind1);
@@ -213,9 +215,6 @@ void gsym(int t)
gsym_addr(t, ind);
}
-/* psym is used to put an instruction with a data field which is a
- reference to a symbol. It is in fact the same as oad ! */
-#define psym oad
static int is64_type(int t)
{
@@ -227,18 +226,18 @@ static int is64_type(int t)
/* instruction + 4 bytes data. Return the address of the data */
ST_FUNC int oad(int c, int s)
{
- int ind1;
-
+ int t;
+ if (nocode_wanted)
+ return s;
o(c);
- ind1 = ind + 4;
- if (ind1 > cur_text_section->data_allocated)
- section_realloc(cur_text_section, ind1);
- write32le(cur_text_section->data + ind, s);
- s = ind;
- ind = ind1;
- return s;
+ t = ind;
+ gen_le32(s);
+ return t;
}
+/* generate jmp to a label */
+#define gjmp2(instr,lbl) oad(instr,lbl)
+
ST_FUNC void gen_addr32(int r, Sym *sym, long c)
{
if (r & VT_SYM)
@@ -1703,7 +1702,7 @@ void gfunc_epilog(void)
/* generate a jump to a label */
int gjmp(int t)
{
- return psym(0xe9, t);
+ return gjmp2(0xe9, t);
}
/* generate a jump to a fixed address */
@@ -1749,7 +1748,10 @@ ST_FUNC void gtst_addr(int inv, int a)
ST_FUNC int gtst(int inv, int t)
{
int v = vtop->r & VT_VALMASK;
- if (v == VT_CMP) {
+
+ if (nocode_wanted) {
+ ;
+ } else if (v == VT_CMP) {
/* fast case : can jump directly since flags are set */
if (vtop->c.i & 0x100)
{
@@ -1766,11 +1768,11 @@ ST_FUNC int gtst(int inv, int t)
else
{
g(0x0f);
- t = psym(0x8a, t); /* jp t */
+ t = gjmp2(0x8a, t); /* jp t */
}
}
g(0x0f);
- t = psym((vtop->c.i - 16) ^ inv, t);
+ t = gjmp2((vtop->c.i - 16) ^ inv, t);
} else if (v == VT_JMP || v == VT_JMPI) {
/* && or || optimization */
if ((v & 1) == inv) {