* elf64-x86-64.c: Convert to ISO C90 prototypes, remove

unnecessary prototypes.  Replace PTR with void *.
This commit is contained in:
Andreas Jaeger 2003-06-29 05:57:36 +00:00
parent 43d5792ce1
commit 27482721cf
2 changed files with 72 additions and 175 deletions

View File

@ -1,3 +1,8 @@
2003-06-29 Andreas Jaeger <aj@suse.de>
* elf64-x86-64.c: Convert to ISO C90 prototypes, remove
unnecessary prototypes. Replace PTR with void *.
2003-06-29 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
* elfxx-mips.c: Allow lazy binding for R_MIPS_JALR.

View File

@ -150,72 +150,14 @@ static const struct elf_reloc_map x86_64_reloc_map[] =
{ BFD_RELOC_VTABLE_ENTRY, R_X86_64_GNU_VTENTRY, },
};
static reloc_howto_type *elf64_x86_64_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static void elf64_x86_64_info_to_howto
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static bfd_boolean elf64_x86_64_grok_prstatus
PARAMS ((bfd *, Elf_Internal_Note *));
static bfd_boolean elf64_x86_64_grok_psinfo
PARAMS ((bfd *, Elf_Internal_Note *));
static struct bfd_link_hash_table *elf64_x86_64_link_hash_table_create
PARAMS ((bfd *));
static int elf64_x86_64_tls_transition
PARAMS ((struct bfd_link_info *, int, int));
static bfd_boolean elf64_x86_64_mkobject
PARAMS((bfd *));
static bfd_boolean elf64_x86_64_elf_object_p PARAMS ((bfd *abfd));
static bfd_boolean create_got_section
PARAMS((bfd *, struct bfd_link_info *));
static bfd_boolean elf64_x86_64_create_dynamic_sections
PARAMS((bfd *, struct bfd_link_info *));
static void elf64_x86_64_copy_indirect_symbol
PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *,
struct elf_link_hash_entry *));
static bfd_boolean elf64_x86_64_check_relocs
PARAMS ((bfd *, struct bfd_link_info *, asection *sec,
const Elf_Internal_Rela *));
static asection *elf64_x86_64_gc_mark_hook
PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
struct elf_link_hash_entry *, Elf_Internal_Sym *));
static bfd_boolean elf64_x86_64_gc_sweep_hook
PARAMS ((bfd *, struct bfd_link_info *, asection *,
const Elf_Internal_Rela *));
static struct bfd_hash_entry *link_hash_newfunc
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
static bfd_boolean elf64_x86_64_adjust_dynamic_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
static bfd_boolean allocate_dynrelocs
PARAMS ((struct elf_link_hash_entry *, PTR));
static bfd_boolean readonly_dynrelocs
PARAMS ((struct elf_link_hash_entry *, PTR));
static bfd_boolean elf64_x86_64_size_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static bfd_vma dtpoff_base
PARAMS ((struct bfd_link_info *));
static bfd_vma tpoff
PARAMS ((struct bfd_link_info *, bfd_vma));
static bfd_boolean elf64_x86_64_relocate_section
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
static bfd_boolean elf64_x86_64_finish_dynamic_symbol
PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
Elf_Internal_Sym *sym));
static bfd_boolean elf64_x86_64_finish_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static enum elf_reloc_type_class elf64_x86_64_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
/* Given a BFD reloc type, return a HOWTO structure. */
static reloc_howto_type *
elf64_x86_64_reloc_type_lookup (abfd, code)
bfd *abfd ATTRIBUTE_UNUSED;
bfd_reloc_code_real_type code;
elf64_x86_64_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
bfd_reloc_code_real_type code)
{
unsigned int i;
for (i = 0; i < sizeof (x86_64_reloc_map) / sizeof (struct elf_reloc_map);
i++)
{
@ -228,10 +170,8 @@ elf64_x86_64_reloc_type_lookup (abfd, code)
/* Given an x86_64 ELF reloc type, fill in an arelent structure. */
static void
elf64_x86_64_info_to_howto (abfd, cache_ptr, dst)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *cache_ptr;
Elf_Internal_Rela *dst;
elf64_x86_64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
Elf_Internal_Rela *dst)
{
unsigned r_type, i;
@ -252,9 +192,7 @@ elf64_x86_64_info_to_howto (abfd, cache_ptr, dst)
/* Support for core dump NOTE sections. */
static bfd_boolean
elf64_x86_64_grok_prstatus (abfd, note)
bfd *abfd;
Elf_Internal_Note *note;
elf64_x86_64_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
{
int offset;
size_t raw_size;
@ -286,9 +224,7 @@ elf64_x86_64_grok_prstatus (abfd, note)
}
static bfd_boolean
elf64_x86_64_grok_psinfo (abfd, note)
bfd *abfd;
Elf_Internal_Note *note;
elf64_x86_64_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
{
switch (note->descsz)
{
@ -447,10 +383,8 @@ struct elf64_x86_64_link_hash_table
/* Create an entry in an x86-64 ELF linker hash table. */
static struct bfd_hash_entry *
link_hash_newfunc (entry, table, string)
struct bfd_hash_entry *entry;
struct bfd_hash_table *table;
const char *string;
link_hash_newfunc (struct bfd_hash_entry *entry, struct bfd_hash_table *table,
const char *string)
{
/* Allocate the structure if it has not already been allocated by a
subclass. */
@ -479,8 +413,7 @@ link_hash_newfunc (entry, table, string)
/* Create an X86-64 ELF linker hash table. */
static struct bfd_link_hash_table *
elf64_x86_64_link_hash_table_create (abfd)
bfd *abfd;
elf64_x86_64_link_hash_table_create (bfd *abfd)
{
struct elf64_x86_64_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf64_x86_64_link_hash_table);
@ -512,9 +445,7 @@ elf64_x86_64_link_hash_table_create (abfd)
shortcuts to them in our hash table. */
static bfd_boolean
create_got_section (dynobj, info)
bfd *dynobj;
struct bfd_link_info *info;
create_got_section (bfd *dynobj, struct bfd_link_info *info)
{
struct elf64_x86_64_link_hash_table *htab;
@ -543,9 +474,7 @@ create_got_section (dynobj, info)
hash table. */
static bfd_boolean
elf64_x86_64_create_dynamic_sections (dynobj, info)
bfd *dynobj;
struct bfd_link_info *info;
elf64_x86_64_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
{
struct elf64_x86_64_link_hash_table *htab;
@ -572,9 +501,9 @@ elf64_x86_64_create_dynamic_sections (dynobj, info)
/* Copy the extra info we tack onto an elf_link_hash_entry. */
static void
elf64_x86_64_copy_indirect_symbol (bed, dir, ind)
struct elf_backend_data *bed;
struct elf_link_hash_entry *dir, *ind;
elf64_x86_64_copy_indirect_symbol (struct elf_backend_data *bed,
struct elf_link_hash_entry *dir,
struct elf_link_hash_entry *ind)
{
struct elf64_x86_64_link_hash_entry *edir, *eind;
@ -637,8 +566,7 @@ elf64_x86_64_copy_indirect_symbol (bed, dir, ind)
}
static bfd_boolean
elf64_x86_64_mkobject (abfd)
bfd *abfd;
elf64_x86_64_mkobject (bfd *abfd)
{
bfd_size_type amt = sizeof (struct elf64_x86_64_obj_tdata);
abfd->tdata.any = bfd_zalloc (abfd, amt);
@ -648,8 +576,7 @@ elf64_x86_64_mkobject (abfd)
}
static bfd_boolean
elf64_x86_64_elf_object_p (abfd)
bfd *abfd;
elf64_x86_64_elf_object_p (bfd *abfd)
{
/* Allocate our special target data. */
struct elf64_x86_64_obj_tdata *new_tdata;
@ -665,10 +592,7 @@ elf64_x86_64_elf_object_p (abfd)
}
static int
elf64_x86_64_tls_transition (info, r_type, is_local)
struct bfd_link_info *info;
int r_type;
int is_local;
elf64_x86_64_tls_transition (struct bfd_link_info *info, int r_type, int is_local)
{
if (info->shared)
return r_type;
@ -692,11 +616,8 @@ elf64_x86_64_tls_transition (info, r_type, is_local)
linkage table, and dynamic reloc sections. */
static bfd_boolean
elf64_x86_64_check_relocs (abfd, info, sec, relocs)
bfd *abfd;
struct bfd_link_info *info;
asection *sec;
const Elf_Internal_Rela *relocs;
elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
const Elf_Internal_Rela *relocs)
{
struct elf64_x86_64_link_hash_table *htab;
Elf_Internal_Shdr *symtab_hdr;
@ -1060,12 +981,11 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
relocation. */
static asection *
elf64_x86_64_gc_mark_hook (sec, info, rel, h, sym)
asection *sec;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
Elf_Internal_Rela *rel;
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
elf64_x86_64_gc_mark_hook (asection *sec,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
Elf_Internal_Rela *rel,
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym)
{
if (h != NULL)
{
@ -1099,11 +1019,8 @@ elf64_x86_64_gc_mark_hook (sec, info, rel, h, sym)
/* Update the got entry reference counts for the section being removed. */
static bfd_boolean
elf64_x86_64_gc_sweep_hook (abfd, info, sec, relocs)
bfd *abfd;
struct bfd_link_info *info;
asection *sec;
const Elf_Internal_Rela *relocs;
elf64_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info,
asection *sec, const Elf_Internal_Rela *relocs)
{
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes;
@ -1202,9 +1119,8 @@ elf64_x86_64_gc_sweep_hook (abfd, info, sec, relocs)
understand. */
static bfd_boolean
elf64_x86_64_adjust_dynamic_symbol (info, h)
struct bfd_link_info *info;
struct elf_link_hash_entry *h;
elf64_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
struct elf64_x86_64_link_hash_table *htab;
asection *s;
@ -1217,11 +1133,9 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
|| (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
{
if (h->plt.refcount <= 0
|| (! info->shared
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
&& h->root.type != bfd_link_hash_undefweak
&& h->root.type != bfd_link_hash_undefined))
|| SYMBOL_CALLS_LOCAL (info, h)
|| (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
&& h->root.type == bfd_link_hash_undefweak))
{
/* This case can occur if we saw a PLT32 reloc in an input
file, but the symbol was never referred to by a dynamic
@ -1355,9 +1269,9 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
will be called from elflink.h. If elflink.h doesn't call our
finish_dynamic_symbol routine, we'll need to do something about
initializing any .plt and .got entries in elf64_x86_64_relocate_section. */
#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
((DYN) \
&& ((INFO)->shared \
&& ((SHARED) \
|| ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
&& ((H)->dynindx != -1 \
|| ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
@ -1366,9 +1280,7 @@ elf64_x86_64_adjust_dynamic_symbol (info, h)
dynamic relocs. */
static bfd_boolean
allocate_dynrelocs (h, inf)
struct elf_link_hash_entry *h;
PTR inf;
allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
struct bfd_link_info *info;
struct elf64_x86_64_link_hash_table *htab;
@ -1385,9 +1297,7 @@ allocate_dynrelocs (h, inf)
htab = elf64_x86_64_hash_table (info);
if (htab->elf.dynamic_sections_created
&& h->plt.refcount > 0
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak))
&& h->plt.refcount > 0)
{
/* Make sure this symbol is output as a dynamic symbol.
Undefined weak syms won't yet be marked as dynamic. */
@ -1398,7 +1308,8 @@ allocate_dynrelocs (h, inf)
return FALSE;
}
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
if (info->shared
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
{
asection *s = htab->splt;
@ -1482,7 +1393,8 @@ allocate_dynrelocs (h, inf)
htab->srelgot->_raw_size += 2 * sizeof (Elf64_External_Rela);
else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak)
&& WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
&& (info->shared
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
htab->srelgot->_raw_size += sizeof (Elf64_External_Rela);
}
else
@ -1500,9 +1412,13 @@ allocate_dynrelocs (h, inf)
if (info->shared)
{
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
&& ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
|| info->symbolic))
/* Relocs that use pc_count are those that appear on a call
insn, or certain REL relocs that can generated via assembly.
We want calls to protected symbols to resolve directly to the
function rather than going via the plt. If people want
function pointer comparisons to work as expected then they
should avoid writing weird assembly. */
if (SYMBOL_CALLS_LOCAL (info, h))
{
struct elf64_x86_64_dyn_relocs **pp;
@ -1569,9 +1485,7 @@ allocate_dynrelocs (h, inf)
/* Find any dynamic relocs that apply to read-only sections. */
static bfd_boolean
readonly_dynrelocs (h, inf)
struct elf_link_hash_entry *h;
PTR inf;
readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
struct elf64_x86_64_link_hash_entry *eh;
struct elf64_x86_64_dyn_relocs *p;
@ -1600,9 +1514,8 @@ readonly_dynrelocs (h, inf)
/* Set the sizes of the dynamic sections. */
static bfd_boolean
elf64_x86_64_size_dynamic_sections (output_bfd, info)
bfd *output_bfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info)
{
struct elf64_x86_64_link_hash_table *htab;
bfd *dynobj;
@ -1824,8 +1737,7 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info)
This is PT_TLS segment p_vaddr. */
static bfd_vma
dtpoff_base (info)
struct bfd_link_info *info;
dtpoff_base (struct bfd_link_info *info)
{
/* If tls_segment is NULL, we should have signalled an error already. */
if (elf_hash_table (info)->tls_segment == NULL)
@ -1837,9 +1749,7 @@ dtpoff_base (info)
if STT_TLS virtual address is ADDRESS. */
static bfd_vma
tpoff (info, address)
struct bfd_link_info *info;
bfd_vma address;
tpoff (struct bfd_link_info *info, bfd_vma address)
{
struct elf_link_tls_segment *tls_segment
= elf_hash_table (info)->tls_segment;
@ -1854,16 +1764,11 @@ tpoff (info, address)
/* Relocate an x86_64 ELF section. */
static bfd_boolean
elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
contents, relocs, local_syms, local_sections)
bfd *output_bfd;
struct bfd_link_info *info;
bfd *input_bfd;
asection *input_section;
bfd_byte *contents;
Elf_Internal_Rela *relocs;
Elf_Internal_Sym *local_syms;
asection **local_sections;
elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
bfd *input_bfd, asection *input_section,
bfd_byte *contents, Elf_Internal_Rela *relocs,
Elf_Internal_Sym *local_syms,
asection **local_sections)
{
struct elf64_x86_64_link_hash_table *htab;
Elf_Internal_Shdr *symtab_hdr;
@ -1981,12 +1886,9 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
off = h->got.offset;
dyn = htab->elf.dynamic_sections_created;
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
|| (info->shared
&& (info->symbolic
|| h->dynindx == -1
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
&& SYMBOL_REFERENCES_LOCAL (info, h))
|| (ELF_ST_VISIBILITY (h->other)
&& h->root.type == bfd_link_hash_undefweak))
{
@ -2114,10 +2016,7 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
&& r_type != R_X86_64_PC16
&& r_type != R_X86_64_PC32)
|| (h != NULL
&& h->dynindx != -1
&& (! info->symbolic
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0))))
&& !SYMBOL_CALLS_LOCAL (info, h))))
|| (ELIMINATE_COPY_RELOCS
&& !info->shared
&& h != NULL
@ -2604,11 +2503,10 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
dynamic sections here. */
static bfd_boolean
elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
bfd *output_bfd;
struct bfd_link_info *info;
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
elf64_x86_64_finish_dynamic_symbol (bfd *output_bfd,
struct bfd_link_info *info,
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym)
{
struct elf64_x86_64_link_hash_table *htab;
@ -2714,10 +2612,7 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
The entry in the global offset table will already have been
initialized in the relocate_section function. */
if (info->shared
&& (info->symbolic
|| h->dynindx == -1
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
&& SYMBOL_REFERENCES_LOCAL (info, h))
{
BFD_ASSERT((h->got.offset & 1) != 0);
rela.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
@ -2774,8 +2669,7 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym)
dynamic linker, before writing them out. */
static enum elf_reloc_type_class
elf64_x86_64_reloc_type_class (rela)
const Elf_Internal_Rela *rela;
elf64_x86_64_reloc_type_class (const Elf_Internal_Rela *rela)
{
switch ((int) ELF64_R_TYPE (rela->r_info))
{
@ -2793,9 +2687,7 @@ elf64_x86_64_reloc_type_class (rela)
/* Finish up the dynamic sections. */
static bfd_boolean
elf64_x86_64_finish_dynamic_sections (output_bfd, info)
bfd *output_bfd;
struct bfd_link_info *info;
elf64_x86_64_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
{
struct elf64_x86_64_link_hash_table *htab;
bfd *dynobj;