diff options
author | Steve Chamberlain <steve@cygnus> | 1991-04-24 20:51:27 +0000 |
---|---|---|
committer | Steve Chamberlain <steve@cygnus> | 1991-04-24 20:51:27 +0000 |
commit | 4cddd1c9048abf7852e9faa4e46a9ce96d7f9436 (patch) | |
tree | ecfd460dcc357d90d1e917805f77494104b76dd7 /bfd | |
parent | a36f604047f7006445325a8e3d962c7f2c115a09 (diff) | |
download | gdb-4cddd1c9048abf7852e9faa4e46a9ce96d7f9436.zip gdb-4cddd1c9048abf7852e9faa4e46a9ce96d7f9436.tar.gz gdb-4cddd1c9048abf7852e9faa4e46a9ce96d7f9436.tar.bz2 |
Changed the shape of the howto type yet again.
Now m88kbcs support can self host.
Diffstat (limited to 'bfd')
-rwxr-xr-x | bfd/aout.c | 71 | ||||
-rw-r--r-- | bfd/archures.c | 13 | ||||
-rw-r--r-- | bfd/bfd.c | 13 | ||||
-rwxr-xr-x | bfd/coff-code.h | 203 | ||||
-rw-r--r-- | bfd/coff-i960.c | 3 | ||||
-rw-r--r-- | bfd/coff-m88k.c | 54 | ||||
-rw-r--r-- | bfd/ieee.c | 4 | ||||
-rw-r--r-- | bfd/libcoff.h | 2 | ||||
-rw-r--r-- | bfd/oasys.c | 9 | ||||
-rw-r--r-- | bfd/sunos.c | 71 |
10 files changed, 266 insertions, 177 deletions
@@ -53,48 +53,47 @@ void (*bfd_error_trap)(); #define CTOR_TABLE_RELOC_IDX 2 static reloc_howto_type howto_table_ext[] = { - /* type rs size bsz pcrel bitpos abs ovrf sf name partial inplace mask*/ -{ (unsigned int) RELOC_8, 0, 0, 8, false, 0, true, true,0,"8", false, 0,0x000000ff}, -{ (unsigned int) RELOC_16, 0, 1, 16, false, 0, true, true,0,"16", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_32, 0, 2, 32, false, 0, true, true,0,"32", false, 0,0xffffffff}, -{ (unsigned int) RELOC_DISP8, 0, 0, 8, true, 0, false, true,0,"DISP8", false, 0,0x000000ff}, -{ (unsigned int) RELOC_DISP16, 0, 1, 16, true, 0, false, true,0,"DISP16", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_DISP32, 0, 2, 32, true, 0, false, true,0,"DISP32", false, 0,0xffffffff}, -{ (unsigned int) RELOC_WDISP30,2, 2, 30, true, 0, false, true,0,"WDISP30", false, 0,0x3fffffff}, -{ (unsigned int) RELOC_WDISP22,2, 2, 22, true, 0, false, true,0,"WDISP22", false, 0,0x003fffff}, -{ (unsigned int) RELOC_HI22, 10, 2, 22, false, 0, false, true,0,"HI22", false, 0,0x003fffff}, -{ (unsigned int) RELOC_22, 0, 2, 22, false, 0, false, true,0,"22", false, 0,0x003fffff}, -{ (unsigned int) RELOC_13, 0, 2, 13, false, 0, false, true,0,"13", false, 0,0x00001fff}, -{ (unsigned int) RELOC_LO10, 0, 2, 10, false, 0, false, true,0,"LO10", false, 0,0x000003ff}, -{ (unsigned int) RELOC_SFA_BASE,0, 2, 32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff}, -{ (unsigned int) RELOC_SFA_OFF13,0,2, 32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff}, -{ (unsigned int) RELOC_BASE10, 0, 2, 16, false, 0, false, true,0,"BASE10", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_BASE13, 0, 2, 13, false, 0, false, true,0,"BASE13", false, 0,0x00001fff}, -{ (unsigned int) RELOC_BASE22, 0, 2, 0, false, 0, false, true,0,"BASE22", false, 0,0x00000000}, -{ (unsigned int) RELOC_PC10, 0, 2, 10, false, 0, false, true,0,"PC10", false, 0,0x000003ff}, -{ (unsigned int) RELOC_PC22, 0, 2, 22, false, 0, false, true,0,"PC22", false, 0,0x003fffff}, -{ (unsigned int) RELOC_JMP_TBL,0, 2, 32, false, 0, false, true,0,"JMP_TBL", false, 0,0xffffffff}, -{ (unsigned int) RELOC_SEGOFF16,0, 2, 0, false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000}, -{ (unsigned int) RELOC_GLOB_DAT,0, 2, 0, false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000}, -{ (unsigned int) RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000}, -{ (unsigned int) RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0,0x00000000}, -{ (unsigned int) RELOC_JUMPTARG,2, 13, 16, true, 0, false, true,0,"JUMPTARG", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_CONST, 0, 13, 16, false, 0, false, true,0,"CONST", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH", false, 0,0x0000ffff}, + HOWTO(RELOC_8, 0, 0, 8, false, 0, true, true,0,"8", false, 0,0x000000ff, false), + HOWTO(RELOC_16, 0, 1, 16, false, 0, true, true,0,"16", false, 0,0x0000ffff, false), + HOWTO(RELOC_32, 0, 2, 32, false, 0, true, true,0,"32", false, 0,0xffffffff, false), + HOWTO(RELOC_DISP8, 0, 0, 8, true, 0, false, true,0,"DISP8", false, 0,0x000000ff, false), + HOWTO(RELOC_DISP16, 0, 1, 16, true, 0, false, true,0,"DISP16", false, 0,0x0000ffff, false), + HOWTO(RELOC_DISP32, 0, 2, 32, true, 0, false, true,0,"DISP32", false, 0,0xffffffff, false), + HOWTO(RELOC_WDISP30,2, 2, 30, true, 0, false, true,0,"WDISP30", false, 0,0x3fffffff, false), + HOWTO(RELOC_WDISP22,2, 2, 22, true, 0, false, true,0,"WDISP22", false, 0,0x003fffff, false), + HOWTO(RELOC_HI22, 10, 2, 22, false, 0, false, true,0,"HI22", false, 0,0x003fffff, false), + HOWTO(RELOC_22, 0, 2, 22, false, 0, false, true,0,"22", false, 0,0x003fffff, false), + HOWTO(RELOC_13, 0, 2, 13, false, 0, false, true,0,"13", false, 0,0x00001fff, false), + HOWTO(RELOC_LO10, 0, 2, 10, false, 0, false, true,0,"LO10", false, 0,0x000003ff, false), + HOWTO(RELOC_SFA_BASE,0, 2, 32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff, false), + HOWTO(RELOC_SFA_OFF13,0,2, 32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff, false), + HOWTO(RELOC_BASE10, 0, 2, 16, false, 0, false, true,0,"BASE10", false, 0,0x0000ffff, false), + HOWTO(RELOC_BASE13, 0, 2, 13, false, 0, false, true,0,"BASE13", false, 0,0x00001fff, false), + HOWTO(RELOC_BASE22, 0, 2, 0, false, 0, false, true,0,"BASE22", false, 0,0x00000000, false), + HOWTO(RELOC_PC10, 0, 2, 10, false, 0, false, true,0,"PC10", false, 0,0x000003ff, false), + HOWTO(RELOC_PC22, 0, 2, 22, false, 0, false, true,0,"PC22", false, 0,0x003fffff, false), + HOWTO(RELOC_JMP_TBL,0, 2, 32, false, 0, false, true,0,"JMP_TBL", false, 0,0xffffffff, false), + HOWTO(RELOC_SEGOFF16,0, 2, 0, false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000, false), + HOWTO(RELOC_GLOB_DAT,0, 2, 0, false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000, false), + HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000, false), + HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0,0x00000000, false), + HOWTO(RELOC_JUMPTARG,2, 13, 16, true, 0, false, true,0,"JUMPTARG", false, 0,0x0000ffff, false), + HOWTO(RELOC_CONST, 0, 13, 16, false, 0, false, true,0,"CONST", false, 0,0x0000ffff, false), + HOWTO(RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH", false, 0,0x0000ffff, false), }; /* Convert standard reloc records to "arelent" format (incl byte swap). */ static reloc_howto_type howto_table_std[] = { /* type rs size bsz pcrel bitpos abs ovrf sf name*/ -{ (unsigned int) 0, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff}, -{ (unsigned int) 1, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff}, -{ (unsigned int) 2, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff}, -{ (unsigned int) 3, 0, 3, 64, false, 0, true, true,0,"64", true, 0xdeaddead,0xdeaddead}, -{ (unsigned int) 4, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff}, -{ (unsigned int) 5, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff}, -{ (unsigned int) 6, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff}, -{ (unsigned int) 7, 0, 3, 64, true, 0, false, true,0,"DISP64", true, 0xfeedface,0xfeedface}, +HOWTO( 0, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff, false), +HOWTO( 1, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff, false), +HOWTO( 2, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff, false), +HOWTO( 3, 0, 3, 64, false, 0, true, true,0,"64", true, 0xdeaddead,0xdeaddead, false), +HOWTO( 4, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff, false), +HOWTO( 5, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff, false), +HOWTO( 6, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff, false), +HOWTO( 7, 0, 3, 64, true, 0, false, true,0,"DISP64", true, 0xfeedface,0xfeedface, false), }; diff --git a/bfd/archures.c b/bfd/archures.c index b7fdaf9..2e151ed 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -53,7 +53,10 @@ struct arch_print { {bfd_arch_convex, "convex", prt_num_mach, scan_num_mach}, {bfd_arch_m88k, "m88k", prt_num_mach, scan_num_mach}, {bfd_arch_pyramid, "pyramid", prt_num_mach, scan_num_mach}, - {bfd_arch_unknown, (char *)0, prt_num_mach, scan_num_mach}, + {bfd_arch_h8_300, "H8/300", prt_num_mach, scan_num_mach}, + {bfd_arch_unknown, (char *)0, prt_num_mach, scan_num_mach}, + + }; /* Return a printable string representing the architecture and machine @@ -92,10 +95,10 @@ prt_num_mach (ap, machine) combination. */ boolean -bfd_scan_arch_mach (string, archp, machinep) - char *string; - enum bfd_architecture *archp; - unsigned long *machinep; +DEFUN(bfd_scan_arch_mach,(string, archp, machinep), + CONST char *string AND + enum bfd_architecture *archp AND + unsigned long *machinep) { struct arch_print *ap; int len; @@ -760,12 +760,23 @@ bfd *output_bfd; { /* Anything which started out as pc relative should end up that - way too + way too. + + There are two ways we can see a pcrel instruction. Sometimes + the pcrel displacement has been partially calculated, it + includes the distance from the start of the section to the + instruction in it (eg sun3), and sometimes the field is + totally blank - eg m88kbcs. */ + relocation -= output_base + input_section->output_offset; + if (howto->pcrel_offset == true) { + relocation -= reloc_entry->address; + } + } if (output_bfd!= (bfd *)NULL) { diff --git a/bfd/coff-code.h b/bfd/coff-code.h index 0584700..979e34d 100755 --- a/bfd/coff-code.h +++ b/bfd/coff-code.h @@ -234,6 +234,10 @@ DEFUN(coff_new_section_hook,(abfd_ignore, section_ignore), bfd *abfd_ignore AND asection *section_ignore) { +#ifdef MC88MAGIC + /* Align to at least 16 bytes */ + section_ignore->alignment_power = 4; +#endif return true; } /* actually it makes itself and its children from the file headers */ @@ -309,7 +313,6 @@ DEFUN(coff_mkobject,(abfd), (coff_data_type*)bfd_alloc(abfd,sizeof(coff_data_type)); coff = coff_data(abfd); coff->relocbase = 0; - coff->hdr = (AOUTHDR*) bfd_alloc(abfd, sizeof(AOUTHDR)); return true; } @@ -433,10 +436,10 @@ DEFUN(coff_real_object_p,(abfd, nscns, opthdr), abfd->flags |= HAS_SYMS; coff->sym_filepos = filehdr->f_symptr; - swap_aouthdr(abfd, coff->hdr); + swap_aouthdr(abfd, &coff->hdr); coff->symbols = (coff_symbol_type *) NULL; - bfd_get_start_address(abfd) = opthdr ? exec_hdr(abfd)->entry : 0; + bfd_get_start_address(abfd) = opthdr ? exec_hdr(abfd).entry : 0; return abfd->xvec; fail: @@ -1199,8 +1202,14 @@ coff_compute_section_file_positions(abfd) sofar += abfd->section_count * SCNHSZ; - for (current = abfd->sections; current != NULL; current = current->next) { + for (current = abfd->sections; current != NULL; current = + current->next) { +#ifdef MC88MAGIC + sofar = current->filepos = ALIGN(sofar, 1<< + current->alignment_power); +#else current->filepos = sofar; +#endif /* Only add sections which have contents */ if (current->flags & SEC_HAS_CONTENTS) sofar += current->size; @@ -1232,28 +1241,35 @@ coff_write_object_contents(abfd) asection *data_sec = NULL; asection *bss_sec = NULL; unsigned magic, + flags; + + struct icofdata *coff = obj_icof(abfd); + + bfd_error = system_call_error; if(abfd->output_has_begun == false) { coff_compute_section_file_positions(abfd); } - scn_base = (file_ptr) (sizeof(struct filehdr) - + ((abfd->flags & EXEC_P) ? sizeof(AOUTHDR) : 0)); + if (abfd->sections != (asection *)NULL) { + scn_base = abfd->sections->filepos; + } + else { + scn_base = 0; + } if (bfd_seek(abfd, scn_base, SEEK_SET) != 0) return false; reloc_base = obj_relocbase(abfd); - - /* - Make a pass through the symbol table to count line number entries and - put them into the correct asections - */ + Make a pass through the symbol table to count line number entries and + put them into the correct asections + */ coff_count_linenumbers(abfd); data_base = scn_base; /* Work out the size of the reloc and linno areas */ @@ -1294,81 +1310,81 @@ coff_write_object_contents(abfd) (file_ptr) ((abfd->flags & EXEC_P) ? (FILHSZ + AOUTSZ) : FILHSZ), SEEK_SET); - { + { #if 0 - unsigned int pad = abfd->flags & D_PAGED ? data_base : 0; + unsigned int pad = abfd->flags & D_PAGED ? data_base : 0; #endif - unsigned int pad = 0; - for (current = abfd->sections; current != NULL; current = current->next) { - SCNHDR section; - strncpy(&(section.s_name[0]), current->name, 8); - section.s_vaddr = current->vma + pad; - section.s_paddr = current->vma + pad; - section.s_size = current->size - pad; - /* - If this section has no size or is unloadable then the scnptr - will be 0 too - */ - if (current->size - pad == 0 || - (current->flags & SEC_LOAD) == 0) { - section.s_scnptr = 0; - - } - else { - section.s_scnptr = current->filepos; - } - section.s_relptr = current->rel_filepos; - section.s_lnnoptr = current->line_filepos; - section.s_nreloc = current->reloc_count; - section.s_nlnno = current->lineno_count; - if (current->reloc_count != 0) - hasrelocs = true; - if (current->lineno_count != 0) - haslinno = true; - - if (!strcmp(current->name, _TEXT)) { - text_sec = current; - section.s_flags = STYP_TEXT; /* kind stupid optimisation */ - } - else { + unsigned int pad = 0; + for (current = abfd->sections; current != NULL; current = current->next) { + SCNHDR section; + strncpy(&(section.s_name[0]), current->name, 8); + section.s_vaddr = current->vma + pad; + section.s_paddr = current->vma + pad; + section.s_size = current->size - pad; + /* + If this section has no size or is unloadable then the scnptr + will be 0 too + */ + if (current->size - pad == 0 || + (current->flags & SEC_LOAD) == 0) { + section.s_scnptr = 0; - if (!strcmp(current->name, _DATA)) { - data_sec = current; - section.s_flags = STYP_DATA; /* kind stupid - optimisation */ } - else if (!strcmp(current->name, _BSS)) { - bss_sec = current; - section.s_flags = STYP_BSS; /* kind stupid optimisation */ + else { + section.s_scnptr = current->filepos; + } + section.s_relptr = current->rel_filepos; + section.s_lnnoptr = current->line_filepos; + section.s_nreloc = current->reloc_count; + section.s_nlnno = current->lineno_count; + if (current->reloc_count != 0) + hasrelocs = true; + if (current->lineno_count != 0) + haslinno = true; + + if (!strcmp(current->name, _TEXT)) { + text_sec = current; + section.s_flags = STYP_TEXT; /* kind stupid optimisation */ + } + else { + + if (!strcmp(current->name, _DATA)) { + data_sec = current; + section.s_flags = STYP_DATA; /* kind stupid + optimisation */ + } + else if (!strcmp(current->name, _BSS)) { + bss_sec = current; + section.s_flags = STYP_BSS; /* kind stupid optimisation */ + } } - } #ifdef I960 - section.s_align = (current->alignment_power - ? 1 << current->alignment_power - : 0); + section.s_align = (current->alignment_power + ? 1 << current->alignment_power + : 0); #endif - swap_scnhdr(abfd, §ion); - bfd_write((PTR) (§ion), 1, SCNHSZ, abfd); - pad = 0; - } + swap_scnhdr(abfd, §ion); + bfd_write((PTR) (§ion), 1, SCNHSZ, abfd); + pad = 0; + } - } + } /* OK, now set up the filehdr... */ bfd_h_put_x(abfd, abfd->section_count, &file_header.f_nscns); /* - We will NOT put a fucking timestamp in the header here. Every time you - put it back, I will come in and take it out again. I'm sorry. This - field does not belong here. We fill it with a 0 so it compares the - same but is not a reasonable time. -- gnu@cygnus.com - */ + We will NOT put a fucking timestamp in the header here. Every time you + put it back, I will come in and take it out again. I'm sorry. This + field does not belong here. We fill it with a 0 so it compares the + same but is not a reasonable time. -- gnu@cygnus.com + */ /* - Well, I like it, so I'm conditionally compiling it in. - steve@cygnus.com - */ + Well, I like it, so I'm conditionally compiling it in. + steve@cygnus.com + */ #ifdef COFF_TIMESTAMP bfd_h_put_x(abfd, time(0), &file_header.f_timdat); #else @@ -1395,12 +1411,16 @@ coff_write_object_contents(abfd) file_header.f_flags |= F_LSYMS; if (abfd->flags & EXEC_P) file_header.f_flags |= F_EXEC; +#if M88 + file_header.f_flags |= F_AR32W; +#else if (!abfd->xvec->byteorder_big_p) file_header.f_flags |= F_AR32WR; +#endif /* - FIXME, should do something about the other byte orders and - architectures. - */ + FIXME, should do something about the other byte orders and + architectures. + */ /* Set up architecture-dependent stuff */ @@ -1415,10 +1435,10 @@ coff_write_object_contents(abfd) /* ...and the "opt"hdr... */ #ifdef I960 bfd_h_put_x(abfd, (magic == I960ROMAGIC ? NMAGIC : OMAGIC), - &(exec_hdr(abfd)->magic)); + &(exec_hdr(abfd).magic)); #endif #if M88 - exec_hdr(abfd)->magic = PAGEMAGIC3; + exec_hdr(abfd).magic = PAGEMAGICBCS; #endif /* Now should write relocs, strings, syms */ @@ -1431,21 +1451,21 @@ coff_write_object_contents(abfd) coff_write_relocs(abfd); } if (text_sec) { - bfd_h_put_x(abfd, text_sec->size, &exec_hdr(abfd)->tsize); + bfd_h_put_x(abfd, text_sec->size, &coff->hdr.tsize); bfd_h_put_x(abfd, text_sec->size ? text_sec->vma : 0, - &exec_hdr(abfd)->text_start); + &exec_hdr(abfd).text_start); } if (data_sec) { - bfd_h_put_x(abfd, data_sec->size, &exec_hdr(abfd)->dsize); + bfd_h_put_x(abfd, data_sec->size, &coff->hdr.dsize); bfd_h_put_x(abfd, data_sec->size ? data_sec->vma : 0, - &exec_hdr(abfd)->data_start); + &exec_hdr(abfd).data_start); } if (bss_sec) { - bfd_h_put_x(abfd, bss_sec->size, &exec_hdr(abfd)->bsize); + bfd_h_put_x(abfd, bss_sec->size, &coff->hdr.bsize); } - bfd_h_put_x(abfd, bfd_get_start_address(abfd), &exec_hdr(abfd)->entry); + bfd_h_put_x(abfd, bfd_get_start_address(abfd), &coff->hdr.entry); /* now write them */ @@ -1457,7 +1477,7 @@ coff_write_object_contents(abfd) if (abfd->flags & EXEC_P) { - bfd_write((PTR) exec_hdr(abfd), 1, AOUTSZ, abfd); + bfd_write((PTR) &coff->hdr, 1, AOUTSZ, abfd); } return true; } @@ -2272,6 +2292,7 @@ coff_slurp_reloc_table(abfd, asect, symbols) #if M88 if (src->r_type >= R_PCR16L && src->r_type <= R_VRT32) { cache_ptr->howto = howto_table + src->r_type - R_PCR16L; + cache_ptr->addend += src->r_offset << 16; } else { BFD_ASSERT(0); @@ -2469,6 +2490,24 @@ return obj_sym_filepos(abfd); #endif +static int +DEFUN(coff_sizeof_headers,(abfd, reloc), + bfd *abfd AND + boolean reloc) +{ + size_t size; + + if (reloc == false) { + size = sizeof(struct filehdr) + sizeof(AOUTHDR); + } + else { + size = sizeof(struct filehdr); + } + + size += abfd->section_count * SCNHSZ; + return size; +} + #define coff_core_file_failing_command _bfd_dummy_core_file_failing_command #define coff_core_file_failing_signal _bfd_dummy_core_file_failing_signal diff --git a/bfd/coff-i960.c b/bfd/coff-i960.c index f5e6f71..8f6e688 100644 --- a/bfd/coff-i960.c +++ b/bfd/coff-i960.c @@ -24,11 +24,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "bfd.h" #include "libbfd.h" #include "obstack.h" +#include "intel-coff.h" #include "libcoff.h" /* to allow easier abstraction-breaking */ -#include "intel-coff.h" + #define CALLS 0x66003800 /* Template for 'calls' instruction */ #define BAL 0x0b000000 /* Template for 'bal' instruction */ diff --git a/bfd/coff-m88k.c b/bfd/coff-m88k.c index 7dda5e5..67db5dc 100644 --- a/bfd/coff-m88k.c +++ b/bfd/coff-m88k.c @@ -28,17 +28,55 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "m88k-bcs.h" #include "libcoff.h" +/* Provided the symbol, returns the value reffed */ +#define HOWTO_PREPARE(relocation, symbol) \ + { \ + if (symbol != (asymbol *)NULL) { \ + if (symbol->flags & BSF_FORT_COMM) { \ + relocation = 0; \ + } \ + else { \ + relocation = symbol->value; \ + } \ + } \ + if (symbol->section != (asection *)NULL) { \ + relocation += symbol->section->output_section->vma + \ + symbol->section->output_offset; \ + } \ +} + + + +static bfd_reloc_status_enum_type +DEFUN(howto_hvrt16,(abfd, reloc_entry, symbol_in, data, input_section), +bfd *abfd AND +arelent *reloc_entry AND +asymbol *symbol_in AND +unsigned char *data AND +asection *ignore_input_section) +{ + long relocation; + bfd_vma addr = reloc_entry->address; + long x = bfd_getshort(abfd, (bfd_byte *)data + addr); + + HOWTO_PREPARE(relocation, symbol_in); + + x = (x + relocation + reloc_entry->addend) >> 16; + + bfd_putshort(abfd, x, (bfd_byte *)data + addr); + return bfd_reloc_ok; +} + static reloc_howto_type howto_table[] = { -/* type rtshift size bitsize pc_rel bitpos abs ovff sf name partial inplace mask*/ - R_PCR16L, 2, 1, 16, true, 0, false, true, 0,"PCR16L", false, 0x0000ffff,0x0000ffff, - R_PCR26L, 2, 2, 26, true, 0, false, true, 0,"PCR26L", false, 0x03ffffff,0x03ffffff, - R_VRT16, 0, 1, 16, false, 0, false, true, 0,"VRT16", false, 0x0000ffff,0x0000ffff, - R_HVRT16,16, 1, 16, false, 0, false, true, 0,"HVRT16", false, 0x0000ffff,0x0000ffff, - R_LVRT16, 0, 1, 16, false, 0, false, true, 0,"LVRT16", false, 0x0000ffff,0x0000ffff, - R_VRT32, 0, 2, 32, false, 0, false, true, 0,"VRT32", false, 0xffffffff,0xffffffff, + HOWTO(R_PCR16L,02,1,16,true, 0,false,true,0,"PCR16L",false,0x0000ffff,0x0000ffff,true), + HOWTO(R_PCR26L,02,2,16,true, 0,false,true,0,"PCR26L",false,0x03ffffff,0x03ffffff,true), + HOWTO(R_VRT16, 00,1,16,false,0,false,true,0,"VRT16", false,0x0000ffff,0x0000ffff,true), + HOWTO(R_HVRT16,16,1,16,false,0,false,true,howto_hvrt16,"HVRT16",false,0x0000ffff,0x0000ffff,true), + HOWTO(R_LVRT16,00,1,16,false,0,false,true,0,"LVRT16",false,0x0000ffff,0x0000ffff,true), + HOWTO(R_VRT32, 00,2,32,false,0,false,true,0,"VRT32", false,0xffffffff,0xffffffff,true), }; @@ -67,7 +105,7 @@ bfd_target m88k_bcs_vec = '/', /* ar_pad_char */ 15, /* ar_max_namelen */ - _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */ + _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */ _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */ {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ @@ -314,10 +314,10 @@ typedef struct static reloc_howto_type abs32_howto - = {1,0,2,32,0,0,0,true,0,"abs32",false,0xffffffff, 0xffffffff}; + = HOWTO(1,0,2,32,0,0,0,true,0,"abs32",false,0xffffffff, 0xffffffff,false); static reloc_howto_type abs16_howto - = {1,0,1,16,0,0,0,true,0,"abs16",false,0x0000ffff, 0x0000ffff}; + = HOWTO(1,0,1,16,0,0,0,true,0,"abs16",false,0x0000ffff, 0x0000ffff,false); static ieee_symbol_index_type NOSYMBOL = { 0, 0}; diff --git a/bfd/libcoff.h b/bfd/libcoff.h index ca498f2..c00970f 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -42,7 +42,7 @@ typedef struct { typedef struct icofdata { - struct aouthdr *hdr; /* exec file header */ + struct aouthdr hdr; /* exec file header */ coff_symbol_type *symbols; /* symtab for input bfd */ unsigned int *conversion_table; file_ptr sym_filepos; diff --git a/bfd/oasys.c b/bfd/oasys.c index 4bce3cc..9f3c916 100644 --- a/bfd/oasys.c +++ b/bfd/oasys.c @@ -421,12 +421,11 @@ CONST char *section_name = symbol->section == (asection *)NULL ? */ static reloc_howto_type howto_table[]= { -/* T rs size bsz pcrel bitpos abs ovr sf name partial inplace mask */ -{ 0, 0, 1, 16, false,0, true,true,0,"abs16",true,0x0000ffff, 0x0000ffff}, -{ 0, 0, 2, 32, false,0, true,true,0,"abs32",true,0xffffffff, 0xffffffff}, -{ 0, 0, 1, 16, true,0, true,true,0,"pcrel16",true,0x0000ffff, 0x0000ffff}, -{ 0, 0, 2, 32, true,0, true,true,0,"pcrel32",true,0xffffffff, 0xffffffff} +HOWTO( 0, 0, 1, 16, false,0, true,true,0,"abs16",true,0x0000ffff, 0x0000ffff,false), +HOWTO( 0, 0, 2, 32, false,0, true,true,0,"abs32",true,0xffffffff, 0xffffffff,false), +HOWTO( 0, 0, 1, 16, true,0, true,true,0,"pcrel16",true,0x0000ffff, 0x0000ffff,false), +HOWTO( 0, 0, 2, 32, true,0, true,true,0,"pcrel32",true,0xffffffff, 0xffffffff,false) }; /* Read in all the section data and relocation stuff too */ diff --git a/bfd/sunos.c b/bfd/sunos.c index d91bb12..e9f3423 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -53,48 +53,47 @@ void (*bfd_error_trap)(); #define CTOR_TABLE_RELOC_IDX 2 static reloc_howto_type howto_table_ext[] = { - /* type rs size bsz pcrel bitpos abs ovrf sf name partial inplace mask*/ -{ (unsigned int) RELOC_8, 0, 0, 8, false, 0, true, true,0,"8", false, 0,0x000000ff}, -{ (unsigned int) RELOC_16, 0, 1, 16, false, 0, true, true,0,"16", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_32, 0, 2, 32, false, 0, true, true,0,"32", false, 0,0xffffffff}, -{ (unsigned int) RELOC_DISP8, 0, 0, 8, true, 0, false, true,0,"DISP8", false, 0,0x000000ff}, -{ (unsigned int) RELOC_DISP16, 0, 1, 16, true, 0, false, true,0,"DISP16", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_DISP32, 0, 2, 32, true, 0, false, true,0,"DISP32", false, 0,0xffffffff}, -{ (unsigned int) RELOC_WDISP30,2, 2, 30, true, 0, false, true,0,"WDISP30", false, 0,0x3fffffff}, -{ (unsigned int) RELOC_WDISP22,2, 2, 22, true, 0, false, true,0,"WDISP22", false, 0,0x003fffff}, -{ (unsigned int) RELOC_HI22, 10, 2, 22, false, 0, false, true,0,"HI22", false, 0,0x003fffff}, -{ (unsigned int) RELOC_22, 0, 2, 22, false, 0, false, true,0,"22", false, 0,0x003fffff}, -{ (unsigned int) RELOC_13, 0, 2, 13, false, 0, false, true,0,"13", false, 0,0x00001fff}, -{ (unsigned int) RELOC_LO10, 0, 2, 10, false, 0, false, true,0,"LO10", false, 0,0x000003ff}, -{ (unsigned int) RELOC_SFA_BASE,0, 2, 32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff}, -{ (unsigned int) RELOC_SFA_OFF13,0,2, 32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff}, -{ (unsigned int) RELOC_BASE10, 0, 2, 16, false, 0, false, true,0,"BASE10", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_BASE13, 0, 2, 13, false, 0, false, true,0,"BASE13", false, 0,0x00001fff}, -{ (unsigned int) RELOC_BASE22, 0, 2, 0, false, 0, false, true,0,"BASE22", false, 0,0x00000000}, -{ (unsigned int) RELOC_PC10, 0, 2, 10, false, 0, false, true,0,"PC10", false, 0,0x000003ff}, -{ (unsigned int) RELOC_PC22, 0, 2, 22, false, 0, false, true,0,"PC22", false, 0,0x003fffff}, -{ (unsigned int) RELOC_JMP_TBL,0, 2, 32, false, 0, false, true,0,"JMP_TBL", false, 0,0xffffffff}, -{ (unsigned int) RELOC_SEGOFF16,0, 2, 0, false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000}, -{ (unsigned int) RELOC_GLOB_DAT,0, 2, 0, false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000}, -{ (unsigned int) RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000}, -{ (unsigned int) RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0,0x00000000}, -{ (unsigned int) RELOC_JUMPTARG,2, 13, 16, true, 0, false, true,0,"JUMPTARG", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_CONST, 0, 13, 16, false, 0, false, true,0,"CONST", false, 0,0x0000ffff}, -{ (unsigned int) RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH", false, 0,0x0000ffff}, + HOWTO(RELOC_8, 0, 0, 8, false, 0, true, true,0,"8", false, 0,0x000000ff, false), + HOWTO(RELOC_16, 0, 1, 16, false, 0, true, true,0,"16", false, 0,0x0000ffff, false), + HOWTO(RELOC_32, 0, 2, 32, false, 0, true, true,0,"32", false, 0,0xffffffff, false), + HOWTO(RELOC_DISP8, 0, 0, 8, true, 0, false, true,0,"DISP8", false, 0,0x000000ff, false), + HOWTO(RELOC_DISP16, 0, 1, 16, true, 0, false, true,0,"DISP16", false, 0,0x0000ffff, false), + HOWTO(RELOC_DISP32, 0, 2, 32, true, 0, false, true,0,"DISP32", false, 0,0xffffffff, false), + HOWTO(RELOC_WDISP30,2, 2, 30, true, 0, false, true,0,"WDISP30", false, 0,0x3fffffff, false), + HOWTO(RELOC_WDISP22,2, 2, 22, true, 0, false, true,0,"WDISP22", false, 0,0x003fffff, false), + HOWTO(RELOC_HI22, 10, 2, 22, false, 0, false, true,0,"HI22", false, 0,0x003fffff, false), + HOWTO(RELOC_22, 0, 2, 22, false, 0, false, true,0,"22", false, 0,0x003fffff, false), + HOWTO(RELOC_13, 0, 2, 13, false, 0, false, true,0,"13", false, 0,0x00001fff, false), + HOWTO(RELOC_LO10, 0, 2, 10, false, 0, false, true,0,"LO10", false, 0,0x000003ff, false), + HOWTO(RELOC_SFA_BASE,0, 2, 32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff, false), + HOWTO(RELOC_SFA_OFF13,0,2, 32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff, false), + HOWTO(RELOC_BASE10, 0, 2, 16, false, 0, false, true,0,"BASE10", false, 0,0x0000ffff, false), + HOWTO(RELOC_BASE13, 0, 2, 13, false, 0, false, true,0,"BASE13", false, 0,0x00001fff, false), + HOWTO(RELOC_BASE22, 0, 2, 0, false, 0, false, true,0,"BASE22", false, 0,0x00000000, false), + HOWTO(RELOC_PC10, 0, 2, 10, false, 0, false, true,0,"PC10", false, 0,0x000003ff, false), + HOWTO(RELOC_PC22, 0, 2, 22, false, 0, false, true,0,"PC22", false, 0,0x003fffff, false), + HOWTO(RELOC_JMP_TBL,0, 2, 32, false, 0, false, true,0,"JMP_TBL", false, 0,0xffffffff, false), + HOWTO(RELOC_SEGOFF16,0, 2, 0, false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000, false), + HOWTO(RELOC_GLOB_DAT,0, 2, 0, false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000, false), + HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000, false), + HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0,0x00000000, false), + HOWTO(RELOC_JUMPTARG,2, 13, 16, true, 0, false, true,0,"JUMPTARG", false, 0,0x0000ffff, false), + HOWTO(RELOC_CONST, 0, 13, 16, false, 0, false, true,0,"CONST", false, 0,0x0000ffff, false), + HOWTO(RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH", false, 0,0x0000ffff, false), }; /* Convert standard reloc records to "arelent" format (incl byte swap). */ static reloc_howto_type howto_table_std[] = { /* type rs size bsz pcrel bitpos abs ovrf sf name*/ -{ (unsigned int) 0, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff}, -{ (unsigned int) 1, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff}, -{ (unsigned int) 2, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff}, -{ (unsigned int) 3, 0, 3, 64, false, 0, true, true,0,"64", true, 0xdeaddead,0xdeaddead}, -{ (unsigned int) 4, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff}, -{ (unsigned int) 5, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff}, -{ (unsigned int) 6, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff}, -{ (unsigned int) 7, 0, 3, 64, true, 0, false, true,0,"DISP64", true, 0xfeedface,0xfeedface}, +HOWTO( 0, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff, false), +HOWTO( 1, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff, false), +HOWTO( 2, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff, false), +HOWTO( 3, 0, 3, 64, false, 0, true, true,0,"64", true, 0xdeaddead,0xdeaddead, false), +HOWTO( 4, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff, false), +HOWTO( 5, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff, false), +HOWTO( 6, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff, false), +HOWTO( 7, 0, 3, 64, true, 0, false, true,0,"DISP64", true, 0xfeedface,0xfeedface, false), }; |