# HG changeset patch # User lost # Date 1232084020 0 # Node ID 033a328a10ae26802772053023e7dac21fc1bab9 # Parent 918be0c02239d331e6401a36c15f9a01683ed488 Checkpoint: object target output diff -r 918be0c02239 -r 033a328a10ae src/lwasm.h --- a/src/lwasm.h Fri Jan 16 05:14:49 2009 +0000 +++ b/src/lwasm.h Fri Jan 16 05:33:40 2009 +0000 @@ -33,6 +33,14 @@ #define OUTPUT_RAWREL 3 // raw bytes where ORG causes a SEEK in the file // structure for tracking sections +typedef struct section_reloc_list_s section_reloc_list_t; +struct section_reloc_list_s +{ + int offset; // offset into section + lwasm_expr_stack_t *expr; // value definition + section_reloc_list_t *next; // next relocation +}; + #define SECTION_BSS 1 // the section contains no actual code - just uninit vars typedef struct sectiontab_s sectiontab_t; struct sectiontab_s @@ -41,9 +49,11 @@ int offset; // current offset in the section int flags; // section flags sectiontab_t *next; // next section + // the following are used during code output unsigned char *obytes; // output bytes int oblen; // how many bytes output so far? int obsize; // how big is output buffer so far? + section_reloc_list_t *rl; // relocation list }; // structure for tracking macros diff -r 918be0c02239 -r 033a328a10ae src/output.c --- a/src/output.c Fri Jan 16 05:14:49 2009 +0000 +++ b/src/output.c Fri Jan 16 05:33:40 2009 +0000 @@ -241,7 +241,15 @@ // relocation table if (l -> relocoff >= 0) { - + section_reloc_list_t *re; + + // build the relocation reference for the linker + re = lwasm_alloc(sizeof(section_reloc_list_t)); + re -> next = l -> sect -> rl; + l -> sect -> rl = re; + + re -> offset = l -> codeaddr + l -> relocoff; + re -> expr = l -> exprs[0]; } } } diff -r 918be0c02239 -r 033a328a10ae src/pseudo.c --- a/src/pseudo.c Fri Jan 16 05:14:49 2009 +0000 +++ b/src/pseudo.c Fri Jan 16 05:33:40 2009 +0000 @@ -720,7 +720,7 @@ s -> obytes = NULL; s -> oblen = 0; s -> obsize = 0; - + s -> rl = NULL; // parse options; only one "bss" if (opts && as -> passnum == 1) {