aboutsummaryrefslogtreecommitdiff
path: root/dynasm/dasm_arm64.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dynasm/dasm_arm64.h16
1 files changed, 5 insertions, 11 deletions
diff --git a/dynasm/dasm_arm64.h b/dynasm/dasm_arm64.h
index 47c9c37d..e04898f1 100644
--- a/dynasm/dasm_arm64.h
+++ b/dynasm/dasm_arm64.h
@@ -72,7 +72,7 @@ struct dasm_State {
72 size_t lgsize; 72 size_t lgsize;
73 int *pclabels; /* PC label chains/pos ptrs. */ 73 int *pclabels; /* PC label chains/pos ptrs. */
74 size_t pcsize; 74 size_t pcsize;
75 void **globals; /* Array of globals (bias -10). */ 75 void **globals; /* Array of globals. */
76 dasm_Section *section; /* Pointer to active section. */ 76 dasm_Section *section; /* Pointer to active section. */
77 size_t codesize; /* Total size of all code sections. */ 77 size_t codesize; /* Total size of all code sections. */
78 int maxsection; /* 0 <= sectionidx < maxsection. */ 78 int maxsection; /* 0 <= sectionidx < maxsection. */
@@ -89,7 +89,6 @@ void dasm_init(Dst_DECL, int maxsection)
89{ 89{
90 dasm_State *D; 90 dasm_State *D;
91 size_t psz = 0; 91 size_t psz = 0;
92 int i;
93 Dst_REF = NULL; 92 Dst_REF = NULL;
94 DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); 93 DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection));
95 D = Dst_REF; 94 D = Dst_REF;
@@ -100,12 +99,7 @@ void dasm_init(Dst_DECL, int maxsection)
100 D->pcsize = 0; 99 D->pcsize = 0;
101 D->globals = NULL; 100 D->globals = NULL;
102 D->maxsection = maxsection; 101 D->maxsection = maxsection;
103 for (i = 0; i < maxsection; i++) { 102 memset((void *)D->sections, 0, maxsection * sizeof(dasm_Section));
104 D->sections[i].buf = NULL; /* Need this for pass3. */
105 D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i);
106 D->sections[i].bsize = 0;
107 D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */
108 }
109} 103}
110 104
111/* Free DynASM state. */ 105/* Free DynASM state. */
@@ -125,7 +119,7 @@ void dasm_free(Dst_DECL)
125void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) 119void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl)
126{ 120{
127 dasm_State *D = Dst_REF; 121 dasm_State *D = Dst_REF;
128 D->globals = gl - 10; /* Negative bias to compensate for locals. */ 122 D->globals = gl;
129 DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); 123 DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
130} 124}
131 125
@@ -444,7 +438,7 @@ int dasm_encode(Dst_DECL, void *buffer)
444 break; 438 break;
445 case DASM_REL_LG: 439 case DASM_REL_LG:
446 if (n < 0) { 440 if (n < 0) {
447 ptrdiff_t na = (ptrdiff_t)D->globals[-n] - (ptrdiff_t)cp + 4; 441 ptrdiff_t na = (ptrdiff_t)D->globals[-n-10] - (ptrdiff_t)cp + 4;
448 n = (int)na; 442 n = (int)na;
449 CK((ptrdiff_t)n == na, RANGE_REL); 443 CK((ptrdiff_t)n == na, RANGE_REL);
450 goto patchrel; 444 goto patchrel;
@@ -487,7 +481,7 @@ int dasm_encode(Dst_DECL, void *buffer)
487 goto patchrel; 481 goto patchrel;
488 } 482 }
489 case DASM_LABEL_LG: 483 case DASM_LABEL_LG:
490 ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); 484 ins &= 2047; if (ins >= 20) D->globals[ins-20] = (void *)(base + n);
491 break; 485 break;
492 case DASM_LABEL_PC: break; 486 case DASM_LABEL_PC: break;
493 case DASM_IMM: 487 case DASM_IMM: