diff options
author | Alan Modra <amodra@gmail.com> | 2002-12-19 01:58:53 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-12-19 01:58:53 +0000 |
commit | 0171ee92b2f4558a80ddd1cc417ba22973f3a7e1 (patch) | |
tree | ee21296626028ebd7522a125295304ca11c0402a /bfd/coff-h8300.c | |
parent | 062b7c0c141b6d28a037c6acf3a822539e701827 (diff) | |
download | gdb-0171ee92b2f4558a80ddd1cc417ba22973f3a7e1.zip gdb-0171ee92b2f4558a80ddd1cc417ba22973f3a7e1.tar.gz gdb-0171ee92b2f4558a80ddd1cc417ba22973f3a7e1.tar.bz2 |
* coff-h8300.c: Include libiberty.h.
(h8300_reloc16_extra_cases): Check the hash table creator before
referencing h8300 specific fields. Stash the hash table pointer
in a local var. Comment typo fixes.
(h8300_bfd_link_add_symbols): Likewise.
Diffstat (limited to 'bfd/coff-h8300.c')
-rw-r--r-- | bfd/coff-h8300.c | 90 |
1 files changed, 56 insertions, 34 deletions
diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c index d571e18..5429076 100644 --- a/bfd/coff-h8300.c +++ b/bfd/coff-h8300.c @@ -28,6 +28,7 @@ #include "coff/h8300.h" #include "coff/internal.h" #include "libcoff.h" +#include "libiberty.h" #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1) @@ -65,7 +66,7 @@ funcvec_hash_newfunc static bfd_boolean funcvec_hash_table_init PARAMS ((struct funcvec_hash_table *, bfd *, - struct bfd_hash_entry *(*) (struct bfd_hash_entry *, + struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *))); @@ -137,8 +138,8 @@ funcvec_hash_newfunc (entry, gen_table, string) subclass. */ if (ret == NULL) ret = ((struct funcvec_hash_entry *) - bfd_hash_allocate (gen_table, - sizeof (struct funcvec_hash_entry))); + bfd_hash_allocate (gen_table, + sizeof (struct funcvec_hash_entry))); if (ret == NULL) return NULL; @@ -516,16 +517,16 @@ h8300_reloc16_estimate (abfd, input_section, reloc, shrink, link_info) Only perform this optimisation for jumps (code 0x5a) not subroutine calls, as otherwise it could transform: - mov.w r0,r0 - beq .L1 - jsr @_bar - .L1: rts - _bar: rts + mov.w r0,r0 + beq .L1 + jsr @_bar + .L1: rts + _bar: rts into: - mov.w r0,r0 - bne _bar - rts - _bar: rts + mov.w r0,r0 + bne _bar + rts + _bar: rts which changes the call (jsr) into a branch (bne). */ if (code == 0x5a @@ -564,7 +565,7 @@ h8300_reloc16_estimate (abfd, input_section, reloc, shrink, link_info) pc-relative branch. */ case R_PCRWORD: /* Get the address of the target of this branch, add one to the value - because the addend field in PCrel jumps is off by -1. */ + because the addend field in PCrel jumps is off by -1. */ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section) + 1; /* Get the address of the next instruction if we were to relax. */ @@ -649,7 +650,7 @@ h8300_reloc16_estimate (abfd, input_section, reloc, shrink, link_info) value = bfd_coff_reloc16_get_value (reloc, link_info, input_section); /* If this address is in 0x0000..0x7fff inclusive or - 0xff8000..0xffffff inclusive, then it can be relaxed. */ + 0xff8000..0xffffff inclusive, then it can be relaxed. */ if (value <= 0x7fff || value >= 0xff8000) { /* Change the reloc type. */ @@ -1091,7 +1092,25 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, const char *name; struct funcvec_hash_table *ftab; struct funcvec_hash_entry *h; - asection *vectors_sec = h8300_coff_hash_table (link_info)->vectors_sec; + struct h8300_coff_link_hash_table *htab; + asection *vectors_sec; + + if (link_info->hash->creator != abfd->xvec) + { + (*_bfd_error_handler) + (_("cannot handle R_MEM_INDIRECT reloc when using %s output"), + link_info->hash->creator->name); + + /* What else can we do? This function doesn't allow return + of an error, and we don't want to call abort as that + indicates an internal error. */ +#ifndef EXIT_FAILURE +#define EXIT_FAILURE 1 +#endif + xexit (EXIT_FAILURE); + } + htab = h8300_coff_hash_table (link_info); + vectors_sec = htab->vectors_sec; /* First see if this is a reloc against the absolute symbol or against a symbol with a nonnegative value <= 0xff. */ @@ -1140,12 +1159,12 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, name = new_name; } - ftab = h8300_coff_hash_table (link_info)->funcvec_hash_table; + ftab = htab->funcvec_hash_table; h = funcvec_hash_lookup (ftab, name, FALSE, FALSE); /* This shouldn't ever happen. If it does that means we've got data corruption of some kind. Aborting seems like a reasonable - think to do here. */ + thing to do here. */ if (h == NULL || vectors_sec == NULL) abort (); @@ -1214,24 +1233,30 @@ h8300_bfd_link_add_symbols (abfd, info) asection *sec; struct funcvec_hash_table *funcvec_hash_table; bfd_size_type amt; + struct h8300_coff_link_hash_table *htab; + + /* Add the symbols using the generic code. */ + _bfd_generic_link_add_symbols (abfd, info); + + if (info->hash->creator != abfd->xvec) + return TRUE; + + htab = h8300_coff_hash_table (info); /* If we haven't created a vectors section, do so now. */ - if (!h8300_coff_hash_table (info)->vectors_sec) + if (!htab->vectors_sec) { flagword flags; /* Make sure the appropriate flags are set, including SEC_IN_MEMORY. */ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_READONLY); - h8300_coff_hash_table (info)->vectors_sec = bfd_make_section (abfd, - ".vectors"); + htab->vectors_sec = bfd_make_section (abfd, ".vectors"); /* If the section wasn't created, or we couldn't set the flags, - quit quickly now, rather than dieing a painful death later. */ - if (! h8300_coff_hash_table (info)->vectors_sec - || ! bfd_set_section_flags (abfd, - h8300_coff_hash_table(info)->vectors_sec, - flags)) + quit quickly now, rather than dying a painful death later. */ + if (!htab->vectors_sec + || !bfd_set_section_flags (abfd, htab->vectors_sec, flags)) return FALSE; /* Also create the vector hash table. */ @@ -1250,14 +1275,11 @@ h8300_bfd_link_add_symbols (abfd, info) } /* Store away a pointer to the funcvec hash table. */ - h8300_coff_hash_table (info)->funcvec_hash_table = funcvec_hash_table; + htab->funcvec_hash_table = funcvec_hash_table; } /* Load up the function vector hash table. */ - funcvec_hash_table = h8300_coff_hash_table (info)->funcvec_hash_table; - - /* Add the symbols using the generic code. */ - _bfd_generic_link_add_symbols (abfd, info); + funcvec_hash_table = htab->funcvec_hash_table; /* Now scan the relocs for all the sections in this bfd; create additional space in the .vectors section as needed. */ @@ -1322,7 +1344,7 @@ h8300_bfd_link_add_symbols (abfd, info) } /* Look this symbol up in the function vector hash table. */ - ftab = h8300_coff_hash_table (info)->funcvec_hash_table; + ftab = htab->funcvec_hash_table; h = funcvec_hash_lookup (ftab, name, FALSE, FALSE); /* If this symbol isn't already in the hash table, add @@ -1339,10 +1361,10 @@ h8300_bfd_link_add_symbols (abfd, info) /* Bump the size of the vectors section. Each vector takes 2 bytes on the h8300 and 4 bytes on the h8300h. */ if (bfd_get_mach (abfd) == bfd_mach_h8300) - h8300_coff_hash_table (info)->vectors_sec->_raw_size += 2; + htab->vectors_sec->_raw_size += 2; else if (bfd_get_mach (abfd) == bfd_mach_h8300h || bfd_get_mach (abfd) == bfd_mach_h8300s) - h8300_coff_hash_table (info)->vectors_sec->_raw_size += 4; + htab->vectors_sec->_raw_size += 4; } } } @@ -1353,7 +1375,7 @@ h8300_bfd_link_add_symbols (abfd, info) /* Now actually allocate some space for the function vector. It's wasteful to do this more than once, but this is easier. */ - sec = h8300_coff_hash_table (info)->vectors_sec; + sec = htab->vectors_sec; if (sec->_raw_size != 0) { /* Free the old contents. */ |