summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2002-10-11 08:33:11 +0000
committerAlan Modra <amodra@bigpond.net.au>2002-10-11 08:33:11 +0000
commit2a14282fa1fdce81d949dd8ee86b54898073ec0a (patch)
tree507ec00957a8442f4809895bba63fc039c21f393
parent51d4a85da5d64b4603e8cd72a6a513ad5294738b (diff)
downloadbinutils-redhat-2a14282fa1fdce81d949dd8ee86b54898073ec0a.tar.gz
Fix numerous occurrences of
warning: dereferencing type-punned pointer will break strict-aliasing rules
-rw-r--r--bfd/ChangeLog27
-rw-r--r--bfd/coff-arm.c16
-rw-r--r--bfd/ecoff.c12
-rw-r--r--bfd/elf32-arm.h17
-rw-r--r--bfd/elf32-m32r.c10
-rw-r--r--bfd/elf32-sh.c9
-rw-r--r--bfd/elf32-sh64.c7
-rw-r--r--bfd/elf64-alpha.c13
-rw-r--r--bfd/elf64-ppc.c6
-rw-r--r--bfd/elf64-sh64.c17
-rw-r--r--bfd/elflink.c50
-rw-r--r--bfd/elflink.h25
-rw-r--r--bfd/elfxx-ia64.c8
-rw-r--r--bfd/elfxx-mips.c84
-rw-r--r--bfd/linker.c7
-rw-r--r--bfd/xcofflink.c6
16 files changed, 179 insertions, 135 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index cceffd70c3..3a59982aba 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,32 @@
2002-10-11 Alan Modra <amodra@bigpond.net.au>
+ * coff-arm.c (record_arm_to_thumb_glue): Avoid type-punned pointers.
+ (record_thumb_to_arm_glue): Likewise.
+ * ecoff.c (ecoff_link_add_externals): Likewise.
+ * elf32-arm.h (record_arm_to_thumb_glue): Likewise.
+ (record_thumb_to_arm_glue): Likewise.
+ * elf32-m32r.c (m32r_elf_add_symbol_hook): Likewise.
+ * elf32-sh.c (sh_elf_create_dynamic_sections): Likewise.
+ * elf32-sh64.c (sh64_elf_add_symbol_hook): Likewise.
+ * elf64-alpha.c (elf64_alpha_create_dynamic_sections): Likewise.
+ * elf64-ppc.c (func_desc_adjust): Likewise.
+ * elf64-sh64.c (sh64_elf64_add_symbol_hook): Likewise.
+ (sh64_elf64_create_dynamic_sections): Likewise.
+ * elflink.c (_bfd_elf_create_got_section): Likewise.
+ (_bfd_elf_create_dynamic_sections): Likewise.
+ (_bfd_elf_create_linker_section): Likewise.
+ * elflink.h (elf_add_default_symbol): Likewise.
+ (elf_link_create_dynamic_sections): Likewise.
+ (NAME(bfd_elf,size_dynamic_sections)): Likewise.
+ * elfxx-ia64.c (elfNN_ia64_aix_add_symbol_hook): Likewise.
+ * elfxx-mips.c (mips_elf_create_got_section): Likewise.
+ (_bfd_mips_elf_add_symbol_hook): Likewise.
+ (_bfd_mips_elf_create_dynamic_sections): Likewise.
+ * linker.c (generic_link_add_symbol_list): Likewise.
+ * xcofflink.c (xcoff_link_add_symbols): Likewise.
+
+ * elfxx-ia64.c (oor_brl, oor_ip): Conditionally define.
+
* elf64-ppc.c (edit_opd): Only zero opd syms when function is
completely removed.
diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c
index 5e7f907a95..25256a8b7b 100644
--- a/bfd/coff-arm.c
+++ b/bfd/coff-arm.c
@@ -1881,6 +1881,7 @@ record_arm_to_thumb_glue (info, h)
register asection * s;
char * tmp_name;
struct coff_link_hash_entry * myh;
+ struct bfd_link_hash_entry * bh;
struct coff_arm_link_hash_table * globals;
bfd_vma val;
bfd_size_type amt;
@@ -1915,10 +1916,10 @@ record_arm_to_thumb_glue (info, h)
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,
- BSF_GLOBAL, s, val, NULL, true, false,
- (struct bfd_link_hash_entry **) & myh);
+ BSF_GLOBAL, s, val, NULL, true, false, &bh);
free (tmp_name);
@@ -1937,6 +1938,7 @@ record_thumb_to_arm_glue (info, h)
register asection * s;
char * tmp_name;
struct coff_link_hash_entry * myh;
+ struct bfd_link_hash_entry * bh;
struct coff_arm_link_hash_table * globals;
bfd_vma val;
bfd_size_type amt;
@@ -1967,12 +1969,13 @@ record_thumb_to_arm_glue (info, h)
return; /* we've already seen this guy */
}
+ bh = NULL;
val = globals->thumb_glue_size + 1;
bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
- BSF_GLOBAL, s, val, NULL, true, false,
- (struct bfd_link_hash_entry **) &myh);
+ BSF_GLOBAL, s, val, NULL, true, false, &bh);
/* If we mark it 'thumb', the disassembler will do a better job. */
+ myh = (struct coff_link_hash_entry *) bh;
myh->class = C_THUMBEXTFUNC;
free (tmp_name);
@@ -1989,11 +1992,10 @@ record_thumb_to_arm_glue (info, h)
sprintf (tmp_name, globals->support_old_code ? BACK_FROM_ARM : CHANGE_TO_ARM, name);
- myh = NULL;
+ bh = NULL;
val = globals->thumb_glue_size + (globals->support_old_code ? 8 : 4);
bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
- BSF_LOCAL, s, val, NULL, true, false,
- (struct bfd_link_hash_entry **) & myh);
+ BSF_LOCAL, s, val, NULL, true, false, &bh);
free (tmp_name);
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 47b6582234..4f129f602f 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -3837,7 +3837,7 @@ ecoff_link_add_externals (abfd, info, external_ext, ssext)
= backend->debug_swap.swap_ext_in;
bfd_size_type external_ext_size = backend->debug_swap.external_ext_size;
unsigned long ext_count;
- struct ecoff_link_hash_entry **sym_hash;
+ struct bfd_link_hash_entry **sym_hash;
char *ext_ptr;
char *ext_end;
bfd_size_type amt;
@@ -3846,10 +3846,10 @@ ecoff_link_add_externals (abfd, info, external_ext, ssext)
amt = ext_count;
amt *= sizeof (struct bfd_link_hash_entry *);
- sym_hash = (struct ecoff_link_hash_entry **) bfd_alloc (abfd, amt);
+ sym_hash = (struct bfd_link_hash_entry **) bfd_alloc (abfd, amt);
if (!sym_hash)
return false;
- ecoff_data (abfd)->sym_hashes = sym_hash;
+ ecoff_data (abfd)->sym_hashes = (struct ecoff_link_hash_entry **) sym_hash;
ext_ptr = (char *) external_ext;
ext_end = ext_ptr + ext_count * external_ext_size;
@@ -3980,15 +3980,13 @@ ecoff_link_add_externals (abfd, info, external_ext, ssext)
name = ssext + esym.asym.iss;
- h = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, name,
(flagword) (esym.weakext ? BSF_WEAK : BSF_GLOBAL),
- section, value, (const char *) NULL, true, true,
- (struct bfd_link_hash_entry **) &h)))
+ section, value, (const char *) NULL, true, true, sym_hash)))
return false;
- *sym_hash = h;
+ h = (struct ecoff_link_hash_entry *) *sym_hash;
/* If we are building an ECOFF hash table, save the external
symbol information. */
diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h
index 2d59601fd0..029bbe2513 100644
--- a/bfd/elf32-arm.h
+++ b/bfd/elf32-arm.h
@@ -427,6 +427,7 @@ record_arm_to_thumb_glue (link_info, h)
asection * s;
char * tmp_name;
struct elf_link_hash_entry * myh;
+ struct bfd_link_hash_entry * bh;
struct elf32_arm_link_hash_table * globals;
bfd_vma val;
@@ -460,11 +461,11 @@ record_arm_to_thumb_glue (link_info, h)
/* The only trick here is using hash_table->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_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner,
tmp_name, BSF_GLOBAL, s, val,
- NULL, true, false,
- (struct bfd_link_hash_entry **) &myh);
+ NULL, true, false, &bh);
free (tmp_name);
@@ -482,6 +483,7 @@ record_thumb_to_arm_glue (link_info, h)
asection *s;
char *tmp_name;
struct elf_link_hash_entry *myh;
+ struct bfd_link_hash_entry *bh;
struct elf32_arm_link_hash_table *hash_table;
char bind;
bfd_vma val;
@@ -513,13 +515,14 @@ record_thumb_to_arm_glue (link_info, h)
return;
}
+ bh = NULL;
val = hash_table->thumb_glue_size + 1;
_bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
tmp_name, BSF_GLOBAL, s, val,
- NULL, true, false,
- (struct bfd_link_hash_entry **) &myh);
+ NULL, true, false, &bh);
/* If we mark it 'Thumb', the disassembler will do a better job. */
+ myh = (struct elf_link_hash_entry *) bh;
bind = ELF_ST_BIND (myh->type);
myh->type = ELF_ST_INFO (bind, STT_ARM_TFUNC);
@@ -536,13 +539,11 @@ record_thumb_to_arm_glue (link_info, h)
sprintf (tmp_name, CHANGE_TO_ARM, name);
- myh = NULL;
-
+ bh = NULL;
val = hash_table->thumb_glue_size + 4,
_bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
tmp_name, BSF_LOCAL, s, val,
- NULL, true, false,
- (struct bfd_link_hash_entry **) &myh);
+ NULL, true, false, &bh);
free (tmp_name);
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index a2e9e0baaf..8adb1e2f61 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -847,6 +847,7 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
section already exists a new one is created that follows it which
screws of _SDA_BASE_ address calcs because output_offset != 0. */
struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
asection *s = bfd_get_section_by_name (abfd, ".sdata");
/* The following code was cobbled from elf32-ppc.c and elflink.c. */
@@ -863,10 +864,10 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
bfd_set_section_alignment (abfd, s, 2);
}
- h = (struct elf_link_hash_entry *)
- bfd_link_hash_lookup (info->hash, "_SDA_BASE_", false, false, false);
+ bh = bfd_link_hash_lookup (info->hash, "_SDA_BASE_",
+ false, false, false);
- if ((h == NULL || h->root.type == bfd_link_hash_undefined)
+ if ((bh == NULL || bh->type == bfd_link_hash_undefined)
&& !(_bfd_generic_link_add_one_symbol (info,
abfd,
"_SDA_BASE_",
@@ -876,8 +877,9 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
(const char *) NULL,
false,
get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ &bh)))
return false;
+ h = (struct elf_link_hash_entry *) bh;
h->type = STT_OBJECT;
}
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 90edf3f8f5..5fe0f585a9 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -3582,13 +3582,16 @@ sh_elf_create_dynamic_sections (abfd, info)
{
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
.plt section. */
- struct elf_link_hash_entry *h = NULL;
+ struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh = NULL;
+
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
(bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ get_elf_backend_data (abfd)->collect, &bh)))
return false;
+
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c
index 7a38fb2241..844a6a43e2 100644
--- a/bfd/elf32-sh64.c
+++ b/bfd/elf32-sh64.c
@@ -411,16 +411,19 @@ sh64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
if (h == NULL)
{
/* No previous datalabel symbol. Make one. */
+ struct bfd_link_hash_entry *bh = NULL;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
if (! _bfd_generic_link_add_one_symbol (info, abfd, dl_name,
flags, *secp, *valp,
*namep, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h))
+ bed->collect, &bh))
{
free (dl_name);
return false;
}
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
h->type = STT_DATALABEL;
}
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index e1d095d523..5973017360 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -2480,6 +2480,7 @@ elf64_alpha_create_dynamic_sections (abfd, info)
{
asection *s;
struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
/* We need to create .plt, .rela.plt, .got, and .rela.got sections. */
@@ -2495,13 +2496,13 @@ elf64_alpha_create_dynamic_sections (abfd, info)
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
.plt section. */
- h = NULL;
+ bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
(bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ get_elf_backend_data (abfd)->collect, &bh)))
return false;
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@@ -2539,13 +2540,13 @@ elf64_alpha_create_dynamic_sections (abfd, info)
dynobj's .got section. We don't do this in the linker script
because we don't want to define the symbol if we are not creating
a global offset table. */
- h = NULL;
+ bh = NULL;
if (!(_bfd_generic_link_add_one_symbol
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL,
alpha_elf_tdata(abfd)->got, (bfd_vma) 0, (const char *) NULL,
- false, get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ false, get_elf_backend_data (abfd)->collect, &bh)))
return false;
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 909314f082..7c6ec10b27 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3166,6 +3166,7 @@ func_desc_adjust (h, inf)
{
bfd *abfd;
asymbol *newsym;
+ struct bfd_link_hash_entry *bh;
abfd = h->root.u.undef.abfd;
newsym = bfd_make_empty_symbol (abfd);
@@ -3176,13 +3177,14 @@ func_desc_adjust (h, inf)
if (h->root.type == bfd_link_hash_undefweak)
newsym->flags |= BSF_WEAK;
+ bh = &fdh->root;
if ( !(_bfd_generic_link_add_one_symbol
(info, abfd, newsym->name, newsym->flags,
- newsym->section, newsym->value, NULL, false, false,
- (struct bfd_link_hash_entry **) &fdh)))
+ newsym->section, newsym->value, NULL, false, false, &bh)))
{
return false;
}
+ fdh = (struct elf_link_hash_entry *) bh;
fdh->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
}
diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c
index 7a114c6974..67a04ad67c 100644
--- a/bfd/elf64-sh64.c
+++ b/bfd/elf64-sh64.c
@@ -2915,16 +2915,19 @@ sh64_elf64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
if (h == NULL)
{
/* No previous datalabel symbol. Make one. */
+ struct bfd_link_hash_entry *bh = NULL;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
if (! _bfd_generic_link_add_one_symbol (info, abfd, dl_name,
flags, *secp, *valp,
*namep, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h))
+ bed->collect, &bh))
{
free (dl_name);
return false;
}
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
h->type = STT_DATALABEL;
}
@@ -3287,13 +3290,15 @@ sh64_elf64_create_dynamic_sections (abfd, info)
{
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
.plt section. */
- struct elf_link_hash_entry *h = NULL;
+ struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh = NULL;
+
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
- (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ (bfd_vma) 0, (const char *) NULL, false, bed->collect, &bh)))
return false;
+
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f8cc645ad7..d6da588a15 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -33,6 +33,7 @@ _bfd_elf_create_got_section (abfd, info)
flagword flags;
register asection *s;
struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
struct elf_backend_data *bed = get_elf_backend_data (abfd);
int ptralign;
@@ -79,12 +80,13 @@ _bfd_elf_create_got_section (abfd, info)
(or .got.plt) section. We don't do this in the linker script
because we don't want to define the symbol if we are not creating
a global offset table. */
- h = NULL;
+ bh = NULL;
if (!(_bfd_generic_link_add_one_symbol
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
bed->got_symbol_offset, (const char *) NULL, false,
- bed->collect, (struct bfd_link_hash_entry **) &h)))
+ bed->collect, &bh)))
return false;
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@@ -151,13 +153,15 @@ _bfd_elf_create_dynamic_sections (abfd, info)
{
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
.plt section. */
- struct elf_link_hash_entry *h = NULL;
+ struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh = NULL;
+
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
(bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ get_elf_backend_data (abfd)->collect, &bh)))
return false;
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@@ -546,29 +550,27 @@ _bfd_elf_create_linker_section (abfd, info, which, defaults)
if (lsect->sym_name)
{
- struct elf_link_hash_entry *h = NULL;
+ struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
+
#ifdef DEBUG
fprintf (stderr, "Adding %s to section %s\n",
lsect->sym_name,
lsect->name);
#endif
- h = (struct elf_link_hash_entry *)
- bfd_link_hash_lookup (info->hash, lsect->sym_name, false, false, false);
-
- if ((h == NULL || h->root.type == bfd_link_hash_undefined)
- && !(_bfd_generic_link_add_one_symbol (info,
- abfd,
- lsect->sym_name,
- BSF_GLOBAL,
- s,
- ((lsect->hole_size)
- ? s->_raw_size - lsect->hole_size + lsect->sym_offset
- : lsect->sym_offset),
- (const char *) NULL,
- false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return (elf_linker_section_t *)0;
+ bh = bfd_link_hash_lookup (info->hash, lsect->sym_name,
+ false, false, false);
+
+ if ((bh == NULL || bh->type == bfd_link_hash_undefined)
+ && !(_bfd_generic_link_add_one_symbol
+ (info, abfd, lsect->sym_name, BSF_GLOBAL, s,
+ (lsect->hole_size
+ ? s->_raw_size - lsect->hole_size + lsect->sym_offset
+ : lsect->sym_offset),
+ (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect, &bh)))
+ return (elf_linker_section_t *) 0;
+ h = (struct elf_link_hash_entry *) bh;
if ((defaults->which != LINKER_SECTION_SDATA)
&& (defaults->which != LINKER_SECTION_SDATA2))
@@ -579,7 +581,7 @@ _bfd_elf_create_linker_section (abfd, info, which, defaults)
if (info->shared
&& ! _bfd_elf_link_record_dynamic_symbol (info, h))
- return (elf_linker_section_t *)0;
+ return (elf_linker_section_t *) 0;
}
}
diff --git a/bfd/elflink.h b/bfd/elflink.h
index da8ff4773a..23ea241fbd 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -921,6 +921,7 @@ elf_add_default_symbol (abfd, info, h, name, sym, psec, value,
boolean size_change_ok;
char *shortname;
struct elf_link_hash_entry *hi;
+ struct bfd_link_hash_entry *bh;
struct elf_backend_data *bed;
boolean collect;
boolean dynamic;
@@ -979,11 +980,12 @@ elf_add_default_symbol (abfd, info, h, name, sym, psec, value,
if (! override)
{
+ bh = &hi->root;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr,
- (bfd_vma) 0, name, false, collect,
- (struct bfd_link_hash_entry **) &hi)))
+ (bfd_vma) 0, name, false, collect, &bh)))
return false;
+ hi = (struct elf_link_hash_entry *) bh;
}
else
{
@@ -1098,11 +1100,12 @@ elf_add_default_symbol (abfd, info, h, name, sym, psec, value,
}
else
{
+ bh = &hi->root;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, shortname, BSF_INDIRECT,
- bfd_ind_section_ptr, (bfd_vma) 0, name, false,
- collect, (struct bfd_link_hash_entry **) &hi)))
+ bfd_ind_section_ptr, (bfd_vma) 0, name, false, collect, &bh)))
return false;
+ hi = (struct elf_link_hash_entry *) bh;
/* If there is a duplicate definition somewhere, then HI may not
point to an indirect symbol. We will have reported an error
@@ -2292,6 +2295,7 @@ elf_link_create_dynamic_sections (abfd, info)
flagword flags;
register asection *s;
struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
struct elf_backend_data *bed;
if (! is_elf_hash_table (info))
@@ -2384,12 +2388,12 @@ elf_link_create_dynamic_sections (abfd, info)
creating a .dynamic section. We don't want to define it if there
is no .dynamic section, since on some ELF platforms the start up
code examines it to decide how to initialize the process. */
- h = NULL;
+ bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_DYNAMIC", BSF_GLOBAL, s, (bfd_vma) 0,
- (const char *) NULL, false, get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ (const char *) 0, false, get_elf_backend_data (abfd)->collect, &bh)))
return false;
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@@ -3326,19 +3330,20 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
unsigned int cdeps;
struct bfd_elf_version_deps *n;
struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
cdeps = 0;
for (n = t->deps; n != NULL; n = n->next)
++cdeps;
/* Add a symbol representing this version. */
- h = NULL;
+ bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, dynobj, t->name, BSF_GLOBAL, bfd_abs_section_ptr,
(bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (dynobj)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ get_elf_backend_data (dynobj)->collect, &bh)))
return false;
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &= ~ ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index 2a29347365..5da8e43b7f 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -647,13 +647,14 @@ static const bfd_byte plt_full_entry[PLT_FULL_ENTRY_SIZE] =
not support brl, and so it gets emulated by the kernel. */
#undef USE_BRL
+#ifdef USE_BRL
static const bfd_byte oor_brl[16] =
{
0x05, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* brl.sptk.few tgt;; */
0x00, 0x00, 0x00, 0xc0
};
-
+#else
static const bfd_byte oor_ip[48] =
{
0x04, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0 */
@@ -666,6 +667,7 @@ static const bfd_byte oor_ip[48] =
0x60, 0x80, 0x04, 0x80, 0x03, 0x00, /* mov b6=r16 */
0x60, 0x00, 0x80, 0x00 /* br b6;; */
};
+#endif
/* These functions do relaxation for IA-64 ELF.
@@ -1282,6 +1284,7 @@ elfNN_ia64_aix_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
{
struct elf_backend_data *bed;
struct elfNN_ia64_link_hash_table *ia64_info;
+ struct bfd_link_hash_entry *bh = NULL;
bed = get_elf_backend_data (abfd);
ia64_info = elfNN_ia64_hash_table (info);
@@ -1290,9 +1293,10 @@ elfNN_ia64_aix_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
(info, abfd, *namep, BSF_GLOBAL,
bfd_get_section_by_name (abfd, ".bss"),
bed->got_symbol_offset, (const char *) NULL, false,
- bed->collect, (struct bfd_link_hash_entry **) &h)))
+ bed->collect, &bh)))
return false;
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 359587dfd9..9584bde083 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -1901,6 +1901,7 @@ mips_elf_create_got_section (abfd, info)
flagword flags;
register asection *s;
struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
struct mips_got_info *g;
bfd_size_type amt;
@@ -1920,13 +1921,14 @@ mips_elf_create_got_section (abfd, info)
/* Define the symbol _GLOBAL_OFFSET_TABLE_. We don't do this in the
linker script because we don't want to define the symbol if we
are not creating a global offset table. */
- h = NULL;
+ bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
(bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ get_elf_backend_data (abfd)->collect, &bh)))
return false;
+
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@@ -3829,15 +3831,17 @@ _bfd_mips_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
&& strcmp (*namep, "__rld_obj_head") == 0)
{
struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
/* Mark __rld_obj_head as dynamic. */
- h = NULL;
+ bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, *namep, BSF_GLOBAL, *secp,
(bfd_vma) *valp, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ get_elf_backend_data (abfd)->collect, &bh)))
return false;
+
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@@ -3893,6 +3897,7 @@ _bfd_mips_elf_create_dynamic_sections (abfd, info)
struct bfd_link_info *info;
{
struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
flagword flags;
register asection *s;
const char * const *namep;
@@ -3951,13 +3956,14 @@ _bfd_mips_elf_create_dynamic_sections (abfd, info)
{
for (namep = mips_elf_dynsym_rtproc_names; *namep != NULL; namep++)
{
- h = NULL;
+ bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, *namep, BSF_GLOBAL, bfd_und_section_ptr,
(bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
+ get_elf_backend_data (abfd)->collect, &bh)))
return false;
+
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_SECTION;
@@ -3993,26 +3999,17 @@ _bfd_mips_elf_create_dynamic_sections (abfd, info)
if (!info->shared)
{
- h = NULL;
- if (SGI_COMPAT (abfd))
- {
- if (!(_bfd_generic_link_add_one_symbol
- (info, abfd, "_DYNAMIC_LINK", BSF_GLOBAL, bfd_abs_section_ptr,
- (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- }
- else
- {
- /* For normal mips it is _DYNAMIC_LINKING. */
- if (!(_bfd_generic_link_add_one_symbol
- (info, abfd, "_DYNAMIC_LINKING", BSF_GLOBAL,
- bfd_abs_section_ptr, (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- }
+ const char *name;
+
+ name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING";
+ bh = NULL;
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect, &bh)))
+ return false;
+
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_SECTION;
@@ -4029,26 +4026,15 @@ _bfd_mips_elf_create_dynamic_sections (abfd, info)
s = bfd_get_section_by_name (abfd, ".rld_map");
BFD_ASSERT (s != NULL);
- h = NULL;
- if (SGI_COMPAT (abfd))
- {
- if (!(_bfd_generic_link_add_one_symbol
- (info, abfd, "__rld_map", BSF_GLOBAL, s,
- (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- }
- else
- {
- /* For normal mips the symbol is __RLD_MAP. */
- if (!(_bfd_generic_link_add_one_symbol
- (info, abfd, "__RLD_MAP", BSF_GLOBAL, s,
- (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- }
+ name = SGI_COMPAT (abfd) ? "__rld_map" : "__RLD_MAP";
+ bh = NULL;
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, name, BSF_GLOBAL, s,
+ (bfd_vma) 0, (const char *) NULL, false,
+ get_elf_backend_data (abfd)->collect, &bh)))
+ return false;
+
+ h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
diff --git a/bfd/linker.c b/bfd/linker.c
index 242f8bd762..e44ac6c6c9 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1305,6 +1305,7 @@ generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
const char *name;
const char *string;
struct generic_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
name = bfd_asymbol_name (p);
if (((p->flags & BSF_INDIRECT) != 0
@@ -1326,12 +1327,12 @@ generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
else
string = NULL;
- h = NULL;
+ bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, name, p->flags, bfd_get_section (p),
- p->value, string, false, collect,
- (struct bfd_link_hash_entry **) &h)))
+ p->value, string, false, collect, &bh)))
return false;
+ h = (struct generic_link_hash_entry *) bh;
/* If this is a constructor symbol, and the linker didn't do
anything with it, then we want to just pass the symbol
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index a869d7d3d6..e4e4755cdd 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -1986,6 +1986,7 @@ xcoff_link_add_symbols (abfd, info)
&& h->descriptor == NULL)
{
struct xcoff_link_hash_entry *hds;
+ struct bfd_link_hash_entry *bh;
hds = xcoff_link_hash_lookup (xcoff_hash_table (info),
h->root.root.string + 1,
@@ -1994,13 +1995,14 @@ xcoff_link_add_symbols (abfd, info)
goto error_return;
if (hds->root.type == bfd_link_hash_new)
{
+ bh = &hds->root;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, hds->root.root.string,
(flagword) 0, bfd_und_section_ptr,
(bfd_vma) 0, (const char *) NULL, false,
- true,
- (struct bfd_link_hash_entry **) &hds)))
+ true, &bh)))
goto error_return;
+ hds = (struct xcoff_link_hash_entry *) bh;
}
hds->flags |= XCOFF_DESCRIPTOR;
BFD_ASSERT ((hds->flags & XCOFF_CALLED) == 0