/* SEC_MERGE support.
- Copyright 2001, 2002 Free Software Foundation, Inc.
+ Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
Written by Jakub Jelinek <jakub@redhat.com>.
This file is part of BFD, the Binary File Descriptor library.
/* The corresponding section. */
asection *sec;
/* Pointer to merge_info pointing to us. */
- PTR *psecinfo;
+ void **psecinfo;
/* A hash table used to hold section content. */
struct sec_merge_hash *htab;
/* First string in this section. */
unsigned char contents[1];
};
-static struct bfd_hash_entry *sec_merge_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct sec_merge_hash_entry *sec_merge_hash_lookup
- PARAMS ((struct sec_merge_hash *, const char *, unsigned int, bfd_boolean));
-static struct sec_merge_hash *sec_merge_init
- PARAMS ((unsigned int, bfd_boolean));
-static struct sec_merge_hash_entry *sec_merge_add
- PARAMS ((struct sec_merge_hash *, const char *, unsigned int,
- struct sec_merge_sec_info *));
-static bfd_boolean sec_merge_emit
- PARAMS ((bfd *, struct sec_merge_hash_entry *));
-static int cmplengthentry
- PARAMS ((const PTR, const PTR));
-static int last4_eq
- PARAMS ((const PTR, const PTR));
-static int last_eq
- PARAMS ((const PTR, const PTR));
-static bfd_boolean record_section
- PARAMS ((struct sec_merge_info *, struct sec_merge_sec_info *));
-static void merge_strings
- PARAMS ((struct sec_merge_info *));
/* Routine to create an entry in a section merge hashtab. */
static struct bfd_hash_entry *
-sec_merge_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
+sec_merge_hash_newfunc (struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table, const char *string)
{
struct sec_merge_hash_entry *ret = (struct sec_merge_hash_entry *) entry;
/* Look up an entry in a section merge hash table. */
static struct sec_merge_hash_entry *
-sec_merge_hash_lookup (table, string, alignment, create)
- struct sec_merge_hash *table;
- const char *string;
- unsigned int alignment;
- bfd_boolean create;
+sec_merge_hash_lookup (struct sec_merge_hash *table, const char *string,
+ unsigned int alignment, bfd_boolean create)
{
register const unsigned char *s;
register unsigned long hash;
/* Create a new hash table. */
static struct sec_merge_hash *
-sec_merge_init (entsize, strings)
- unsigned int entsize;
- bfd_boolean strings;
+sec_merge_init (unsigned int entsize, bfd_boolean strings)
{
struct sec_merge_hash *table;
bfd_size_type amt = sizeof (struct sec_merge_hash);
already present. */
static struct sec_merge_hash_entry *
-sec_merge_add (tab, str, alignment, secinfo)
- struct sec_merge_hash *tab;
- const char *str;
- unsigned int alignment;
- struct sec_merge_sec_info *secinfo;
+sec_merge_add (struct sec_merge_hash *tab, const char *str,
+ unsigned int alignment, struct sec_merge_sec_info *secinfo)
{
register struct sec_merge_hash_entry *entry;
}
static bfd_boolean
-sec_merge_emit (abfd, entry)
- register bfd *abfd;
- struct sec_merge_hash_entry *entry;
+sec_merge_emit (register bfd *abfd, struct sec_merge_hash_entry *entry)
{
struct sec_merge_sec_info *secinfo = entry->secinfo;
asection *sec = secinfo->sec;
if (len)
{
len = entry->alignment - len;
- if (bfd_bwrite ((PTR) pad, (bfd_size_type) len, abfd) != len)
+ if (bfd_bwrite (pad, (bfd_size_type) len, abfd) != len)
break;
off += len;
}
str = entry->root.string;
len = entry->len;
- if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len)
+ if (bfd_bwrite (str, (bfd_size_type) len, abfd) != len)
break;
off += len;
pass of the linker. */
bfd_boolean
-_bfd_merge_section (abfd, psinfo, sec, psecinfo)
- bfd *abfd;
- PTR *psinfo;
- asection *sec;
- PTR *psecinfo;
+_bfd_merge_section (bfd *abfd, void **psinfo, asection *sec, void **psecinfo)
{
struct sec_merge_info *sinfo;
struct sec_merge_sec_info *secinfo;
goto error_return;
sinfo->next = (struct sec_merge_info *) *psinfo;
sinfo->chain = NULL;
- *psinfo = (PTR) sinfo;
+ *psinfo = sinfo;
sinfo->htab = sec_merge_init (sec->entsize, (sec->flags & SEC_STRINGS));
if (sinfo->htab == NULL)
goto error_return;
/* Compare two sec_merge_hash_entry structures. This is called via qsort. */
static int
-cmplengthentry (a, b)
- const PTR a;
- const PTR b;
+cmplengthentry (const void *a, const void *b)
{
struct sec_merge_hash_entry * A = *(struct sec_merge_hash_entry **) a;
struct sec_merge_hash_entry * B = *(struct sec_merge_hash_entry **) b;
}
static int
-last4_eq (a, b)
- const PTR a;
- const PTR b;
+last4_eq (const void *a, const void *b)
{
struct sec_merge_hash_entry * A = (struct sec_merge_hash_entry *) a;
struct sec_merge_hash_entry * B = (struct sec_merge_hash_entry *) b;
}
static int
-last_eq (a, b)
- const PTR a;
- const PTR b;
+last_eq (const void *a, const void *b)
{
struct sec_merge_hash_entry * A = (struct sec_merge_hash_entry *) a;
struct sec_merge_hash_entry * B = (struct sec_merge_hash_entry *) b;
/* Record one section into the hash table. */
static bfd_boolean
-record_section (sinfo, secinfo)
- struct sec_merge_info *sinfo;
- struct sec_merge_sec_info *secinfo;
+record_section (struct sec_merge_info *sinfo,
+ struct sec_merge_sec_info *secinfo)
{
asection *sec = secinfo->sec;
struct sec_merge_hash_entry *entry;
/* This is a helper function for _bfd_merge_sections. It attempts to
merge strings matching suffixes of longer strings. */
static void
-merge_strings (sinfo)
- struct sec_merge_info *sinfo;
+merge_strings (struct sec_merge_info *sinfo)
{
struct sec_merge_hash_entry **array, **a, **end, *e;
struct sec_merge_sec_info *secinfo;
unsigned int c;
unsigned int i;
const unsigned char *s;
- PTR *p;
+ void **p;
e = *a;
e->u.entsize = sinfo->htab->entsize;
continue;
}
else
- *p = (PTR) e;
+ *p = e;
}
s = (const unsigned char *) (e->root.string + e->len - e->u.entsize);
hash = 0;
e->alignment = 0;
}
else
- *p = (PTR) e;
+ *p = e;
}
alloc_failure:
with _bfd_merge_section. */
bfd_boolean
-_bfd_merge_sections (abfd, xsinfo, remove_hook)
- bfd *abfd ATTRIBUTE_UNUSED;
- PTR xsinfo;
- void (*remove_hook) PARAMS((bfd *, asection *));
+_bfd_merge_sections (bfd *abfd ATTRIBUTE_UNUSED, void *xsinfo,
+ void (*remove_hook) (bfd *, asection *))
{
struct sec_merge_info *sinfo;
/* Finally shrink all input sections which have not made it into
the hash table at all. */
for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next)
- if (secinfo->first == NULL)
+ if (secinfo->first == NULL)
secinfo->sec->_cooked_size = 0;
}
/* Write out the merged section. */
bfd_boolean
-_bfd_write_merged_section (output_bfd, sec, psecinfo)
- bfd *output_bfd;
- asection *sec;
- PTR psecinfo;
+_bfd_write_merged_section (bfd *output_bfd, asection *sec, void *psecinfo)
{
struct sec_merge_sec_info *secinfo;
file_ptr pos;
section and writes the new section back into *PSEC. */
bfd_vma
-_bfd_merged_section_offset (output_bfd, psec, psecinfo, offset, addend)
- bfd *output_bfd ATTRIBUTE_UNUSED;
- asection **psec;
- PTR psecinfo;
- bfd_vma offset, addend;
+_bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
+ void *psecinfo, bfd_vma offset, bfd_vma addend)
{
struct sec_merge_sec_info *secinfo;
struct sec_merge_hash_entry *entry;