Convert to ISO C90 formatting.

This commit is contained in:
Nick Clifton 2005-03-22 16:14:43 +00:00
parent 28a094c2cc
commit c8e7bf0d21
8 changed files with 852 additions and 1318 deletions

View file

@ -1,3 +1,13 @@
2005-03-22 Nick Clifton <nickc@redhat.com>
* binary.c: Convert to ISO C90 formatting.
* coff-arm.c: Convert to ISO C90 formatting.
* coffgen.c: Convert to ISO C90 formatting.
* elf32-gen.c: Convert to ISO C90 formatting.
* elf64-gen.c: Convert to ISO C90 formatting.
* hash.c: Convert to ISO C90 formatting.
* ieee.c: Convert to ISO C90 formatting.
2005-03-22 Daniel Jacobowitz <dan@codesourcery.com>
* elf32-arm.c (elf32_arm_final_link_relocate): Don't fail for

View file

@ -1,6 +1,6 @@
/* BFD back-end for binary objects.
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004 Free Software Foundation, Inc.
2004, 2005 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
This file is part of BFD, the Binary File Descriptor library.
@ -41,18 +41,6 @@
a start symbol, an end symbol, and an absolute length symbol. */
#define BIN_SYMS 3
static bfd_boolean binary_mkobject PARAMS ((bfd *));
static const bfd_target *binary_object_p PARAMS ((bfd *));
static bfd_boolean binary_get_section_contents
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
static long binary_get_symtab_upper_bound PARAMS ((bfd *));
static char *mangle_name PARAMS ((bfd *, char *));
static long binary_canonicalize_symtab PARAMS ((bfd *, asymbol **));
static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
static bfd_boolean binary_set_section_contents
PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
static int binary_sizeof_headers PARAMS ((bfd *, bfd_boolean));
/* Set by external programs - specifies the BFD architecture and
machine number to be uses when creating binary BFDs. */
enum bfd_architecture bfd_external_binary_architecture = bfd_arch_unknown;
@ -61,8 +49,7 @@ unsigned long bfd_external_machine = 0;
/* Create a binary object. Invoked via bfd_set_format. */
static bfd_boolean
binary_mkobject (abfd)
bfd *abfd ATTRIBUTE_UNUSED;
binary_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
{
return TRUE;
}
@ -72,8 +59,7 @@ binary_mkobject (abfd)
being binary. */
static const bfd_target *
binary_object_p (abfd)
bfd *abfd;
binary_object_p (bfd *abfd)
{
struct stat statbuf;
asection *sec;
@ -102,7 +88,7 @@ binary_object_p (abfd)
sec->size = statbuf.st_size;
sec->filepos = 0;
abfd->tdata.any = (PTR) sec;
abfd->tdata.any = (void *) sec;
if (bfd_get_arch_info (abfd) != NULL)
{
@ -115,19 +101,18 @@ binary_object_p (abfd)
return abfd->xvec;
}
#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
#define binary_new_section_hook _bfd_generic_new_section_hook
#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
#define binary_new_section_hook _bfd_generic_new_section_hook
/* Get contents of the only section. */
static bfd_boolean
binary_get_section_contents (abfd, section, location, offset, count)
bfd *abfd;
asection *section ATTRIBUTE_UNUSED;
PTR location;
file_ptr offset;
bfd_size_type count;
binary_get_section_contents (bfd *abfd,
asection *section ATTRIBUTE_UNUSED,
void * location,
file_ptr offset,
bfd_size_type count)
{
if (bfd_seek (abfd, offset, SEEK_SET) != 0
|| bfd_bread (location, count, abfd) != count)
@ -138,8 +123,7 @@ binary_get_section_contents (abfd, section, location, offset, count)
/* Return the amount of memory needed to read the symbol table. */
static long
binary_get_symtab_upper_bound (abfd)
bfd *abfd ATTRIBUTE_UNUSED;
binary_get_symtab_upper_bound (bfd *abfd ATTRIBUTE_UNUSED)
{
return (BIN_SYMS + 1) * sizeof (asymbol *);
}
@ -147,9 +131,7 @@ binary_get_symtab_upper_bound (abfd)
/* Create a symbol name based on the bfd's filename. */
static char *
mangle_name (abfd, suffix)
bfd *abfd;
char *suffix;
mangle_name (bfd *abfd, char *suffix)
{
bfd_size_type size;
char *buf;
@ -159,7 +141,7 @@ mangle_name (abfd, suffix)
+ strlen (suffix)
+ sizeof "_binary__");
buf = (char *) bfd_alloc (abfd, size);
buf = bfd_alloc (abfd, size);
if (buf == NULL)
return "";
@ -176,16 +158,14 @@ mangle_name (abfd, suffix)
/* Return the symbol table. */
static long
binary_canonicalize_symtab (abfd, alocation)
bfd *abfd;
asymbol **alocation;
binary_canonicalize_symtab (bfd *abfd, asymbol **alocation)
{
asection *sec = (asection *) abfd->tdata.any;
asymbol *syms;
unsigned int i;
bfd_size_type amt = BIN_SYMS * sizeof (asymbol);
syms = (asymbol *) bfd_alloc (abfd, amt);
syms = bfd_alloc (abfd, amt);
if (syms == NULL)
return 0;
@ -220,33 +200,29 @@ binary_canonicalize_symtab (abfd, alocation)
return BIN_SYMS;
}
#define binary_make_empty_symbol _bfd_generic_make_empty_symbol
#define binary_print_symbol _bfd_nosymbols_print_symbol
#define binary_make_empty_symbol _bfd_generic_make_empty_symbol
#define binary_print_symbol _bfd_nosymbols_print_symbol
/* Get information about a symbol. */
static void
binary_get_symbol_info (ignore_abfd, symbol, ret)
bfd *ignore_abfd ATTRIBUTE_UNUSED;
asymbol *symbol;
symbol_info *ret;
binary_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
asymbol *symbol,
symbol_info *ret)
{
bfd_symbol_info (symbol, ret);
}
#define binary_bfd_is_local_label_name bfd_generic_is_local_label_name
#define binary_get_lineno _bfd_nosymbols_get_lineno
#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
#define binary_read_minisymbols _bfd_generic_read_minisymbols
#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
#define binary_get_reloc_upper_bound ((long (*) (bfd *, asection *)) bfd_0l)
#define binary_canonicalize_reloc ((long (*) (bfd *, asection *, arelent **, asymbol **)) bfd_0l)
#define binary_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
#define binary_bfd_is_local_label_name bfd_generic_is_local_label_name
#define binary_get_lineno _bfd_nosymbols_get_lineno
#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
#define binary_read_minisymbols _bfd_generic_read_minisymbols
#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
#define binary_get_reloc_upper_bound \
((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
#define binary_canonicalize_reloc \
((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
/* Set the architecture of a binary file. */
#define binary_set_arch_mach _bfd_generic_set_arch_mach
@ -254,12 +230,11 @@ binary_get_symbol_info (ignore_abfd, symbol, ret)
/* Write section contents of a binary file. */
static bfd_boolean
binary_set_section_contents (abfd, sec, data, offset, size)
bfd *abfd;
asection *sec;
const PTR data;
file_ptr offset;
bfd_size_type size;
binary_set_section_contents (bfd *abfd,
asection *sec,
const void * data,
file_ptr offset,
bfd_size_type size)
{
if (size == 0)
return TRUE;
@ -328,30 +303,26 @@ binary_set_section_contents (abfd, sec, data, offset, size)
/* No space is required for header information. */
static int
binary_sizeof_headers (abfd, exec)
bfd *abfd ATTRIBUTE_UNUSED;
bfd_boolean exec ATTRIBUTE_UNUSED;
binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
bfd_boolean exec ATTRIBUTE_UNUSED)
{
return 0;
}
#define binary_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
#define binary_bfd_relax_section bfd_generic_relax_section
#define binary_bfd_gc_sections bfd_generic_gc_sections
#define binary_bfd_merge_sections bfd_generic_merge_sections
#define binary_bfd_is_group_section bfd_generic_is_group_section
#define binary_bfd_discard_group bfd_generic_discard_group
#define binary_section_already_linked \
_bfd_generic_section_already_linked
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
#define binary_bfd_link_just_syms _bfd_generic_link_just_syms
#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define binary_bfd_final_link _bfd_generic_final_link
#define binary_bfd_link_split_section _bfd_generic_link_split_section
#define binary_get_section_contents_in_window \
_bfd_generic_get_section_contents_in_window
#define binary_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
#define binary_bfd_relax_section bfd_generic_relax_section
#define binary_bfd_gc_sections bfd_generic_gc_sections
#define binary_bfd_merge_sections bfd_generic_merge_sections
#define binary_bfd_is_group_section bfd_generic_is_group_section
#define binary_bfd_discard_group bfd_generic_discard_group
#define binary_section_already_linked _bfd_generic_section_already_linked
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
#define binary_bfd_link_just_syms _bfd_generic_link_just_syms
#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define binary_bfd_final_link _bfd_generic_final_link
#define binary_bfd_link_split_section _bfd_generic_link_split_section
#define binary_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
const bfd_target binary_vec =
{
@ -373,7 +344,7 @@ const bfd_target binary_vec =
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
{ /* bfd_check_format */
_bfd_dummy_target,
binary_object_p, /* bfd_check_format */
binary_object_p,
_bfd_dummy_target,
_bfd_dummy_target,
},

View file

@ -23,9 +23,7 @@
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "coff/arm.h"
#include "coff/internal.h"
#ifdef COFF_WITH_PE
@ -75,75 +73,10 @@
#endif
typedef enum {bunknown, b9, b12, b23} thumb_pcrel_branchtype;
/* some typedefs for holding instructions */
/* Some typedefs for holding instructions. */
typedef unsigned long int insn32;
typedef unsigned short int insn16;
/* Forward declarations for stupid compilers. */
static bfd_boolean coff_arm_relocate_section
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
struct internal_reloc *, struct internal_syment *, asection **));
static bfd_reloc_status_type aoutarm_fix_pcrel_26_done
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type aoutarm_fix_pcrel_26
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
#ifndef ARM_WINCE
static bfd_reloc_status_type coff_thumb_pcrel_23
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type coff_thumb_pcrel_9
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static insn32 insert_thumb_branch
PARAMS ((insn32, int));
#endif
static bfd_reloc_status_type coff_thumb_pcrel_12
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type coff_arm_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_boolean coff_arm_adjust_symndx
PARAMS ((bfd *, struct bfd_link_info *, bfd *,
asection *, struct internal_reloc *, bfd_boolean *));
static reloc_howto_type * coff_arm_rtype_to_howto
PARAMS ((bfd *, asection *, struct internal_reloc *,
struct coff_link_hash_entry *, struct internal_syment *,
bfd_vma *));
static bfd_reloc_status_type coff_thumb_pcrel_common
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **,
thumb_pcrel_branchtype));
static const struct reloc_howto_struct * coff_arm_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static struct bfd_link_hash_table * coff_arm_link_hash_table_create
PARAMS ((bfd *));
#ifndef ARM_WINCE
static struct coff_link_hash_entry * find_thumb_glue
PARAMS ((struct bfd_link_info *, const char *, bfd *));
#endif
static struct coff_link_hash_entry * find_arm_glue
PARAMS ((struct bfd_link_info *, const char *, bfd *));
#ifndef COFF_IMAGE_WITH_PE
static void record_arm_to_thumb_glue
PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
#ifndef ARM_WINCE
static void record_thumb_to_arm_glue
PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
#endif
#endif
static bfd_boolean coff_arm_merge_private_bfd_data
PARAMS ((bfd *, bfd *));
static bfd_boolean coff_arm_print_private_bfd_data
PARAMS ((bfd *, PTR));
static bfd_boolean _bfd_coff_arm_set_private_flags
PARAMS ((bfd *, flagword));
static bfd_boolean coff_arm_copy_private_bfd_data
PARAMS ((bfd *, bfd *));
static bfd_boolean coff_arm_is_local_label_name
PARAMS ((bfd *, const char *));
static bfd_boolean coff_arm_link_output_has_begun
PARAMS ((bfd *, struct coff_final_link_info *));
static bfd_boolean coff_arm_final_link_postscript
PARAMS ((bfd *, struct coff_final_link_info *));
static void arm_emit_base_file_entry
PARAMS ((struct bfd_link_info *, bfd *, asection *, bfd_vma));
/* The linker script knows the section names for placement.
The entry_names are used to do simple name mangling on the stubs.
Given a function name, and its type, the stub can be found. The
@ -158,18 +91,17 @@ static void arm_emit_base_file_entry
/* Used by the assembler. */
static bfd_reloc_status_type
coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
error_message)
bfd *abfd;
arelent *reloc_entry;
asymbol *symbol ATTRIBUTE_UNUSED;
PTR data;
asection *input_section ATTRIBUTE_UNUSED;
bfd *output_bfd;
char **error_message ATTRIBUTE_UNUSED;
coff_arm_reloc (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol ATTRIBUTE_UNUSED,
void * data,
asection *input_section ATTRIBUTE_UNUSED,
bfd *output_bfd,
char **error_message ATTRIBUTE_UNUSED)
{
symvalue diff;
if (output_bfd == (bfd *) NULL)
if (output_bfd == NULL)
return bfd_reloc_continue;
diff = reloc_entry->addend;
@ -239,7 +171,7 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
#define ARM_DISP16 5
#define ARM_DISP32 6
#define ARM_26D 7
/* 8 is unused */
/* 8 is unused. */
#define ARM_NEG16 9
#define ARM_NEG32 10
#define ARM_RVA32 11
@ -263,6 +195,19 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
#define ARM_SECREL 15
#endif
static bfd_reloc_status_type aoutarm_fix_pcrel_26_done
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type aoutarm_fix_pcrel_26
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type coff_thumb_pcrel_9
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type coff_thumb_pcrel_12
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
#ifndef ARM_WINCE
static bfd_reloc_status_type coff_thumb_pcrel_23
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
#endif
static reloc_howto_type aoutarm_std_reloc_howto[] =
{
#ifdef ARM_WINCE
@ -367,19 +312,19 @@ static reloc_howto_type aoutarm_std_reloc_howto[] =
0xffffffff,
PCRELOFFSET),
#else /* not ARM_WINCE */
HOWTO (ARM_8, /* type */
0, /* rightshift */
0, /* size */
8, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
coff_arm_reloc, /* special_function */
"ARM_8", /* name */
TRUE, /* partial_inplace */
0x000000ff, /* src_mask */
0x000000ff, /* dst_mask */
PCRELOFFSET /* pcrel_offset */),
HOWTO (ARM_8,
0,
0,
8,
FALSE,
0,
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_8",
TRUE,
0x000000ff,
0x000000ff,
PCRELOFFSET),
HOWTO (ARM_16,
0,
1,
@ -557,14 +502,12 @@ static reloc_howto_type aoutarm_std_reloc_howto[] =
#define NUM_RELOCS NUM_ELEM (aoutarm_std_reloc_howto)
#ifdef COFF_WITH_PE
static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
/* Return TRUE if this relocation should
appear in the output .reloc section. */
static bfd_boolean
in_reloc_p (abfd, howto)
bfd * abfd ATTRIBUTE_UNUSED;
reloc_howto_type * howto;
in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
reloc_howto_type * howto)
{
return !howto->pc_relative && howto->type != ARM_RVA32;
}
@ -579,13 +522,12 @@ in_reloc_p (abfd, howto)
#define coff_rtype_to_howto coff_arm_rtype_to_howto
static reloc_howto_type *
coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
bfd *abfd ATTRIBUTE_UNUSED;
asection *sec;
struct internal_reloc *rel;
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
struct internal_syment *sym ATTRIBUTE_UNUSED;
bfd_vma *addendp;
coff_arm_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
asection *sec,
struct internal_reloc *rel,
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
struct internal_syment *sym ATTRIBUTE_UNUSED,
bfd_vma *addendp)
{
reloc_howto_type * howto;
@ -603,15 +545,13 @@ coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
/* Used by the assembler. */
static bfd_reloc_status_type
aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *reloc_entry ATTRIBUTE_UNUSED;
asymbol *symbol ATTRIBUTE_UNUSED;
PTR data ATTRIBUTE_UNUSED;
asection *input_section ATTRIBUTE_UNUSED;
bfd *output_bfd ATTRIBUTE_UNUSED;
char **error_message ATTRIBUTE_UNUSED;
aoutarm_fix_pcrel_26_done (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry ATTRIBUTE_UNUSED,
asymbol *symbol ATTRIBUTE_UNUSED,
void * data ATTRIBUTE_UNUSED,
asection *input_section ATTRIBUTE_UNUSED,
bfd *output_bfd ATTRIBUTE_UNUSED,
char **error_message ATTRIBUTE_UNUSED)
{
/* This is dead simple at present. */
return bfd_reloc_ok;
@ -620,15 +560,13 @@ aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
/* Used by the assembler. */
static bfd_reloc_status_type
aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message)
bfd *abfd;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message ATTRIBUTE_UNUSED;
aoutarm_fix_pcrel_26 (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
bfd *output_bfd,
char **error_message ATTRIBUTE_UNUSED)
{
bfd_vma relocation;
bfd_size_type addr = reloc_entry->address;
@ -680,16 +618,14 @@ aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
}
static bfd_reloc_status_type
coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message, btype)
bfd *abfd;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message ATTRIBUTE_UNUSED;
thumb_pcrel_branchtype btype;
coff_thumb_pcrel_common (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
bfd *output_bfd,
char **error_message ATTRIBUTE_UNUSED,
thumb_pcrel_branchtype btype)
{
bfd_vma relocation = 0;
bfd_size_type addr = reloc_entry->address;
@ -701,7 +637,6 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section,
/* NOTE: This routine is currently used by GAS, but not by the link
phase. */
switch (btype)
{
case b9:
@ -809,15 +744,13 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section,
#ifndef ARM_WINCE
static bfd_reloc_status_type
coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message)
bfd *abfd;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message;
coff_thumb_pcrel_23 (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
bfd *output_bfd,
char **error_message)
{
return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message,
@ -825,15 +758,13 @@ coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section,
}
static bfd_reloc_status_type
coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message)
bfd *abfd;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message;
coff_thumb_pcrel_9 (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
bfd *output_bfd,
char **error_message)
{
return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message,
@ -842,15 +773,13 @@ coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section,
#endif /* not ARM_WINCE */
static bfd_reloc_status_type
coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section,
output_bfd, error_message)
bfd *abfd;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message;
coff_thumb_pcrel_12 (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
bfd *output_bfd,
char **error_message)
{
return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message,
@ -858,9 +787,7 @@ coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section,
}
static const struct reloc_howto_struct *
coff_arm_reloc_type_lookup (abfd, code)
bfd * abfd;
bfd_reloc_code_real_type code;
coff_arm_reloc_type_lookup (bfd * abfd, bfd_reloc_code_real_type code)
{
#define ASTD(i,j) case i: return aoutarm_std_reloc_howto + j
@ -871,7 +798,7 @@ coff_arm_reloc_type_lookup (abfd, code)
code = BFD_RELOC_32;
break;
default:
return (const struct reloc_howto_struct *) 0;
return NULL;
}
switch (code)
@ -896,17 +823,17 @@ coff_arm_reloc_type_lookup (abfd, code)
ASTD (BFD_RELOC_THUMB_PCREL_BRANCH23, ARM_THUMB23);
ASTD (BFD_RELOC_THUMB_PCREL_BLX, ARM_THUMB23);
#endif
default: return (const struct reloc_howto_struct *) 0;
default: return NULL;
}
}
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
#define COFF_PAGE_SIZE 0x1000
/* Turn a howto into a reloc nunmber */
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2
#define COFF_PAGE_SIZE 0x1000
/* Turn a howto into a reloc nunmber. */
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
#define BADMAG(x) ARMBADMAG(x)
#define ARM 1 /* Customize coffcode.h */
#define BADMAG(x) ARMBADMAG(x)
#define ARM 1 /* Customize coffcode.h. */
#ifndef ARM_WINCE
/* Make sure that the 'r_offset' field is copied properly
@ -943,21 +870,20 @@ struct coff_arm_link_hash_table
/* Create an ARM coff linker hash table. */
static struct bfd_link_hash_table *
coff_arm_link_hash_table_create (abfd)
bfd * abfd;
coff_arm_link_hash_table_create (bfd * abfd)
{
struct coff_arm_link_hash_table * ret;
bfd_size_type amt = sizeof (struct coff_arm_link_hash_table);
ret = (struct coff_arm_link_hash_table *) bfd_malloc (amt);
if (ret == (struct coff_arm_link_hash_table *) NULL)
ret = bfd_malloc (amt);
if (ret == NULL)
return NULL;
if (! _bfd_coff_link_hash_table_init
(& ret->root, abfd, _bfd_coff_link_hash_newfunc))
{
free (ret);
return (struct bfd_link_hash_table *) NULL;
return NULL;
}
ret->thumb_glue_size = 0;
@ -968,11 +894,10 @@ coff_arm_link_hash_table_create (abfd)
}
static void
arm_emit_base_file_entry (info, output_bfd, input_section, reloc_offset)
struct bfd_link_info *info;
bfd *output_bfd;
asection *input_section;
bfd_vma reloc_offset;
arm_emit_base_file_entry (struct bfd_link_info *info,
bfd *output_bfd,
asection *input_section,
bfd_vma reloc_offset)
{
bfd_vma addr = reloc_offset
- input_section->vma
@ -1018,18 +943,16 @@ arm_emit_base_file_entry (info, output_bfd, input_section, reloc_offset)
#define HI_LOW_ORDER 0xF000F800
static insn32
insert_thumb_branch (br_insn, rel_off)
insn32 br_insn;
int rel_off;
insert_thumb_branch (insn32 br_insn, int rel_off)
{
unsigned int low_bits;
unsigned int high_bits;
BFD_ASSERT((rel_off & 1) != 1);
BFD_ASSERT ((rel_off & 1) != 1);
rel_off >>= 1; /* half word aligned address */
low_bits = rel_off & 0x000007FF; /* the bottom 11 bits */
high_bits = (rel_off >> 11) & 0x000007FF; /* the top 11 bits */
rel_off >>= 1; /* Half word aligned address. */
low_bits = rel_off & 0x000007FF; /* The bottom 11 bits. */
high_bits = (rel_off >> 11) & 0x000007FF; /* The top 11 bits. */
if ((br_insn & LOW_HI_ORDER) == LOW_HI_ORDER)
br_insn = LOW_HI_ORDER | (low_bits << 16) | high_bits;
@ -1045,16 +968,15 @@ insert_thumb_branch (br_insn, rel_off)
static struct coff_link_hash_entry *
find_thumb_glue (info, name, input_bfd)
struct bfd_link_info *info;
const char *name;
bfd *input_bfd;
find_thumb_glue (struct bfd_link_info *info,
const char *name,
bfd *input_bfd)
{
char *tmp_name;
struct coff_link_hash_entry *myh;
bfd_size_type amt = strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1;
tmp_name = (char *) bfd_malloc (amt);
tmp_name = bfd_malloc (amt);
BFD_ASSERT (tmp_name);
@ -1075,16 +997,15 @@ find_thumb_glue (info, name, input_bfd)
#endif /* not ARM_WINCE */
static struct coff_link_hash_entry *
find_arm_glue (info, name, input_bfd)
struct bfd_link_info *info;
const char *name;
bfd *input_bfd;
find_arm_glue (struct bfd_link_info *info,
const char *name,
bfd *input_bfd)
{
char *tmp_name;
struct coff_link_hash_entry * myh;
bfd_size_type amt = strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1;
tmp_name = (char *) bfd_malloc (amt);
tmp_name = bfd_malloc (amt);
BFD_ASSERT (tmp_name);
@ -1193,16 +1114,14 @@ static const insn32 t2a6_bx_insn = 0xe12fff1e;
is different from the original. */
static bfd_boolean
coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
contents, relocs, syms, sections)
bfd *output_bfd;
struct bfd_link_info *info;
bfd *input_bfd;
asection *input_section;
bfd_byte *contents;
struct internal_reloc *relocs;
struct internal_syment *syms;
asection **sections;
coff_arm_relocate_section (bfd *output_bfd,
struct bfd_link_info *info,
bfd *input_bfd,
asection *input_section,
bfd_byte *contents,
struct internal_reloc *relocs,
struct internal_syment *syms,
asection **sections)
{
struct internal_reloc * rel;
struct internal_reloc * relend;
@ -1285,7 +1204,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
addend -= rel->r_vaddr - input_section->vma;
#ifdef ARM_WINCE
/* FIXME: I don't know why, but the hack is necessary for correct
generation of bl's instruction offset. */
generation of bl's instruction offset. */
addend -= 8;
#endif
howto = &fake_arm26_reloc;
@ -1453,7 +1372,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
|| h->class == C_STAT
|| h->class == C_LABEL)
{
/* Thumb code calling an ARM function */
/* Thumb code calling an ARM function. */
asection * s = 0;
bfd_vma my_offset;
unsigned long int tmp;
@ -1532,13 +1451,19 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
s->contents + my_offset + 2);
ret_offset =
((bfd_signed_vma) h_val) /* Address of destination of the stub. */
/* Address of destination of the stub. */
((bfd_signed_vma) h_val)
- ((bfd_signed_vma)
(s->output_offset /* Offset from the start of the current section to the start of the stubs. */
+ my_offset /* Offset of the start of this stub from the start of the stubs. */
+ s->output_section->vma) /* Address of the start of the current section. */
+ 4 /* The branch instruction is 4 bytes into the stub. */
+ 8); /* ARM branches work from the pc of the instruction + 8. */
/* Offset from the start of the current section to the start of the stubs. */
(s->output_offset
/* Offset of the start of this stub from the start of the stubs. */
+ my_offset
/* Address of the start of the current section. */
+ s->output_section->vma)
/* The branch instruction is 4 bytes into the stub. */
+ 4
/* ARM branches work from the pc of the instruction + 8. */
+ 8);
bfd_put_32 (output_bfd,
(bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
@ -1610,7 +1535,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
if (done)
rstat = bfd_reloc_ok;
#ifndef ARM_WINCE
/* Only perform this fix during the final link, not a relocatable link. nickc@cygnus.com */
/* Only perform this fix during the final link, not a relocatable link. */
else if (! info->relocatable
&& howto->type == ARM_THUMB23)
{
@ -1734,16 +1659,12 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
contents,
rel->r_vaddr - input_section->vma,
val, addend);
/* FIXME:
Is this the best way to fix up thumb addresses? krk@cygnus.com
Probably not, but it works, and if it works it don't need fixing! nickc@cygnus.com */
/* Only perform this fix during the final link, not a relocatable link. nickc@cygnus.com */
/* Only perform this fix during the final link, not a relocatable link. */
if (! info->relocatable
&& (rel->r_type == ARM_32 || rel->r_type == ARM_RVA32))
{
/* Determine if we need to set the bottom bit of a relocated address
because the address is the address of a Thumb code symbol. */
int patchit = FALSE;
if (h != NULL
@ -1756,7 +1677,6 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
&& sym->n_scnum > N_UNDEF)
{
/* No hash entry - use the symbol instead. */
if ( sym->n_sclass == C_THUMBSTATFUNC
|| sym->n_sclass == C_THUMBEXTFUNC)
patchit = TRUE;
@ -1813,8 +1733,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
#ifndef COFF_IMAGE_WITH_PE
bfd_boolean
bfd_arm_allocate_interworking_sections (info)
struct bfd_link_info * info;
bfd_arm_allocate_interworking_sections (struct bfd_link_info * info)
{
asection * s;
bfd_byte * foo;
@ -1833,8 +1752,7 @@ bfd_arm_allocate_interworking_sections (info)
BFD_ASSERT (s != NULL);
foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner,
globals->arm_glue_size);
foo = bfd_alloc (globals->bfd_of_glue_owner, globals->arm_glue_size);
s->size = globals->arm_glue_size;
s->contents = foo;
@ -1849,8 +1767,7 @@ bfd_arm_allocate_interworking_sections (info)
BFD_ASSERT (s != NULL);
foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner,
globals->thumb_glue_size);
foo = bfd_alloc (globals->bfd_of_glue_owner, globals->thumb_glue_size);
s->size = globals->thumb_glue_size;
s->contents = foo;
@ -1860,9 +1777,8 @@ bfd_arm_allocate_interworking_sections (info)
}
static void
record_arm_to_thumb_glue (info, h)
struct bfd_link_info * info;
struct coff_link_hash_entry * h;
record_arm_to_thumb_glue (struct bfd_link_info * info,
struct coff_link_hash_entry * h)
{
const char * name = h->root.root.string;
register asection * s;
@ -1884,7 +1800,7 @@ record_arm_to_thumb_glue (info, h)
BFD_ASSERT (s != NULL);
amt = strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1;
tmp_name = (char *) bfd_malloc (amt);
tmp_name = bfd_malloc (amt);
BFD_ASSERT (tmp_name);
@ -1896,13 +1812,13 @@ record_arm_to_thumb_glue (info, h)
if (myh != NULL)
{
free (tmp_name);
return; /* we've already seen this guy */
/* We've already seen this guy. */
return;
}
/* The only trick here is using globals->arm_glue_size as the value. Even
though the section isn't allocated yet, this is where we will be putting
it. */
bh = NULL;
val = globals->arm_glue_size + 1;
bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
@ -1917,12 +1833,11 @@ record_arm_to_thumb_glue (info, h)
#ifndef ARM_WINCE
static void
record_thumb_to_arm_glue (info, h)
struct bfd_link_info * info;
struct coff_link_hash_entry * h;
record_thumb_to_arm_glue (struct bfd_link_info * info,
struct coff_link_hash_entry * h)
{
const char * name = h->root.root.string;
register asection * s;
asection * s;
char * tmp_name;
struct coff_link_hash_entry * myh;
struct bfd_link_hash_entry * bh;
@ -1941,7 +1856,7 @@ record_thumb_to_arm_glue (info, h)
BFD_ASSERT (s != NULL);
amt = strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1;
tmp_name = (char *) bfd_malloc (amt);
tmp_name = bfd_malloc (amt);
BFD_ASSERT (tmp_name);
@ -1953,7 +1868,8 @@ record_thumb_to_arm_glue (info, h)
if (myh != NULL)
{
free (tmp_name);
return; /* we've already seen this guy */
/* We've already seen this guy. */
return;
}
bh = NULL;
@ -1973,7 +1889,7 @@ record_thumb_to_arm_glue (info, h)
#define BACK_FROM_ARM "__%s_back_from_arm"
amt = strlen (name) + strlen (CHANGE_TO_ARM) + 1;
tmp_name = (char *) bfd_malloc (amt);
tmp_name = bfd_malloc (amt);
BFD_ASSERT (tmp_name);
@ -1997,9 +1913,8 @@ record_thumb_to_arm_glue (info, h)
{armcoff/pe}.em */
bfd_boolean
bfd_arm_get_bfd_for_interworking (abfd, info)
bfd * abfd;
struct bfd_link_info * info;
bfd_arm_get_bfd_for_interworking (bfd * abfd,
struct bfd_link_info * info)
{
struct coff_arm_link_hash_table * globals;
flagword flags;
@ -2052,10 +1967,9 @@ bfd_arm_get_bfd_for_interworking (abfd, info)
}
bfd_boolean
bfd_arm_process_before_allocation (abfd, info, support_old_code)
bfd * abfd;
struct bfd_link_info * info;
int support_old_code;
bfd_arm_process_before_allocation (bfd * abfd,
struct bfd_link_info * info,
int support_old_code)
{
asection * sec;
struct coff_arm_link_hash_table * globals;
@ -2067,7 +1981,6 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code)
/* Here we have a bfd that is to be included on the link. We have a hook
to do reloc rummaging, before section sizes are nailed down. */
_bfd_coff_get_external_symbols (abfd);
globals = coff_arm_hash_table (info);
@ -2093,7 +2006,6 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code)
/* Load the relocs. */
/* FIXME: there may be a storage leak here. */
i = _bfd_coff_read_internal_relocs (abfd, sec, 1, 0, 0, 0);
BFD_ASSERT (i != 0);
@ -2186,13 +2098,12 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code)
into ARM_26D relocs. */
static bfd_boolean
coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
bfd *obfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
bfd *ibfd;
asection *sec;
struct internal_reloc *irel;
bfd_boolean *adjustedp;
coff_arm_adjust_symndx (bfd *obfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
bfd *ibfd,
asection *sec,
struct internal_reloc *irel,
bfd_boolean *adjustedp)
{
if (irel->r_type == ARM_26)
{
@ -2215,9 +2126,7 @@ coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
targets, eg different CPUs or different APCS's. */
static bfd_boolean
coff_arm_merge_private_bfd_data (ibfd, obfd)
bfd * ibfd;
bfd * obfd;
coff_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
{
BFD_ASSERT (ibfd != NULL && obfd != NULL);
@ -2330,9 +2239,7 @@ coff_arm_merge_private_bfd_data (ibfd, obfd)
/* Display the flags field. */
static bfd_boolean
coff_arm_print_private_bfd_data (abfd, ptr)
bfd * abfd;
PTR ptr;
coff_arm_print_private_bfd_data (bfd * abfd, void * ptr)
{
FILE * file = (FILE *) ptr;
@ -2377,9 +2284,7 @@ coff_arm_print_private_bfd_data (abfd, ptr)
called from both coffcode.h and peicode.h. */
static bfd_boolean
_bfd_coff_arm_set_private_flags (abfd, flags)
bfd * abfd;
flagword flags;
_bfd_coff_arm_set_private_flags (bfd * abfd, flagword flags)
{
flagword flag;
@ -2428,9 +2333,7 @@ _bfd_coff_arm_set_private_flags (abfd, flags)
from one instance of a BFD to another. */
static bfd_boolean
coff_arm_copy_private_bfd_data (src, dest)
bfd * src;
bfd * dest;
coff_arm_copy_private_bfd_data (bfd * src, bfd * dest)
{
BFD_ASSERT (src != NULL && dest != NULL);
@ -2442,7 +2345,7 @@ coff_arm_copy_private_bfd_data (src, dest)
if (src->xvec != dest->xvec)
return TRUE;
/* copy the flags field */
/* Copy the flags field. */
if (APCS_SET (src))
{
if (APCS_SET (dest))
@ -2502,10 +2405,10 @@ Warning: Clearing the interworking flag of %B because non-interworking code in %
non-local.
b) Allow other prefixes than ".", e.g. an empty prefix would cause all
labels of the form Lxxx to be stripped. */
static bfd_boolean
coff_arm_is_local_label_name (abfd, name)
bfd * abfd ATTRIBUTE_UNUSED;
const char * name;
coff_arm_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
const char * name)
{
#ifdef USER_LABEL_PREFIX
if (USER_LABEL_PREFIX[0] != 0)
@ -2540,23 +2443,18 @@ coff_arm_is_local_label_name (abfd, name)
the glue section is written last.
This does depend on bfd_make_section attaching a new section to the
end of the section list for the bfd.
krk@cygnus.com */
end of the section list for the bfd. */
static bfd_boolean
coff_arm_link_output_has_begun (sub, info)
bfd * sub;
struct coff_final_link_info * info;
coff_arm_link_output_has_begun (bfd * sub, struct coff_final_link_info * info)
{
return (sub->output_has_begun
|| sub == coff_arm_hash_table (info->info)->bfd_of_glue_owner);
}
static bfd_boolean
coff_arm_final_link_postscript (abfd, pfinfo)
bfd * abfd ATTRIBUTE_UNUSED;
struct coff_final_link_info * pfinfo;
coff_arm_final_link_postscript (bfd * abfd ATTRIBUTE_UNUSED,
struct coff_final_link_info * pfinfo)
{
struct coff_arm_link_hash_table * globals;

File diff suppressed because it is too large Load diff

View file

@ -1,22 +1,22 @@
/* Generic support for 32-bit ELF
Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004
Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004, 2005
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
This file is part of BFD, the Binary File Descriptor library.
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
(at your option) any later version.
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
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@ -41,53 +41,48 @@ static reloc_howto_type dummy =
0, /* dst_mask */
FALSE); /* pcrel_offset */
static void elf_generic_info_to_howto
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static void elf_generic_info_to_howto_rel
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static bfd_boolean elf32_generic_link_add_symbols
PARAMS ((bfd *, struct bfd_link_info *));
static void
elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *bfd_reloc;
Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
{
bfd_reloc->howto = &dummy;
}
static void
elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *bfd_reloc;
Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
{
bfd_reloc->howto = &dummy;
}
static void
check_for_relocs (bfd * abfd, asection * o, void * failed)
{
if ((o->flags & SEC_RELOC) != 0)
{
Elf_Internal_Ehdr *ehdrp;
ehdrp = elf_elfheader (abfd);
_bfd_error_handler (_("%B: Relocations in generic ELF (EM: %d)"),
abfd, ehdrp->e_machine);
bfd_set_error (bfd_error_wrong_format);
* (bfd_boolean *) failed = TRUE;
}
}
static bfd_boolean
elf32_generic_link_add_symbols (abfd, info)
bfd *abfd;
struct bfd_link_info *info;
elf32_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
{
asection *o;
bfd_boolean failed = FALSE;
/* Check if there are any relocations. */
for (o = abfd->sections; o != NULL; o = o->next)
if ((o->flags & SEC_RELOC) != 0)
{
Elf_Internal_Ehdr *ehdrp;
ehdrp = elf_elfheader (abfd);
(*_bfd_error_handler) (_("%B: Relocations in generic ELF (EM: %d)"),
abfd,
ehdrp->e_machine);
bfd_set_error (bfd_error_wrong_format);
return FALSE;
}
bfd_map_over_sections (abfd, check_for_relocs, & failed);
if (failed)
return FALSE;
return bfd_elf_link_add_symbols (abfd, info);
}

View file

@ -1,22 +1,22 @@
/* Generic support for 64-bit ELF
Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004
Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004, 2005
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
This file is part of BFD, the Binary File Descriptor library.
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
(at your option) any later version.
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
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@ -41,52 +41,48 @@ static reloc_howto_type dummy =
0, /* dst_mask */
FALSE); /* pcrel_offset */
static void elf_generic_info_to_howto
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static void elf_generic_info_to_howto_rel
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static bfd_boolean elf64_generic_link_add_symbols
PARAMS ((bfd *, struct bfd_link_info *));
static void
elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *bfd_reloc;
Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
{
bfd_reloc->howto = &dummy;
}
static void
elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *bfd_reloc;
Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
{
bfd_reloc->howto = &dummy;
}
static void
check_for_relocs (bfd * abfd, asection * o, void * failed)
{
if ((o->flags & SEC_RELOC) != 0)
{
Elf_Internal_Ehdr *ehdrp;
ehdrp = elf_elfheader (abfd);
_bfd_error_handler (_("%B: Relocations in generic ELF (EM: %d)"),
abfd, ehdrp->e_machine);
bfd_set_error (bfd_error_wrong_format);
* (bfd_boolean *) failed = TRUE;
}
}
static bfd_boolean
elf64_generic_link_add_symbols (abfd, info)
bfd *abfd;
struct bfd_link_info *info;
elf64_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
{
asection *o;
bfd_boolean failed = FALSE;
/* Check if there are any relocations. */
for (o = abfd->sections; o != NULL; o = o->next)
if ((o->flags & SEC_RELOC) != 0)
{
Elf_Internal_Ehdr *ehdrp;
ehdrp = elf_elfheader (abfd);
(*_bfd_error_handler) (_("%B: Relocations in generic ELF (EM: %d)"),
abfd, ehdrp->e_machine);
bfd_set_error (bfd_error_wrong_format);
return FALSE;
}
bfd_map_over_sections (abfd, check_for_relocs, & failed);
if (failed)
return FALSE;
return bfd_elf_link_add_symbols (abfd, info);
}

View file

@ -1,5 +1,5 @@
/* hash.c -- hash table routines for BFD
Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004
Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
@ -230,20 +230,18 @@ SUBSUBSECTION
EXAMPLE
.struct bfd_hash_entry *
.@var{function_name} (entry, table, string)
. struct bfd_hash_entry *entry;
. struct bfd_hash_table *table;
. const char *string;
.@var{function_name} (struct bfd_hash_entry *entry,
. struct bfd_hash_table *table,
. const char *string)
.{
. struct @var{entry_type} *ret = (@var{entry_type} *) entry;
.
. {* Allocate the structure if it has not already been allocated by a
. derived class. *}
. if (ret == (@var{entry_type} *) NULL)
. if (ret == NULL)
. {
. ret = ((@var{entry_type} *)
. bfd_hash_allocate (table, sizeof (@var{entry_type})));
. if (ret == (@var{entry_type} *) NULL)
. ret = bfd_hash_allocate (table, sizeof (* ret));
. if (ret == NULL)
. return NULL;
. }
.
@ -306,31 +304,29 @@ static size_t bfd_default_hash_table_size = DEFAULT_SIZE;
/* Create a new hash table, given a number of entries. */
bfd_boolean
bfd_hash_table_init_n (table, newfunc, size)
struct bfd_hash_table *table;
struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
struct bfd_hash_table *,
const char *));
unsigned int size;
bfd_hash_table_init_n (struct bfd_hash_table *table,
struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
struct bfd_hash_table *,
const char *),
unsigned int size)
{
unsigned int alloc;
alloc = size * sizeof (struct bfd_hash_entry *);
table->memory = (PTR) objalloc_create ();
table->memory = (void *) objalloc_create ();
if (table->memory == NULL)
{
bfd_set_error (bfd_error_no_memory);
return FALSE;
}
table->table = ((struct bfd_hash_entry **)
objalloc_alloc ((struct objalloc *) table->memory, alloc));
table->table = objalloc_alloc ((struct objalloc *) table->memory, alloc);
if (table->table == NULL)
{
bfd_set_error (bfd_error_no_memory);
return FALSE;
}
memset ((PTR) table->table, 0, alloc);
memset ((void *) table->table, 0, alloc);
table->size = size;
table->newfunc = newfunc;
return TRUE;
@ -339,11 +335,10 @@ bfd_hash_table_init_n (table, newfunc, size)
/* Create a new hash table with the default number of entries. */
bfd_boolean
bfd_hash_table_init (table, newfunc)
struct bfd_hash_table *table;
struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
struct bfd_hash_table *,
const char *));
bfd_hash_table_init (struct bfd_hash_table *table,
struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
struct bfd_hash_table *,
const char *))
{
return bfd_hash_table_init_n (table, newfunc, bfd_default_hash_table_size);
}
@ -351,25 +346,23 @@ bfd_hash_table_init (table, newfunc)
/* Free a hash table. */
void
bfd_hash_table_free (table)
struct bfd_hash_table *table;
bfd_hash_table_free (struct bfd_hash_table *table)
{
objalloc_free ((struct objalloc *) table->memory);
objalloc_free (table->memory);
table->memory = NULL;
}
/* Look up a string in a hash table. */
struct bfd_hash_entry *
bfd_hash_lookup (table, string, create, copy)
struct bfd_hash_table *table;
const char *string;
bfd_boolean create;
bfd_boolean copy;
bfd_hash_lookup (struct bfd_hash_table *table,
const char *string,
bfd_boolean create,
bfd_boolean copy)
{
register const unsigned char *s;
register unsigned long hash;
register unsigned int c;
const unsigned char *s;
unsigned long hash;
unsigned int c;
struct bfd_hash_entry *hashp;
unsigned int len;
unsigned int index;
@ -388,7 +381,7 @@ bfd_hash_lookup (table, string, create, copy)
index = hash % table->size;
for (hashp = table->table[index];
hashp != (struct bfd_hash_entry *) NULL;
hashp != NULL;
hashp = hashp->next)
{
if (hashp->hash == hash
@ -397,21 +390,20 @@ bfd_hash_lookup (table, string, create, copy)
}
if (! create)
return (struct bfd_hash_entry *) NULL;
return NULL;
hashp = (*table->newfunc) ((struct bfd_hash_entry *) NULL, table, string);
if (hashp == (struct bfd_hash_entry *) NULL)
return (struct bfd_hash_entry *) NULL;
hashp = (*table->newfunc) (NULL, table, string);
if (hashp == NULL)
return NULL;
if (copy)
{
char *new;
new = (char *) objalloc_alloc ((struct objalloc *) table->memory,
len + 1);
new = objalloc_alloc ((struct objalloc *) table->memory, len + 1);
if (!new)
{
bfd_set_error (bfd_error_no_memory);
return (struct bfd_hash_entry *) NULL;
return NULL;
}
memcpy (new, string, len + 1);
string = new;
@ -427,17 +419,16 @@ bfd_hash_lookup (table, string, create, copy)
/* Replace an entry in a hash table. */
void
bfd_hash_replace (table, old, nw)
struct bfd_hash_table *table;
struct bfd_hash_entry *old;
struct bfd_hash_entry *nw;
bfd_hash_replace (struct bfd_hash_table *table,
struct bfd_hash_entry *old,
struct bfd_hash_entry *nw)
{
unsigned int index;
struct bfd_hash_entry **pph;
index = old->hash % table->size;
for (pph = &table->table[index];
(*pph) != (struct bfd_hash_entry *) NULL;
(*pph) != NULL;
pph = &(*pph)->next)
{
if (*pph == old)
@ -450,28 +441,13 @@ bfd_hash_replace (table, old, nw)
abort ();
}
/* Base method for creating a new hash table entry. */
struct bfd_hash_entry *
bfd_hash_newfunc (entry, table, string)
struct bfd_hash_entry *entry;
struct bfd_hash_table *table;
const char *string ATTRIBUTE_UNUSED;
{
if (entry == (struct bfd_hash_entry *) NULL)
entry = ((struct bfd_hash_entry *)
bfd_hash_allocate (table, sizeof (struct bfd_hash_entry)));
return entry;
}
/* Allocate space in a hash table. */
PTR
bfd_hash_allocate (table, size)
struct bfd_hash_table *table;
unsigned int size;
void *
bfd_hash_allocate (struct bfd_hash_table *table,
unsigned int size)
{
PTR ret;
void * ret;
ret = objalloc_alloc ((struct objalloc *) table->memory, size);
if (ret == NULL && size != 0)
@ -479,13 +455,24 @@ bfd_hash_allocate (table, size)
return ret;
}
/* Base method for creating a new hash table entry. */
struct bfd_hash_entry *
bfd_hash_newfunc (struct bfd_hash_entry *entry,
struct bfd_hash_table *table,
const char *string ATTRIBUTE_UNUSED)
{
if (entry == NULL)
entry = bfd_hash_allocate (table, sizeof (* entry));
return entry;
}
/* Traverse a hash table. */
void
bfd_hash_traverse (table, func, info)
struct bfd_hash_table *table;
bfd_boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR));
PTR info;
bfd_hash_traverse (struct bfd_hash_table *table,
bfd_boolean (*func) (struct bfd_hash_entry *, void *),
void * info)
{
unsigned int i;
@ -494,10 +481,8 @@ bfd_hash_traverse (table, func, info)
struct bfd_hash_entry *p;
for (p = table->table[i]; p != NULL; p = p->next)
{
if (! (*func) (p, info))
return;
}
if (! (*func) (p, info))
return;
}
}
@ -558,30 +543,25 @@ struct bfd_strtab_hash
bfd_boolean xcoff;
};
static struct bfd_hash_entry *strtab_hash_newfunc
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
/* Routine to create an entry in a strtab. */
static struct bfd_hash_entry *
strtab_hash_newfunc (entry, table, string)
struct bfd_hash_entry *entry;
struct bfd_hash_table *table;
const char *string;
strtab_hash_newfunc (struct bfd_hash_entry *entry,
struct bfd_hash_table *table,
const char *string)
{
struct strtab_hash_entry *ret = (struct strtab_hash_entry *) entry;
/* Allocate the structure if it has not already been allocated by a
subclass. */
if (ret == (struct strtab_hash_entry *) NULL)
ret = ((struct strtab_hash_entry *)
bfd_hash_allocate (table, sizeof (struct strtab_hash_entry)));
if (ret == (struct strtab_hash_entry *) NULL)
if (ret == NULL)
ret = bfd_hash_allocate (table, sizeof (* entry));
if (ret == NULL)
return NULL;
/* Call the allocation method of the superclass. */
ret = ((struct strtab_hash_entry *)
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
ret = (struct strtab_hash_entry *)
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string);
if (ret)
{
@ -602,16 +582,16 @@ strtab_hash_newfunc (entry, table, string)
/* Create a new strtab. */
struct bfd_strtab_hash *
_bfd_stringtab_init ()
_bfd_stringtab_init (void)
{
struct bfd_strtab_hash *table;
bfd_size_type amt = sizeof (struct bfd_strtab_hash);
bfd_size_type amt = sizeof (* table);
table = (struct bfd_strtab_hash *) bfd_malloc (amt);
table = bfd_malloc (amt);
if (table == NULL)
return NULL;
if (! bfd_hash_table_init (&table->table, strtab_hash_newfunc))
if (! bfd_hash_table_init (& table->table, strtab_hash_newfunc))
{
free (table);
return NULL;
@ -630,7 +610,7 @@ _bfd_stringtab_init ()
string. */
struct bfd_strtab_hash *
_bfd_xcoff_stringtab_init ()
_bfd_xcoff_stringtab_init (void)
{
struct bfd_strtab_hash *ret;
@ -643,8 +623,7 @@ _bfd_xcoff_stringtab_init ()
/* Free a strtab. */
void
_bfd_stringtab_free (table)
struct bfd_strtab_hash *table;
_bfd_stringtab_free (struct bfd_strtab_hash *table)
{
bfd_hash_table_free (&table->table);
free (table);
@ -655,13 +634,12 @@ _bfd_stringtab_free (table)
table, and we don't eliminate duplicate strings. */
bfd_size_type
_bfd_stringtab_add (tab, str, hash, copy)
struct bfd_strtab_hash *tab;
const char *str;
bfd_boolean hash;
bfd_boolean copy;
_bfd_stringtab_add (struct bfd_strtab_hash *tab,
const char *str,
bfd_boolean hash,
bfd_boolean copy)
{
register struct strtab_hash_entry *entry;
struct strtab_hash_entry *entry;
if (hash)
{
@ -671,9 +649,7 @@ _bfd_stringtab_add (tab, str, hash, copy)
}
else
{
entry = ((struct strtab_hash_entry *)
bfd_hash_allocate (&tab->table,
sizeof (struct strtab_hash_entry)));
entry = bfd_hash_allocate (&tab->table, sizeof (* entry));
if (entry == NULL)
return (bfd_size_type) -1;
if (! copy)
@ -682,7 +658,7 @@ _bfd_stringtab_add (tab, str, hash, copy)
{
char *n;
n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
n = bfd_hash_allocate (&tab->table, strlen (str) + 1);
if (n == NULL)
return (bfd_size_type) -1;
entry->root.string = n;
@ -713,8 +689,7 @@ _bfd_stringtab_add (tab, str, hash, copy)
/* Get the number of bytes in a strtab. */
bfd_size_type
_bfd_stringtab_size (tab)
struct bfd_strtab_hash *tab;
_bfd_stringtab_size (struct bfd_strtab_hash *tab)
{
return tab->size;
}
@ -723,12 +698,10 @@ _bfd_stringtab_size (tab)
the file. */
bfd_boolean
_bfd_stringtab_emit (abfd, tab)
register bfd *abfd;
struct bfd_strtab_hash *tab;
_bfd_stringtab_emit (bfd *abfd, struct bfd_strtab_hash *tab)
{
register bfd_boolean xcoff;
register struct strtab_hash_entry *entry;
bfd_boolean xcoff;
struct strtab_hash_entry *entry;
xcoff = tab->xcoff;
@ -746,11 +719,11 @@ _bfd_stringtab_emit (abfd, tab)
/* The output length includes the null byte. */
bfd_put_16 (abfd, (bfd_vma) len, buf);
if (bfd_bwrite ((PTR) buf, (bfd_size_type) 2, abfd) != 2)
if (bfd_bwrite ((void *) buf, (bfd_size_type) 2, abfd) != 2)
return FALSE;
}
if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len)
if (bfd_bwrite ((void *) str, (bfd_size_type) len, abfd) != len)
return FALSE;
}

File diff suppressed because it is too large Load diff