23
23
#include "global.h"
24
24
#include "type.h"
25
25
#include "parser.h"
26
+ #include "aa.h"
27
+ #include "tinfo.h"
26
28
#if SCPP
27
29
#include "cpp.h"
28
30
#include "exh.h"
@@ -65,7 +67,7 @@ static int AAoff; // offset of alloca temporary
65
67
*/
66
68
67
69
struct fixlist
68
- { symbol * Lsymbol ; // symbol we don't know about
70
+ { // symbol *Lsymbol; // symbol we don't know about
69
71
int Lseg ; // where the fixup is going (CODE or DATA, never UDATA)
70
72
int Lflags ; // CFxxxx
71
73
targ_size_t Loffset ; // addr of reference to symbol
@@ -75,10 +77,12 @@ struct fixlist
75
77
#endif
76
78
fixlist * Lnext ; // next in threaded list
77
79
78
- static fixlist * start ;
80
+ static AArray * start ;
81
+ static int nodel ; // don't delete from within searchfixlist
79
82
};
80
83
81
- fixlist * fixlist ::start = NULL ;
84
+ AArray * fixlist ::start = NULL ;
85
+ int fixlist ::nodel = 0 ;
82
86
83
87
/*************
84
88
* Size in bytes of each instruction.
@@ -4186,6 +4190,7 @@ unsigned codout(code *c)
4186
4190
c -> Iop = op ^= 1 ; // toggle condition
4187
4191
c -> IFL2 = FLconst ;
4188
4192
c -> IEVpointer2 = I16 ? 3 : 5 ; // skip over JMP block
4193
+ c -> Iflags &= ~CFjmp16 ;
4189
4194
}
4190
4195
}
4191
4196
}
@@ -4745,7 +4750,8 @@ STATIC void do8bit(enum FL fl,union evc *uev)
4745
4750
}
4746
4751
GEN (c );
4747
4752
}
4748
-
4753
+
4754
+
4749
4755
/****************************
4750
4756
* Add to the fix list.
4751
4757
*/
@@ -4758,16 +4764,21 @@ void addtofixlist(symbol *s,targ_size_t soffset,int seg,targ_size_t val,int flag
4758
4764
//printf("addtofixlist(%p '%s')\n",s,s->Sident);
4759
4765
assert (flags );
4760
4766
ln = (fixlist * ) mem_calloc (sizeof (fixlist ));
4761
- ln -> Lsymbol = s ;
4767
+ // ln->Lsymbol = s;
4762
4768
ln -> Loffset = soffset ;
4763
4769
ln -> Lseg = seg ;
4764
4770
ln -> Lflags = flags ;
4765
4771
ln -> Lval = val ;
4766
4772
#if TARGET_OSX
4767
4773
ln -> Lfuncsym = funcsym_p ;
4768
4774
#endif
4769
- ln -> Lnext = fixlist ::start ;
4770
- fixlist ::start = ln ;
4775
+
4776
+ if (!fixlist ::start )
4777
+ fixlist ::start = new AArray (& ti_pvoid , sizeof (fixlist * ));
4778
+ fixlist * * pv = (fixlist * * )fixlist ::start -> get (& s );
4779
+ ln -> Lnext = * pv ;
4780
+ * pv = ln ;
4781
+
4771
4782
#if TARGET_FLAT
4772
4783
numbytes = tysize [TYnptr ];
4773
4784
if (I64 && !(flags & CFoffset64 ))
@@ -4796,13 +4807,16 @@ void addtofixlist(symbol *s,targ_size_t soffset,int seg,targ_size_t val,int flag
4796
4807
*/
4797
4808
4798
4809
void searchfixlist (symbol * s )
4799
- { register fixlist * * lp ,* p ;
4800
-
4801
- //dbg_printf("searchfixlist(%s)\n",s->Sident);
4802
- for (lp = & fixlist ::start ; (p = * lp ) != NULL ;)
4803
- {
4804
- if (s == p -> Lsymbol )
4805
- { //dbg_printf("Found reference at x%lx\n",p->Loffset);
4810
+ {
4811
+ //printf("searchfixlist(%s)\n",s->Sident);
4812
+ if (fixlist ::start )
4813
+ {
4814
+ fixlist * * lp = (fixlist * * )fixlist ::start -> in (& s );
4815
+ if (lp )
4816
+ { fixlist * p ;
4817
+ while ((p = * lp ) != NULL )
4818
+ {
4819
+ //dbg_printf("Found reference at x%lx\n",p->Loffset);
4806
4820
4807
4821
// Determine if it is a self-relative fixup we can
4808
4822
// resolve directly.
@@ -4833,23 +4847,29 @@ void searchfixlist(symbol *s)
4833
4847
}
4834
4848
* lp = p -> Lnext ;
4835
4849
mem_free (p ); /* remove from list */
4850
+ }
4851
+ if (!fixlist ::nodel )
4852
+ fixlist ::start -> del (& s );
4836
4853
}
4837
- else
4838
- lp = & (p -> Lnext );
4839
- }
4854
+ }
4840
4855
}
4841
4856
4842
4857
/****************************
4843
4858
* End of module. Output remaining fixlist elements as references
4844
4859
* to external symbols.
4845
4860
*/
4846
4861
4847
- void outfixlist ( )
4862
+ STATIC int outfixlist_dg ( void * parameter , void * pkey , void * pvalue )
4848
4863
{
4849
- //printf("outfixlist()\n");
4850
- for (fixlist * ln = fixlist ::start ; ln ; ln = fixlist ::start )
4851
- {
4852
- symbol * s = ln -> Lsymbol ;
4864
+ //printf("outfixlist_dg(pkey = %p, pvalue = %p)\n", pkey, pvalue);
4865
+ symbol * s = * (symbol * * )pkey ;
4866
+
4867
+ fixlist * * plnext = (fixlist * * )pvalue ;
4868
+
4869
+ while (* plnext )
4870
+ {
4871
+ fixlist * ln = * plnext ;
4872
+
4853
4873
symbol_debug (s );
4854
4874
//printf("outfixlist '%s' offset %04x\n",s->Sident,ln->Loffset);
4855
4875
@@ -4902,14 +4922,29 @@ void outfixlist()
4902
4922
#else
4903
4923
reftoident (ln -> Lseg ,ln -> Loffset ,s ,ln -> Lval ,ln -> Lflags );
4904
4924
#endif
4905
- fixlist :: start = ln -> Lnext ;
4925
+ * plnext = ln -> Lnext ;
4906
4926
#if TERMCODE
4907
4927
mem_free (ln );
4908
4928
#endif
4909
4929
}
4910
- }
4930
+ }
4931
+ return 0 ;
4911
4932
}
4912
4933
4934
+ void outfixlist ()
4935
+ {
4936
+ //printf("outfixlist()\n");
4937
+ if (fixlist ::start )
4938
+ {
4939
+ fixlist ::nodel ++ ;
4940
+ fixlist ::start -> apply (NULL , & outfixlist_dg );
4941
+ fixlist ::nodel -- ;
4942
+ #if TERMCODE
4943
+ delete fixlist ::start ;
4944
+ fixlist ::start = NULL ;
4945
+ #endif
4946
+ }
4947
+ }
4913
4948
4914
4949
/**********************************
4915
4950
*/
0 commit comments