/* Generic ECOFF (Extended-COFF) routines.
Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ Free Software Foundation, Inc.
Original version by Per Bothner.
Full support added by Ian Lance Taylor, ian@cygnus.com.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+ MA 02110-1301, USA. */
-#include "bfd.h"
#include "sysdep.h"
+#include "bfd.h"
#include "bfdlink.h"
#include "libbfd.h"
#include "aout/ar.h"
{
/* name, id, index, next, prev, flags, user_set_vma, */
"*DEBUG*", 0, 0, NULL, NULL, 0, 0,
- /* linker_mark, linker_has_input, gc_mark, gc_mark_from_eh, */
- 0, 0, 1, 0,
+ /* linker_mark, linker_has_input, gc_mark, */
+ 0, 0, 1,
/* segment_mark, sec_info_type, use_rela_p, has_tls_reloc, */
0, 0, 0, 0,
- /* has_gp_reloc, need_finalize_relax, reloc_done, */
- 0, 0, 0,
- /* vma, lma, size, rawsize, */
- 0, 0, 0, 0,
+ /* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax, */
+ 0, 0, 0,
+ /* reloc_done, vma, lma, size, rawsize, */
+ 0, 0, 0, 0, 0,
/* output_offset, output_section, alignment_power, */
0, NULL, 0,
/* relocation, orelocation, reloc_count, filepos, rel_filepos, */
/* Initialize a new section. */
bfd_boolean
-_bfd_ecoff_new_section_hook (bfd *abfd ATTRIBUTE_UNUSED,
- asection *section)
+_bfd_ecoff_new_section_hook (bfd *abfd, asection *section)
{
unsigned int i;
static struct
uncertain about .init on some systems and I don't know how shared
libraries work. */
- return TRUE;
+ return _bfd_generic_new_section_hook (abfd, section);
}
/* Determine the machine architecture and type. This is called from
return bfd_default_set_arch_mach (abfd, arch, mach);
}
+bfd_boolean
+_bfd_ecoff_no_long_sections (abfd, enable)
+ bfd *abfd;
+ int enable;
+{
+ (void) abfd;
+ (void) enable;
+ return FALSE;
+}
+
/* Get the magic number to use based on the architecture and machine.
This is the inverse of _bfd_ecoff_set_arch_mach_hook, above. */
sprintf (string,
"%s %s { ifd = %u, index = %lu }",
which, name, ifd,
- ((long) indx
+ ((unsigned long) indx
+ debug_info->symbolic_header.iextMax));
}
/* Get the size of the section headers. */
int
-_bfd_ecoff_sizeof_headers (bfd *abfd, bfd_boolean reloc ATTRIBUTE_UNUSED)
+_bfd_ecoff_sizeof_headers (bfd *abfd,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
asection *current;
int c;
const bfd_vma round = ecoff_backend (abfd)->round;
bfd_size_type amt;
- sofar = _bfd_ecoff_sizeof_headers (abfd, FALSE);
+ sofar = _bfd_ecoff_sizeof_headers (abfd, NULL);
file_sofar = sofar;
/* Sort the sections by VMA. */
}
if ((abfd->flags & D_PAGED) != 0)
- text_size = _bfd_ecoff_sizeof_headers (abfd, FALSE);
+ text_size = _bfd_ecoff_sizeof_headers (abfd, NULL);
else
text_size = 0;
text_start = 0;
bfd_slurp_armap, but that seems inappropriate since no other
target uses this format. Instead, we check directly for a COFF
armap. */
- if (strneq (nextname, "/ ", 16))
+ if (CONST_STRNEQ (nextname, "/ "))
return bfd_slurp_armap (abfd);
/* See if the first element is an armap. */
last_elt = current;
for (i = 0; i < orl_count; i++)
{
- unsigned int hash, rehash;
+ unsigned int hash, rehash = 0;
/* Advance firstreal to the file position of this archive
element. */
{
firstreal += arelt_size (current) + sizeof (struct ar_hdr);
firstreal += firstreal % 2;
- current = current->next;
+ current = current->archive_next;
}
while (current != map[i].u.abfd);
}
return TRUE;
}
-
-/* See whether this BFD is an archive. If it is, read in the armap
- and the extended name table. */
-
-const bfd_target *
-_bfd_ecoff_archive_p (bfd *abfd)
-{
- struct artdata *tdata_hold;
- char armag[SARMAG + 1];
- bfd_size_type amt;
-
- if (bfd_bread ((void *) armag, (bfd_size_type) SARMAG, abfd) != SARMAG)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (! strneq (armag, ARMAG, SARMAG))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- tdata_hold = bfd_ardata (abfd);
-
- amt = sizeof (struct artdata);
- bfd_ardata (abfd) = bfd_zalloc (abfd, amt);
- if (bfd_ardata (abfd) == NULL)
- {
- bfd_ardata (abfd) = tdata_hold;
- return NULL;
- }
-
- bfd_ardata (abfd)->first_file_filepos = SARMAG;
- /* Already cleared by bfd_zalloc above.
- bfd_ardata (abfd)->cache = NULL;
- bfd_ardata (abfd)->archive_head = NULL;
- bfd_ardata (abfd)->symdefs = NULL;
- bfd_ardata (abfd)->extended_names = NULL;
- bfd_ardata (abfd)->extended_names_size = 0;
- bfd_ardata (abfd)->tdata = NULL; */
-
- if (! _bfd_ecoff_slurp_armap (abfd)
- || ! _bfd_ecoff_slurp_extended_name_table (abfd))
- {
- bfd_release (abfd, bfd_ardata (abfd));
- bfd_ardata (abfd) = tdata_hold;
- return NULL;
- }
-
- if (bfd_has_map (abfd))
- {
- bfd *first;
-
- /* This archive has a map, so we may presume that the contents
- are object files. Make sure that if the first file in the
- archive can be recognized as an object file, it is for this
- target. If not, assume that this is the wrong format. If
- the first file is not an object file, somebody is doing
- something weird, and we permit it so that ar -t will work. */
-
- first = bfd_openr_next_archived_file (abfd, NULL);
- if (first != NULL)
- {
- first->target_defaulted = FALSE;
- if (bfd_check_format (first, bfd_object)
- && first->xvec != abfd->xvec)
- {
- /* We ought to close `first' here, but we can't, because
- we have no way to remove it from the archive cache.
- It's almost impossible to figure out when we can
- release bfd_ardata. FIXME. */
- bfd_set_error (bfd_error_wrong_object_format);
- bfd_ardata (abfd) = tdata_hold;
- return NULL;
- }
- /* And we ought to close `first' here too. */
- }
- }
-
- return abfd->xvec;
-}
\f
/* ECOFF linker code. */
/* If we are building an ECOFF hash table, save the external
symbol information. */
- if (info->hash->creator->flavour == bfd_get_flavour (abfd))
+ if (bfd_get_flavour (info->output_bfd) == bfd_get_flavour (abfd))
{
if (h->abfd == NULL
|| (! bfd_is_und_section (section)
while (*pundef != NULL)
{
struct bfd_link_hash_entry *h;
- unsigned int hash, rehash;
+ unsigned int hash, rehash = 0;
unsigned int file_offset;
const char *name;
bfd *element;