diff options
Diffstat (limited to '')
-rw-r--r-- | dynasm/dasm_ppc.h | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/dynasm/dasm_ppc.h b/dynasm/dasm_ppc.h index fdb89bce..30b757e3 100644 --- a/dynasm/dasm_ppc.h +++ b/dynasm/dasm_ppc.h | |||
@@ -69,7 +69,7 @@ struct dasm_State { | |||
69 | size_t lgsize; | 69 | size_t lgsize; |
70 | int *pclabels; /* PC label chains/pos ptrs. */ | 70 | int *pclabels; /* PC label chains/pos ptrs. */ |
71 | size_t pcsize; | 71 | size_t pcsize; |
72 | void **globals; /* Array of globals (bias -10). */ | 72 | void **globals; /* Array of globals. */ |
73 | dasm_Section *section; /* Pointer to active section. */ | 73 | dasm_Section *section; /* Pointer to active section. */ |
74 | size_t codesize; /* Total size of all code sections. */ | 74 | size_t codesize; /* Total size of all code sections. */ |
75 | int maxsection; /* 0 <= sectionidx < maxsection. */ | 75 | int maxsection; /* 0 <= sectionidx < maxsection. */ |
@@ -86,7 +86,6 @@ void dasm_init(Dst_DECL, int maxsection) | |||
86 | { | 86 | { |
87 | dasm_State *D; | 87 | dasm_State *D; |
88 | size_t psz = 0; | 88 | size_t psz = 0; |
89 | int i; | ||
90 | Dst_REF = NULL; | 89 | Dst_REF = NULL; |
91 | DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); | 90 | DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); |
92 | D = Dst_REF; | 91 | D = Dst_REF; |
@@ -97,12 +96,7 @@ void dasm_init(Dst_DECL, int maxsection) | |||
97 | D->pcsize = 0; | 96 | D->pcsize = 0; |
98 | D->globals = NULL; | 97 | D->globals = NULL; |
99 | D->maxsection = maxsection; | 98 | D->maxsection = maxsection; |
100 | for (i = 0; i < maxsection; i++) { | 99 | memset((void *)D->sections, 0, maxsection * sizeof(dasm_Section)); |
101 | D->sections[i].buf = NULL; /* Need this for pass3. */ | ||
102 | D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); | ||
103 | D->sections[i].bsize = 0; | ||
104 | D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ | ||
105 | } | ||
106 | } | 100 | } |
107 | 101 | ||
108 | /* Free DynASM state. */ | 102 | /* Free DynASM state. */ |
@@ -122,7 +116,7 @@ void dasm_free(Dst_DECL) | |||
122 | void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) | 116 | void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) |
123 | { | 117 | { |
124 | dasm_State *D = Dst_REF; | 118 | dasm_State *D = Dst_REF; |
125 | D->globals = gl - 10; /* Negative bias to compensate for locals. */ | 119 | D->globals = gl; |
126 | DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); | 120 | DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); |
127 | } | 121 | } |
128 | 122 | ||
@@ -354,7 +348,7 @@ int dasm_encode(Dst_DECL, void *buffer) | |||
354 | break; | 348 | break; |
355 | case DASM_REL_LG: | 349 | case DASM_REL_LG: |
356 | if (n < 0) { | 350 | if (n < 0) { |
357 | n = (int)((ptrdiff_t)D->globals[-n] - (ptrdiff_t)cp); | 351 | n = (int)((ptrdiff_t)D->globals[-n-10] - (ptrdiff_t)cp); |
358 | goto patchrel; | 352 | goto patchrel; |
359 | } | 353 | } |
360 | /* fallthrough */ | 354 | /* fallthrough */ |
@@ -368,7 +362,7 @@ int dasm_encode(Dst_DECL, void *buffer) | |||
368 | cp[-1] |= ((n+4) & ((ins & 2048) ? 0x0000fffc: 0x03fffffc)); | 362 | cp[-1] |= ((n+4) & ((ins & 2048) ? 0x0000fffc: 0x03fffffc)); |
369 | break; | 363 | break; |
370 | case DASM_LABEL_LG: | 364 | case DASM_LABEL_LG: |
371 | ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); | 365 | ins &= 2047; if (ins >= 20) D->globals[ins-20] = (void *)(base + n); |
372 | break; | 366 | break; |
373 | case DASM_LABEL_PC: break; | 367 | case DASM_LABEL_PC: break; |
374 | case DASM_IMM: | 368 | case DASM_IMM: |