summaryrefslogtreecommitdiff
path: root/src/buildvm_peobj.c
diff options
context:
space:
mode:
authorMike Pall <mike>2010-02-05 20:15:01 +0100
committerMike Pall <mike>2010-02-05 20:15:01 +0100
commitc4dadf1d67b5f91e7b80d92859eb85ae080f41f0 (patch)
tree2cd0b4a39eac8fad887b530c7727a10b39065078 /src/buildvm_peobj.c
parenta0914c409b615af85eafb7e2787be628483ffde2 (diff)
downloadluajit-c4dadf1d67b5f91e7b80d92859eb85ae080f41f0.tar.gz
luajit-c4dadf1d67b5f91e7b80d92859eb85ae080f41f0.tar.bz2
luajit-c4dadf1d67b5f91e7b80d92859eb85ae080f41f0.zip
Move bytecode offsets from lj_vm.* to generated header.
Diffstat (limited to 'src/buildvm_peobj.c')
-rw-r--r--src/buildvm_peobj.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/buildvm_peobj.c b/src/buildvm_peobj.c
index 49b72930..5f4075af 100644
--- a/src/buildvm_peobj.c
+++ b/src/buildvm_peobj.c
@@ -103,7 +103,6 @@ enum {
103 PEOBJ_SECT_PDATA, 103 PEOBJ_SECT_PDATA,
104 PEOBJ_SECT_XDATA, 104 PEOBJ_SECT_XDATA,
105#endif 105#endif
106 PEOBJ_SECT_RDATA,
107 PEOBJ_SECT_RDATA_Z, 106 PEOBJ_SECT_RDATA_Z,
108 PEOBJ_NSECTIONS 107 PEOBJ_NSECTIONS
109}; 108};
@@ -168,9 +167,6 @@ static void emit_peobj_sym_sect(BuildCtx *ctx, PEsection *pesect, int sect)
168#define emit_peobj_sym_func(ctx, name, ofs) \ 167#define emit_peobj_sym_func(ctx, name, ofs) \
169 emit_peobj_sym(ctx, name, (uint32_t)(ofs), \ 168 emit_peobj_sym(ctx, name, (uint32_t)(ofs), \
170 PEOBJ_SECT_TEXT, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN) 169 PEOBJ_SECT_TEXT, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN)
171#define emit_peobj_sym_rdata(ctx, name, ofs) \
172 emit_peobj_sym(ctx, name, (uint32_t)(ofs), \
173 PEOBJ_SECT_RDATA, PEOBJ_TYPE_NULL, PEOBJ_SCL_EXTERN)
174 170
175/* Emit Windows PE object file. */ 171/* Emit Windows PE object file. */
176void emit_peobj(BuildCtx *ctx) 172void emit_peobj(BuildCtx *ctx)
@@ -218,12 +214,6 @@ void emit_peobj(BuildCtx *ctx)
218 pesect[PEOBJ_SECT_XDATA].flags = 0x40300040; 214 pesect[PEOBJ_SECT_XDATA].flags = 0x40300040;
219#endif 215#endif
220 216
221 memcpy(pesect[PEOBJ_SECT_RDATA].name, ".rdata", sizeof(".rdata")-1);
222 pesect[PEOBJ_SECT_RDATA].ofs = sofs;
223 sofs += (pesect[PEOBJ_SECT_RDATA].size = ctx->npc*sizeof(uint16_t));
224 /* Flags: 40 = read, 30 = align4, 40 = initialized data. */
225 pesect[PEOBJ_SECT_RDATA].flags = 0x40300040;
226
227 memcpy(pesect[PEOBJ_SECT_RDATA_Z].name, ".rdata$Z", sizeof(".rdata$Z")-1); 217 memcpy(pesect[PEOBJ_SECT_RDATA_Z].name, ".rdata$Z", sizeof(".rdata$Z")-1);
228 pesect[PEOBJ_SECT_RDATA_Z].ofs = sofs; 218 pesect[PEOBJ_SECT_RDATA_Z].ofs = sofs;
229 sofs += (pesect[PEOBJ_SECT_RDATA_Z].size = (uint32_t)strlen(ctx->dasm_ident)+1); 219 sofs += (pesect[PEOBJ_SECT_RDATA_Z].size = (uint32_t)strlen(ctx->dasm_ident)+1);
@@ -240,13 +230,13 @@ void emit_peobj(BuildCtx *ctx)
240 230
241 /* Compute the size of the symbol table: 231 /* Compute the size of the symbol table:
242 ** @feat.00 + nsections*2 232 ** @feat.00 + nsections*2
243 ** + asm_start + (nsyms-nzsym) + op_ofs 233 ** + asm_start + (nsyms-nzsym)
244 ** + relocsyms 234 ** + relocsyms
245 */ 235 */
246 /* Skip _Z syms. */ 236 /* Skip _Z syms. */
247 for (nzsym = 0; ctx->sym_ofs[ctx->perm[nzsym]] < 0; nzsym++) ; 237 for (nzsym = 0; ctx->sym_ofs[ctx->perm[nzsym]] < 0; nzsym++) ;
248 for (relocsyms = 0; ctx->extnames[relocsyms]; relocsyms++) ; 238 for (relocsyms = 0; ctx->extnames[relocsyms]; relocsyms++) ;
249 pehdr.nsyms = 1+PEOBJ_NSECTIONS*2 + 1+(ctx->nsym-nzsym)+1 + relocsyms; 239 pehdr.nsyms = 1+PEOBJ_NSECTIONS*2 + 1+(ctx->nsym-nzsym) + relocsyms;
250#if !LJ_HASJIT 240#if !LJ_HASJIT
251 pehdr.nsyms -= 7; 241 pehdr.nsyms -= 7;
252#endif 242#endif
@@ -303,12 +293,6 @@ void emit_peobj(BuildCtx *ctx)
303 } 293 }
304#endif 294#endif
305 295
306 /* Write .rdata section. */
307 for (i = 0; i < ctx->npc; i++) {
308 uint16_t pcofs = (uint16_t)ctx->sym_ofs[i];
309 owrite(ctx, &pcofs, 2);
310 }
311
312 /* Write .rdata$Z section. */ 296 /* Write .rdata$Z section. */
313 owrite(ctx, ctx->dasm_ident, strlen(ctx->dasm_ident)+1); 297 owrite(ctx, ctx->dasm_ident, strlen(ctx->dasm_ident)+1);
314 298
@@ -378,9 +362,6 @@ void emit_peobj(BuildCtx *ctx)
378 } 362 }
379 } 363 }
380 364
381 emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA);
382 emit_peobj_sym_rdata(ctx, PEOBJ_SYM_PREFIX LABEL_OP_OFS, 0);
383
384 emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA_Z); 365 emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA_Z);
385 366
386 if (strtab) 367 if (strtab)