{ "type", obj_coff_type, 0 },
{ "val", obj_coff_val, 0 },
{ "section", obj_coff_section, 0 },
+ { "use", obj_coff_section, 0 },
{ "sect", obj_coff_section, 0 },
{ "text", obj_coff_text, 0 },
{ "data", obj_coff_data, 0 },
{
unsigned int nrelocs;
unsigned int idx;
-
+ unsigned int addr = 0;
for (idx = SEG_E0; idx < SEG_E9; idx++)
{
if (segment_info[idx].scnhdr.s_name[0])
struct external_reloc *external_reloc_vec;
unsigned int external_reloc_size;
unsigned int count = 0;
- unsigned int base = segment_info[idx].scnhdr.s_paddr;
+ unsigned int base = addr;
fixS * fix_ptr = segment_info[idx].fix_root;
nrelocs = count_entries_in_chain(idx);
*file_cursor += external_reloc_size;
free( external_reloc_vec);
}
+ addr += segment_info[idx].scnhdr.s_size;
}
}
unsigned long *file_cursor)
{
- unsigned int i;
- unsigned int paddr = 0;
+ unsigned int i;
+ unsigned int paddr = 0;
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- unsigned int offset = 0;
+ for (i = SEG_E0; i < SEG_UNKNOWN; i++)
+ {
+ unsigned int offset = 0;
- struct internal_scnhdr *s = &( segment_info[i].scnhdr);
+ struct internal_scnhdr *s = &( segment_info[i].scnhdr);
- if (s->s_name[0])
- {
- fragS *frag = segment_info[i].frchainP->frch_root;
- char *buffer = malloc(s->s_size);
- if (s->s_size != 0)
- {
- s->s_scnptr = *file_cursor;
- s->s_paddr = paddr;
- s->s_vaddr = paddr;
+ if (s->s_name[0])
+ {
+ fragS *frag = segment_info[i].frchainP->frch_root;
+ char *buffer = malloc(s->s_size);
+ if (s->s_size != 0)
+ {
+ s->s_scnptr = *file_cursor;
+ s->s_paddr = paddr;
+ s->s_vaddr = paddr;
- }
- else
- {
- s->s_scnptr = 0;
- s->s_paddr = 0;
- s->s_vaddr = 0;
+ }
+ else
+ {
+ s->s_scnptr = 0;
+ s->s_paddr = 0;
+ s->s_vaddr = 0;
- }
+ }
- s->s_flags = STYP_REG;
- if (strcmp(s->s_name,".text")==0)
- s->s_flags |= STYP_TEXT;
- else if (strcmp(s->s_name,".data")==0)
- s->s_flags |= STYP_DATA;
- else if (strcmp(s->s_name,".bss")==0)
- s->s_flags |= STYP_BSS | STYP_NOLOAD;
-
- while (frag) {
- unsigned int fill_size;
- switch (frag->fr_type) {
-
- case rs_fill:
- case rs_align:
- case rs_org:
- if(frag->fr_fix)
- {
- memcpy(buffer + frag->fr_address,
- frag->fr_literal,
- frag->fr_fix);
- offset += frag->fr_fix;
- }
+ s->s_flags = STYP_REG;
+ if (strcmp(s->s_name,".text")==0)
+ s->s_flags |= STYP_TEXT;
+ else if (strcmp(s->s_name,".data")==0)
+ s->s_flags |= STYP_DATA;
+ else if (strcmp(s->s_name,".bss")==0)
+ s->s_flags |= STYP_BSS | STYP_NOLOAD;
+
+ while (frag) {
+ unsigned int fill_size;
+ switch (frag->fr_type) {
+
+ case rs_fill:
+ case rs_align:
+ case rs_org:
+ if(frag->fr_fix)
+ {
+ memcpy(buffer + frag->fr_address,
+ frag->fr_literal,
+ frag->fr_fix);
+ offset += frag->fr_fix;
+ }
- fill_size = frag->fr_var;
- if (fill_size)
- {
- unsigned int count ;
- unsigned int off = frag->fr_fix;
- for (count = frag->fr_offset; count; count--)
- {
- memcpy(buffer + frag->fr_address + off,
- frag->fr_literal + frag->fr_fix,
- fill_size);
- off += fill_size;
- offset += fill_size;
+ fill_size = frag->fr_var;
+ if (fill_size)
+ {
+ unsigned int count ;
+ unsigned int off = frag->fr_fix;
+ for (count = frag->fr_offset; count; count--)
+ {
+ memcpy(buffer + frag->fr_address + off,
+ frag->fr_literal + frag->fr_fix,
+ fill_size);
+ off += fill_size;
+ offset += fill_size;
- }
-
- }
- break;
- default:
- abort();
- }
- frag = frag->fr_next;
}
+
+ }
+ break;
+ default:
+ abort();
+ }
+ frag = frag->fr_next;
+ }
- bfd_write(buffer, s->s_size,1,abfd);
- free(buffer);
+ bfd_write(buffer, s->s_size,1,abfd);
+ free(buffer);
- *file_cursor += s->s_size;
- paddr += s->s_size;
- }
- }
+ *file_cursor += s->s_size;
+ paddr += s->s_size;
+ }
+ }
}
/* THis is a special case, we leave the size alone, which will have */
/* been made up from all and any lcomms seen */
}
- else {
- addr += size_section(abfd, i);
- }
+ else
+ {
+ addr += size_section(abfd, i);
+ }
}
fill_section(abfd,&filehdr, &file_cursor);
+
+
filehdr.f_magic = COFF_MAGIC;
filehdr.f_timdat = time(0);
filehdr.f_flags = COFF_FLAGS ;
if (line_number == 0)
{
-last_line_symbol = symbol;
+ last_line_symbol = symbol;
new_line->line.l_addr.l_symndx = (long)symbol;
}
else
{
s->lineno_list_tail->next = new_line;
}
- s->lineno_list_tail = new_line;
+ s->lineno_list_tail = new_line;
return LINESZ * s->scnhdr.s_nlnno ++;
}
{ "reg", s_lsym, 0 }, /* Register equate, same as equ */
{ "space", s_ignore, 0 }, /* Listing control */
{ "sect", s_ignore, 0 }, /* Creation of coff sections */
+#ifndef OBJ_COFF
+ /* We can do this right with coff */
{ "use", s_use, 0 },
+#endif
{ "word", cons, 4 },
{ NULL, 0, 0 },
};
char *s;
expressionS *operandp;
{
- char *save = input_line_pointer;
- char *new;
- segT seg;
-
- input_line_pointer = s;
- seg = expr (0, operandp);
- new = input_line_pointer;
- input_line_pointer = save;
+ char *save = input_line_pointer;
+ char *new;
+ segT seg;
- switch (seg) {
- case SEG_ABSOLUTE:
- case SEG_TEXT:
- case SEG_DATA:
- case SEG_BSS:
- case SEG_UNKNOWN:
- case SEG_DIFFERENCE:
- case SEG_BIG:
- case SEG_REGISTER:
- return new;
-
- case SEG_ABSENT:
- as_bad("Missing operand");
- return new;
-
- default:
- as_bad("Don't understand operand of type %s", segment_name (seg));
- return new;
- }
+ input_line_pointer = s;
+ seg = expr (0, operandp);
+ new = input_line_pointer;
+ input_line_pointer = save;
+
+ if (seg == SEG_ABSENT)
+ as_bad("Missing operand");
+ return new;
}
/* Instruction parsing. Takes a string containing the opcode.