aboutsummaryrefslogtreecommitdiff
path: root/dynasm/dasm_arm.h
diff options
context:
space:
mode:
Diffstat (limited to 'dynasm/dasm_arm.h')
-rw-r--r--dynasm/dasm_arm.h16
1 files changed, 5 insertions, 11 deletions
diff --git a/dynasm/dasm_arm.h b/dynasm/dasm_arm.h
index fbfebee0..aa16014e 100644
--- a/dynasm/dasm_arm.h
+++ b/dynasm/dasm_arm.h
@@ -70,7 +70,7 @@ struct dasm_State {
70 size_t lgsize; 70 size_t lgsize;
71 int *pclabels; /* PC label chains/pos ptrs. */ 71 int *pclabels; /* PC label chains/pos ptrs. */
72 size_t pcsize; 72 size_t pcsize;
73 void **globals; /* Array of globals (bias -10). */ 73 void **globals; /* Array of globals. */
74 dasm_Section *section; /* Pointer to active section. */ 74 dasm_Section *section; /* Pointer to active section. */
75 size_t codesize; /* Total size of all code sections. */ 75 size_t codesize; /* Total size of all code sections. */
76 int maxsection; /* 0 <= sectionidx < maxsection. */ 76 int maxsection; /* 0 <= sectionidx < maxsection. */
@@ -87,7 +87,6 @@ void dasm_init(Dst_DECL, int maxsection)
87{ 87{
88 dasm_State *D; 88 dasm_State *D;
89 size_t psz = 0; 89 size_t psz = 0;
90 int i;
91 Dst_REF = NULL; 90 Dst_REF = NULL;
92 DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); 91 DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection));
93 D = Dst_REF; 92 D = Dst_REF;
@@ -98,12 +97,7 @@ void dasm_init(Dst_DECL, int maxsection)
98 D->pcsize = 0; 97 D->pcsize = 0;
99 D->globals = NULL; 98 D->globals = NULL;
100 D->maxsection = maxsection; 99 D->maxsection = maxsection;
101 for (i = 0; i < maxsection; i++) { 100 memset((void *)D->sections, 0, maxsection * sizeof(dasm_Section));
102 D->sections[i].buf = NULL; /* Need this for pass3. */
103 D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i);
104 D->sections[i].bsize = 0;
105 D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */
106 }
107} 101}
108 102
109/* Free DynASM state. */ 103/* Free DynASM state. */
@@ -123,7 +117,7 @@ void dasm_free(Dst_DECL)
123void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) 117void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl)
124{ 118{
125 dasm_State *D = Dst_REF; 119 dasm_State *D = Dst_REF;
126 D->globals = gl - 10; /* Negative bias to compensate for locals. */ 120 D->globals = gl;
127 DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); 121 DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
128} 122}
129 123
@@ -372,7 +366,7 @@ int dasm_encode(Dst_DECL, void *buffer)
372 break; 366 break;
373 case DASM_REL_LG: 367 case DASM_REL_LG:
374 if (n < 0) { 368 if (n < 0) {
375 n = (int)((ptrdiff_t)D->globals[-n] - (ptrdiff_t)cp - 4); 369 n = (int)((ptrdiff_t)D->globals[-n-10] - (ptrdiff_t)cp - 4);
376 goto patchrel; 370 goto patchrel;
377 } 371 }
378 /* fallthrough */ 372 /* fallthrough */
@@ -396,7 +390,7 @@ int dasm_encode(Dst_DECL, void *buffer)
396 } 390 }
397 break; 391 break;
398 case DASM_LABEL_LG: 392 case DASM_LABEL_LG:
399 ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); 393 ins &= 2047; if (ins >= 20) D->globals[ins-20] = (void *)(base + n);
400 break; 394 break;
401 case DASM_LABEL_PC: break; 395 case DASM_LABEL_PC: break;
402 case DASM_IMM: 396 case DASM_IMM: