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.
+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
. 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,
/* 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;
sofar += SCNHSZ;
#endif
+ align_adjust = false;
for (current = abfd->sections, count = 1;
current != (asection *) NULL;
current = current->next, ++count)
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;
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
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
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 *));
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);
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)
/* 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
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 *,
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;
/* 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
/* 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
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)
/* 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. */
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)
/* 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. */
/* 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.
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 */
/*
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;
{
return ret;
}
-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;