diff options
author | Ian Lance Taylor <ian@airs.com> | 1997-03-17 16:36:08 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1997-03-17 16:36:08 +0000 |
commit | 50ede03d760c23490792fc84fe98969fe5dfbacd (patch) | |
tree | 955f7be2e6db6fa129458cf319af4766d8bbfea6 /bfd | |
parent | 590c50d82cc981b0523e39fafa48c4d6585ec035 (diff) | |
download | gdb-50ede03d760c23490792fc84fe98969fe5dfbacd.zip gdb-50ede03d760c23490792fc84fe98969fe5dfbacd.tar.gz gdb-50ede03d760c23490792fc84fe98969fe5dfbacd.tar.bz2 |
* opncls.c (bfd_alloc): Rename from bfd_alloc_by_size_t. Remove
old version of bfd_alloc.
* libbfd-in.h (bfd_alloc_by_size_t): Don't declare.
* libbfd.h: Rebuild.
* Several files: Call bfd_alloc rather than bfd_alloc_by_size_t.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 8 | ||||
-rw-r--r-- | bfd/coffcode.h | 50 | ||||
-rw-r--r-- | bfd/elf32-hppa.c | 21 | ||||
-rw-r--r-- | bfd/libbfd-in.h | 3 | ||||
-rw-r--r-- | bfd/libbfd.h | 3 | ||||
-rw-r--r-- | bfd/opncls.c | 22 |
6 files changed, 65 insertions, 42 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c8afb4b..63fd35e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +Mon Mar 17 11:32:53 1997 Ian Lance Taylor <ian@cygnus.com> + + * opncls.c (bfd_alloc): Rename from bfd_alloc_by_size_t. Remove + old version of bfd_alloc. + * libbfd-in.h (bfd_alloc_by_size_t): Don't declare. + * libbfd.h: Rebuild. + * Several files: Call bfd_alloc rather than bfd_alloc_by_size_t. + Sat Mar 15 15:24:18 1997 Ian Lance Taylor <ian@cygnus.com> * elf32-mips.c (mips_elf_is_local_label_name): Accept the generic diff --git a/bfd/coffcode.h b/bfd/coffcode.h index e2a7dde..948165e 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -796,7 +796,7 @@ dependent COFF routines: . boolean (*_bfd_coff_sym_is_global) PARAMS (( . bfd *abfd, . struct internal_syment *)); -. void (*_bfd_coff_compute_section_file_positions) PARAMS (( +. boolean (*_bfd_coff_compute_section_file_positions) PARAMS (( . bfd *abfd)); . boolean (*_bfd_coff_start_final_link) PARAMS (( . bfd *output_bfd, @@ -2069,13 +2069,14 @@ coff_set_arch_mach (abfd, arch, machine) /* Calculate the file position for each section. */ -static void +static boolean coff_compute_section_file_positions (abfd) bfd * abfd; { asection *current; asection *previous = (asection *) NULL; file_ptr sofar = FILHSZ; + boolean align_adjust; #ifndef I960 file_ptr old_sofar; @@ -2161,6 +2162,7 @@ coff_compute_section_file_positions (abfd) sofar += SCNHSZ; #endif + align_adjust = false; for (current = abfd->sections, count = 1; current != (asection *) NULL; current = current->next, ++count) @@ -2209,20 +2211,14 @@ coff_compute_section_file_positions (abfd) current->used_by_bfd = (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)); if (current->used_by_bfd == NULL) - { - /* FIXME: Return error. */ - abort (); - } + return false; } if (pei_section_data (abfd, current) == NULL) { coff_section_data (abfd, current)->tdata = (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata)); if (coff_section_data (abfd, current)->tdata == NULL) - { - /* FIXME: Return error. */ - abort (); - } + return false; } if (pei_section_data (abfd, current)->virt_size == 0) pei_section_data (abfd, current)->virt_size = current->_raw_size; @@ -2241,12 +2237,14 @@ coff_compute_section_file_positions (abfd) old_size = current->_raw_size; current->_raw_size = BFD_ALIGN (current->_raw_size, 1 << current->alignment_power); + align_adjust = current->_raw_size != old_size; sofar += current->_raw_size - old_size; } else { old_sofar = sofar; sofar = BFD_ALIGN (sofar, 1 << current->alignment_power); + align_adjust = sofar != old_sofar; current->_raw_size += sofar - old_sofar; } #endif @@ -2262,12 +2260,30 @@ coff_compute_section_file_positions (abfd) previous = current; } - /* Make sure the relocations are aligned. */ + /* It is now safe to write to the output file. If we needed an + alignment adjustment for the last section, then make sure that + there is a byte at offset sofar. If there are no symbols and no + relocs, then nothing follows the last section. If we don't force + the last byte out, then the file may appear to be truncated. */ + if (align_adjust) + { + bfd_byte b; + + b = 0; + if (bfd_seek (abfd, sofar - 1, SEEK_SET) != 0 + || bfd_write (&b, 1, 1, abfd) != 1) + return false; + } + + /* Make sure the relocations are aligned. We don't need to make + sure that this byte exists, because it will only matter if there + really are relocs. */ sofar = BFD_ALIGN (sofar, 1 << COFF_DEFAULT_SECTION_ALIGNMENT_POWER); obj_relocbase (abfd) = sofar; abfd->output_has_begun = true; + return true; } #if 0 @@ -2324,7 +2340,7 @@ coff_add_missing_symbols (abfd) if (!need_text && !need_data && !need_bss && !need_file) return true; nsyms += need_text + need_data + need_bss + need_file; - sympp2 = (asymbol **) bfd_alloc_by_size_t (abfd, nsyms * sizeof (asymbol *)); + sympp2 = (asymbol **) bfd_alloc (abfd, nsyms * sizeof (asymbol *)); if (!sympp2) return false; memcpy (sympp2, sympp, i * sizeof (asymbol *)); @@ -2379,7 +2395,10 @@ coff_write_object_contents (abfd) lnno_size = coff_count_linenumbers (abfd) * LINESZ; if (abfd->output_has_begun == false) - coff_compute_section_file_positions (abfd); + { + if (! coff_compute_section_file_positions (abfd)) + return false; + } reloc_base = obj_relocbase (abfd); @@ -3015,7 +3034,10 @@ coff_set_section_contents (abfd, section, location, offset, count) bfd_size_type count; { if (abfd->output_has_begun == false) /* set by bfd.c handler */ - coff_compute_section_file_positions (abfd); + { + if (! coff_compute_section_file_positions (abfd)) + return false; + } #if defined(_LIB) && !defined(TARG_AUX) diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 322eb55..784c699 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1,5 +1,6 @@ /* BFD back-end for HP PA-RISC ELF files. - Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 + Free Software Foundation, Inc. Written by @@ -234,7 +235,7 @@ static void add_entry_to_symext_chain static void elf_hppa_tc_make_sections PARAMS ((bfd *, symext_chainS *)); -static boolean hppa_elf_is_local_label PARAMS ((bfd *, asymbol *)); +static boolean hppa_elf_is_local_label_name PARAMS ((bfd *, const char *)); static boolean elf32_hppa_add_symbol_hook PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, @@ -953,14 +954,14 @@ hppa_elf_gen_reloc_type (abfd, base_type, format, field, ignore, sym) elf32_hppa_reloc_type **final_types; /* Allocate slots for the BFD relocation. */ - final_types = (elf32_hppa_reloc_type **) - bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type *) * 2); + final_types = ((elf32_hppa_reloc_type **) + bfd_alloc (abfd, sizeof (elf32_hppa_reloc_type *) * 2)); if (final_types == NULL) return NULL; /* Allocate space for the relocation itself. */ - finaltype = (elf32_hppa_reloc_type *) - bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type)); + finaltype = ((elf32_hppa_reloc_type *) + bfd_alloc (abfd, sizeof (elf32_hppa_reloc_type))); if (finaltype == NULL) return NULL; @@ -1553,11 +1554,11 @@ elf_hppa_reloc_type_lookup (abfd, code) /* Return true if SYM represents a local label symbol. */ static boolean -hppa_elf_is_local_label (abfd, sym) +hppa_elf_is_local_label_name (abfd, name) bfd *abfd; - asymbol *sym; + const char *name; { - return (sym->name[0] == 'L' && sym->name[1] == '$'); + return (name[0] == 'L' && name[1] == '$'); } /* Do any backend specific processing when beginning to write an object @@ -2959,7 +2960,7 @@ error_return: /* Misc BFD support code. */ #define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup -#define bfd_elf32_bfd_is_local_label hppa_elf_is_local_label +#define bfd_elf32_bfd_is_local_label_name hppa_elf_is_local_label_name /* Symbol extension stuff. */ #define bfd_elf32_set_section_contents elf32_hppa_set_section_contents diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index e378aff..cefe914 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -93,7 +93,6 @@ PTR bfd_alloc PARAMS ((bfd *abfd, size_t size)); PTR bfd_zalloc PARAMS ((bfd *abfd, size_t size)); void bfd_alloc_grow PARAMS ((bfd *abfd, PTR thing, size_t size)); PTR bfd_alloc_finish PARAMS ((bfd *abfd)); -PTR bfd_alloc_by_size_t PARAMS ((bfd *abfd, size_t wanted)); #define bfd_release(x,y) (void) obstack_free(&(x->memory),y) @@ -486,7 +485,7 @@ extern bfd *bfd_last_cache; /* List of supported target vectors, and the default vector (if bfd_default_vector[0] is NULL, there is no default). */ extern const bfd_target * const bfd_target_vector[]; -extern const bfd_target * const bfd_default_vector[]; +extern const bfd_target *bfd_default_vector[]; /* Functions shared by the ECOFF and MIPS ELF backends, which have no other common header files. */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index a0864ea..60f32cb 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -93,7 +93,6 @@ PTR bfd_alloc PARAMS ((bfd *abfd, size_t size)); PTR bfd_zalloc PARAMS ((bfd *abfd, size_t size)); void bfd_alloc_grow PARAMS ((bfd *abfd, PTR thing, size_t size)); PTR bfd_alloc_finish PARAMS ((bfd *abfd)); -PTR bfd_alloc_by_size_t PARAMS ((bfd *abfd, size_t wanted)); #define bfd_release(x,y) (void) obstack_free(&(x->memory),y) @@ -486,7 +485,7 @@ extern bfd *bfd_last_cache; /* List of supported target vectors, and the default vector (if bfd_default_vector[0] is NULL, there is no default). */ extern const bfd_target * const bfd_target_vector[]; -extern const bfd_target * const bfd_default_vector[]; +extern const bfd_target *bfd_default_vector[]; /* Functions shared by the ECOFF and MIPS ELF backends, which have no other common header files. */ diff --git a/bfd/opncls.c b/bfd/opncls.c index ee8d152..f65dbff 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -1,5 +1,7 @@ /* opncls.c -- open and close a BFD. - Copyright (C) 1990 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 + Free Software Foundation, Inc. + Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -226,7 +228,7 @@ bfd_fdopenr (filename, target, fd) bfd_set_error (bfd_error_invalid_target); return NULL; } -#if defined(VMS) || defined(__GO32__) || defined (WINGDB) +#if defined(VMS) || defined(__GO32__) nbfd->iostream = (PTR)fopen(filename, FOPEN_RB); #else /* (O_ACCMODE) parens are to avoid Ultrix header file bug */ @@ -539,19 +541,19 @@ bfd_create (filename, templ) /* INTERNAL_FUNCTION - bfd_alloc_by_size_t + bfd_alloc SYNOPSIS - PTR bfd_alloc_by_size_t(bfd *abfd, size_t wanted); + PTR bfd_alloc (bfd *abfd, size_t wanted); DESCRIPTION Allocate a block of @var{wanted} bytes of memory in the obstack - attatched to <<abfd>> and return a pointer to it. + attached to <<abfd>> and return a pointer to it. */ PTR -bfd_alloc_by_size_t (abfd, size) +bfd_alloc (abfd, size) bfd *abfd; size_t size; { @@ -585,14 +587,6 @@ bfd_alloc_finish (abfd) } PTR -bfd_alloc (abfd, size) - bfd *abfd; - size_t size; -{ - return bfd_alloc_by_size_t(abfd, (size_t)size); -} - -PTR bfd_zalloc (abfd, size) bfd *abfd; size_t size; |