static void as86_init(void) { stext.data = saa_init(1L); stext.datalen = 0L; stext.head = stext.last = NULL; stext.tail = &stext.head; sdata.data = saa_init(1L); sdata.datalen = 0L; sdata.head = sdata.last = NULL; sdata.tail = &sdata.head; bsslen = stext.len = stext.datalen = stext.size = sdata.len = sdata.datalen = sdata.size = 0; stext.index = seg_alloc(); sdata.index = seg_alloc(); bssindex = seg_alloc(); syms = saa_init((int32_t)sizeof(struct Symbol)); nsyms = 0; bsym = raa_init(); strs = saa_init(1L); strslen = 0; /* as86 module name = input file minus extension */ as86_add_string(filename_set_extension(inname, "")); }
static void aoutg_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval) { aoutfp = fp; error = errfunc; evaluate = eval; (void)ldef; /* placate optimisers */ stext.data = saa_init(1L); stext.head = NULL; stext.tail = &stext.head; sdata.data = saa_init(1L); sdata.head = NULL; sdata.tail = &sdata.head; stext.len = stext.size = sdata.len = sdata.size = sbss.len = 0; stext.nrelocs = sdata.nrelocs = 0; stext.gsyms = sdata.gsyms = sbss.gsyms = NULL; stext.index = seg_alloc(); sdata.index = seg_alloc(); sbss.index = seg_alloc(); stext.asym = sdata.asym = sbss.asym = NULL; syms = saa_init((long)sizeof(struct Symbol)); nsyms = 0; bsym = raa_init(); strs = saa_init(1L); strslen = 0; fwds = NULL; }
static void as86_init(FILE *fp, efunc errfunc, ldfunc ldef, evalfunc eval) { as86fp = fp; error = errfunc; (void) ldef; /* placate optimisers */ stext.data = saa_init(1L); stext.datalen = 0L; stext.head = stext.last = NULL; stext.tail = &stext.head; sdata.data = saa_init(1L); sdata.datalen = 0L; sdata.head = sdata.last = NULL; sdata.tail = &sdata.head; bsslen = stext.len = stext.datalen = stext.size = sdata.len = sdata.datalen = sdata.size = 0; stext.index = seg_alloc(); sdata.index = seg_alloc(); bssindex = seg_alloc(); syms = saa_init((long)sizeof(struct Symbol)); nsyms = 0; bsym = raa_init(); strs = saa_init(1L); strslen = 0; as86_add_string (as86_module); }
static void coff_gen_init(FILE *fp, efunc errfunc) { coffp = fp; error = errfunc; sects = NULL; nsects = sectlen = 0; syms = saa_init((long)sizeof(struct Symbol)); nsyms = 0; bsym = raa_init(); symval = raa_init(); strs = saa_init(1L); strslen = 0; def_seg = seg_alloc(); }
static int elf_make_section(char *name, int type, int flags, int align) { struct Section *s; s = nasm_malloc(sizeof(*s)); if (type != SHT_NOBITS) s->data = saa_init(1L); s->head = NULL; s->tail = &s->head; s->len = s->size = 0; s->nrelocs = 0; if (!strcmp(name, ".text")) s->index = def_seg; else s->index = seg_alloc(); add_sectname("", name); s->name = nasm_malloc(1 + strlen(name)); strcpy(s->name, name); s->type = type; s->flags = flags; s->align = align; s->gsyms = NULL; if (nsects >= sectlen) sects = nasm_realloc(sects, (sectlen += SECT_DELTA) * sizeof(*sects)); sects[nsects++] = s; return nsects - 1; }
static struct SAA *elf_build_reltab(long *len, struct Reloc *r) { struct SAA *s; unsigned char *p, entry[8]; if (!r) return NULL; s = saa_init(1L); *len = 0; while (r) { long sym = r->symbol; if (sym >= GLOBAL_TEMP_BASE) sym += -GLOBAL_TEMP_BASE + (nsects + 3) + nlocals; p = entry; WRITELONG(p, r->address); WRITELONG(p, (sym << 8) + r->type); saa_wbytes(s, entry, 8L); *len += 8; r = r->next; } return s; }
static int coff_make_section (char *name, unsigned long flags) { struct Section *s; s = nasm_malloc (sizeof(*s)); if (flags != BSS_FLAGS) s->data = saa_init (1L); else s->data = NULL; s->head = NULL; s->tail = &s->head; s->len = 0; s->nrelocs = 0; if (!strcmp(name, ".text")) s->index = def_seg; else s->index = seg_alloc(); strncpy (s->name, name, 8); s->name[8] = '\0'; s->flags = flags; if (nsects >= sectlen) sects = nasm_realloc (sects, (sectlen += SECT_DELTA)*sizeof(*sects)); sects[nsects++] = s; return nsects-1; }
static void elf_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval) { elffp = fp; error = errfunc; evaluate = eval; (void)ldef; /* placate optimisers */ sects = NULL; nsects = sectlen = 0; syms = saa_init((long)sizeof(struct Symbol)); nlocals = nglobs = 0; bsym = raa_init(); strs = saa_init(1L); saa_wbytes(strs, "\0", 1L); saa_wbytes(strs, elf_module, (long)(strlen(elf_module) + 1)); strslen = 2 + strlen(elf_module); shstrtab = NULL; shstrtablen = shstrtabsize = 0;; add_sectname("", ""); fwds = NULL; elf_gotpc_sect = seg_alloc(); ldef("..gotpc", elf_gotpc_sect + 1, 0L, NULL, FALSE, FALSE, &of_elf, error); elf_gotoff_sect = seg_alloc(); ldef("..gotoff", elf_gotoff_sect + 1, 0L, NULL, FALSE, FALSE, &of_elf, error); elf_got_sect = seg_alloc(); ldef("..got", elf_got_sect + 1, 0L, NULL, FALSE, FALSE, &of_elf, error); elf_plt_sect = seg_alloc(); ldef("..plt", elf_plt_sect + 1, 0L, NULL, FALSE, FALSE, &of_elf, error); elf_sym_sect = seg_alloc(); ldef("..sym", elf_sym_sect + 1, 0L, NULL, FALSE, FALSE, &of_elf, error); def_seg = seg_alloc(); }
static void as86_init(void) { stext.data = saa_init(1L); stext.datalen = 0L; stext.head = stext.last = NULL; stext.tail = &stext.head; sdata.data = saa_init(1L); sdata.datalen = 0L; sdata.head = sdata.last = NULL; sdata.tail = &sdata.head; bsslen = stext.len = stext.datalen = stext.size = sdata.len = sdata.datalen = sdata.size = 0; stext.index = seg_alloc(); sdata.index = seg_alloc(); bssindex = seg_alloc(); syms = saa_init((int32_t)sizeof(struct Symbol)); nsyms = 0; bsym = raa_init(); strs = saa_init(1L); strslen = 0; as86_add_string(as86_module); }
static struct SAA *elf_build_symtab(long *len, long *local) { struct SAA *s = saa_init(1L); struct Symbol *sym; unsigned char entry[16], *p; int i; *len = *local = 0; /* * First, an all-zeros entry, required by the ELF spec. */ saa_wbytes(s, NULL, 16L); /* null symbol table entry */ *len += 16; (*local)++; /* * Next, an entry for the file name. */ p = entry; WRITELONG(p, 1); /* we know it's 1st thing in strtab */ WRITELONG(p, 0); /* no value */ WRITELONG(p, 0); /* no size either */ WRITESHORT(p, 4); /* type FILE */ WRITESHORT(p, SHN_ABS); saa_wbytes(s, entry, 16L); *len += 16; (*local)++; /* * Now some standard symbols defining the segments, for relocation * purposes. */ for (i = 1; i <= nsects + 1; i++) { p = entry; WRITELONG(p, 0); /* no symbol name */ WRITELONG(p, 0); /* offset zero */ WRITELONG(p, 0); /* size zero */ WRITESHORT(p, 3); /* local section-type thing */ WRITESHORT(p, (i == 1 ? SHN_ABS : i - 1)); /* the section id */ saa_wbytes(s, entry, 16L); *len += 16; (*local)++; } /* * Now the other local symbols. */ saa_rewind(syms); while ((sym = saa_rstruct(syms))) { if (sym->type & SYM_GLOBAL) continue; p = entry; WRITELONG(p, sym->strpos); WRITELONG(p, sym->value); WRITELONG(p, sym->size); WRITESHORT(p, sym->type); /* local non-typed thing */ WRITESHORT(p, sym->section); saa_wbytes(s, entry, 16L); *len += 16; (*local)++; } /* * Now the global symbols. */ saa_rewind(syms); while ((sym = saa_rstruct(syms))) { if (!(sym->type & SYM_GLOBAL)) continue; p = entry; WRITELONG(p, sym->strpos); WRITELONG(p, sym->value); WRITELONG(p, sym->size); WRITESHORT(p, sym->type); /* global non-typed thing */ WRITESHORT(p, sym->section); saa_wbytes(s, entry, 16L); *len += 16; } return s; }