static void as86_add_piece(struct Section *sect, int type, int32_t offset,
                           int32_t segment, int32_t bytes, int relative)
{
    struct Piece *p;

    sect->len += bytes;

    if (type == 0 && sect->last && sect->last->type == 0) {
        sect->last->bytes += bytes;
        return;
    }

    p = sect->last = *sect->tail = nasm_malloc(sizeof(struct Piece));
    sect->tail = &p->next;
    p->next = NULL;

    p->type = type;
    p->offset = offset;
    p->bytes = bytes;
    p->relative = relative;

    if (type == 1 && segment == stext.index)
        p->number = SECT_TEXT;
    else if (type == 1 && segment == sdata.index)
        p->number = SECT_DATA;
    else if (type == 1 && segment == bssindex)
        p->number = SECT_BSS;
    else if (type == 1)
        p->number = raa_read(bsym, segment), p->type = 2;
}
Exemple #2
0
static long coff_add_reloc (struct Section *sect, long segment,
			    int relative) 
{
    struct Reloc *r;

    r = *sect->tail = nasm_malloc(sizeof(struct Reloc));
    sect->tail = &r->next;
    r->next = NULL;

    r->address = sect->len;
    if (segment == NO_SEG)
	r->symbol = 0, r->symbase = ABS_SYMBOL;
    else {
	int i;
	r->symbase = REAL_SYMBOLS;
	for (i=0; i<nsects; i++)
	    if (segment == sects[i]->index) {
		r->symbol = i*2;
		r->symbase = SECT_SYMBOLS;
		break;
	    }
	if (r->symbase == REAL_SYMBOLS)
	    r->symbol = raa_read (bsym, segment);
    }
    r->relative = relative;

    sect->nrelocs++;

    /*
     * Return the fixup for standard COFF common variables.
     */
    if (r->symbase == REAL_SYMBOLS && !win32)
	return raa_read (symval, segment);
    else
	return 0;
}
Exemple #3
0
static void aout_add_reloc (struct Section *sect, long segment,
			    int reltype, int bytes) {
    struct Reloc *r;

    r = *sect->tail = nasm_malloc(sizeof(struct Reloc));
    sect->tail = &r->next;
    r->next = NULL;

    r->address = sect->len;
    r->symbol = (segment == NO_SEG ? -SECT_ABS :
		 segment == stext.index ? -SECT_TEXT :
		 segment == sdata.index ? -SECT_DATA :
		 segment == sbss.index ? -SECT_BSS :
		 raa_read(bsym, segment));
    r->reltype = reltype;
    if (r->symbol >= 0)
	r->reltype |= RELTYPE_SYMFLAG;
    r->bytes = bytes;

    sect->nrelocs++;
}
Exemple #4
0
static void elf_add_reloc(struct Section *sect, long segment, int type)
{
    struct Reloc *r;

    r = *sect->tail = nasm_malloc(sizeof(struct Reloc));
    sect->tail = &r->next;
    r->next = NULL;

    r->address = sect->len;
    if (segment == NO_SEG)
        r->symbol = 2;
    else {
        int i;
        r->symbol = 0;
        for (i = 0; i < nsects; i++)
            if (segment == sects[i]->index)
                r->symbol = i + 3;
        if (!r->symbol)
            r->symbol = GLOBAL_TEMP_BASE + raa_read(bsym, segment);
    }
    r->type = type;

    sect->nrelocs++;
}