From cf5138e388552d449e47b7b32bfed73e2643d951 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 30 Jan 1996 18:18:17 +0000 Subject: [PATCH] * elf32-hppa.c (elf32_hppa_relocate_section): Handle indirect and warning symbols correctly. * elf32-i386.c (elf_i386_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mips.c (mips_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. --- bfd/ChangeLog | 9 ++++++ bfd/elf32-hppa.c | 82 ++++++++++++++++++------------------------------ bfd/elf32-i386.c | 3 ++ bfd/elf32-m68k.c | 3 ++ bfd/elf32-ppc.c | 23 ++++++++------ 5 files changed, 58 insertions(+), 62 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c1734347293..11f7c83e1dc 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,14 @@ Tue Jan 30 12:09:04 1996 Ian Lance Taylor + * elf32-hppa.c (elf32_hppa_relocate_section): Handle indirect and + warning symbols correctly. + * elf32-i386.c (elf_i386_relocate_section): Likewise. + * elf32-m68k.c (elf_m68k_relocate_section): Likewise. + * elf32-mips.c (mips_elf_relocate_section): Likewise. + * elf32-ppc.c (ppc_elf_relocate_section): Likewise. + * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. + * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. + * syms.c (_bfd_stab_section_find_nearest_line): Add casts to avoid warnings. diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 80172d66024..f1becf8a577 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -832,6 +832,9 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, indx = r_symndx - symtab_hdr->sh_info; h = elf_sym_hashes (input_bfd)[indx]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) { @@ -1348,12 +1351,9 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, len = strlen (sym_name) + 1; if (is_local) len += 9; - new_name = malloc (len); + new_name = bfd_malloc (len); if (!new_name) - { - bfd_set_error (bfd_error_no_memory); - return bfd_reloc_notsupported; - } + return bfd_reloc_notsupported; strcpy (new_name, sym_name); /* Local symbols have unique IDs. */ @@ -1395,12 +1395,9 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, len = strlen (new_name); len += 23; - stub_name = malloc (len); + stub_name = bfd_malloc (len); if (!stub_name) - { - bfd_set_error (bfd_error_no_memory); - return bfd_reloc_notsupported; - } + return bfd_reloc_notsupported; elf32_hppa_name_of_stub (caller_args, callee_args, location, value, stub_name); strcat (stub_name, new_name); @@ -1679,12 +1676,9 @@ elf32_hppa_link_output_symbol_hook (abfd, info, name, sym, section) if (ELF_ST_BIND (sym->st_info) == STB_LOCAL) len += 9; - new_name = malloc (len); + new_name = bfd_malloc (len); if (new_name == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; strcpy (new_name, name); if (ELF_ST_BIND (sym->st_info) == STB_LOCAL) @@ -1931,12 +1925,9 @@ elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table, local_syms) return true; } - contents = (bfd_byte *) malloc ((size_t) symextn_sec->_raw_size); + contents = (bfd_byte *) bfd_malloc ((size_t) symextn_sec->_raw_size); if (contents == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; /* How gross. We turn off SEC_HAS_CONTENTS for the input symbol extension sections to keep the generic ELF/BFD code from trying to do anything @@ -1994,10 +1985,9 @@ elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table, local_syms) symtab_hdr->sh_link, local_syms[current_index].st_name); len = strlen (sym_name) + 10; - new_name = malloc (len); + new_name = bfd_malloc (len); if (new_name == NULL) { - bfd_set_error (bfd_error_no_memory); free (contents); return false; } @@ -2519,12 +2509,9 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) /* Create and initialize the stub hash table. */ stub_hash_table = ((struct elf32_hppa_stub_hash_table *) - malloc (sizeof (struct elf32_hppa_stub_hash_table))); + bfd_malloc (sizeof (struct elf32_hppa_stub_hash_table))); if (!stub_hash_table) - { - bfd_set_error (bfd_error_no_memory); - goto error_return; - } + goto error_return; if (!elf32_hppa_stub_hash_table_init (stub_hash_table, stub_bfd, elf32_hppa_stub_hash_newfunc)) @@ -2532,12 +2519,9 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) /* Likewise for the argument location hash table. */ args_hash_table = ((struct elf32_hppa_args_hash_table *) - malloc (sizeof (struct elf32_hppa_args_hash_table))); + bfd_malloc (sizeof (struct elf32_hppa_args_hash_table))); if (!args_hash_table) - { - bfd_set_error (bfd_error_no_memory); - goto error_return; - } + goto error_return; if (!elf32_hppa_args_hash_table_init (args_hash_table, elf32_hppa_args_hash_newfunc)) @@ -2557,12 +2541,10 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) we need to read in the local symbols in parallel and save them for later use; so hold pointers to the local symbols in an array. */ all_local_syms - = (Elf_Internal_Sym **) malloc (sizeof (Elf_Internal_Sym *) * bfd_count); + = (Elf_Internal_Sym **) bfd_malloc (sizeof (Elf_Internal_Sym *) + * bfd_count); if (all_local_syms == NULL) - { - bfd_set_error (bfd_error_no_memory); - goto error_return; - } + goto error_return; memset (all_local_syms, 0, sizeof (Elf_Internal_Sym *) * bfd_count); /* Walk over all the input BFDs adding entries to the args hash table @@ -2579,11 +2561,10 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) /* We need an array of the local symbols attached to the input bfd. Unfortunately, we're going to have to read & swap them in. */ local_syms - = (Elf_Internal_Sym *)malloc (symtab_hdr->sh_info - * sizeof (Elf_Internal_Sym)); + = (Elf_Internal_Sym *) bfd_malloc (symtab_hdr->sh_info + * sizeof (Elf_Internal_Sym)); if (local_syms == NULL) { - bfd_set_error (bfd_error_no_memory); for (i = 0; i < bfd_count; i++) if (all_local_syms[i]) free (all_local_syms[i]); @@ -2593,11 +2574,10 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) all_local_syms[index] = local_syms; ext_syms - = (Elf32_External_Sym *)malloc (symtab_hdr->sh_info - * sizeof (Elf32_External_Sym)); + = (Elf32_External_Sym *) bfd_malloc (symtab_hdr->sh_info + * sizeof (Elf32_External_Sym)); if (ext_syms == NULL) { - bfd_set_error (bfd_error_no_memory); for (i = 0; i < bfd_count; i++) if (all_local_syms[i]) free (all_local_syms[i]); @@ -2682,10 +2662,11 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) /* Allocate space for the external relocations. */ external_relocs - = (Elf32_External_Rela *) malloc (section->reloc_count * sizeof (Elf32_External_Rela)); + = ((Elf32_External_Rela *) + bfd_malloc (section->reloc_count + * sizeof (Elf32_External_Rela))); if (external_relocs == NULL) { - bfd_set_error (bfd_error_no_memory); for (i = 0; i < bfd_count; i++) if (all_local_syms[i]) free (all_local_syms[i]); @@ -2695,10 +2676,10 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) /* Likewise for the internal relocations. */ internal_relocs - = (Elf_Internal_Rela *) malloc (section->reloc_count * sizeof (Elf_Internal_Rela)); + = ((Elf_Internal_Rela *) + bfd_malloc (section->reloc_count * sizeof (Elf_Internal_Rela))); if (internal_relocs == NULL) { - bfd_set_error (bfd_error_no_memory); free (external_relocs); for (i = 0; i < bfd_count; i++) if (all_local_syms[i]) @@ -2795,10 +2776,9 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) /* Tack on an ID so we can uniquely identify this local symbol in the stub or arg info hash tables. */ - new_name = malloc (strlen (sym_name) + 10); + new_name = bfd_malloc (strlen (sym_name) + 10); if (new_name == 0) { - bfd_set_error (bfd_error_bad_value); free (internal_relocs); for (i = 0; i < bfd_count; i++) if (all_local_syms[i]) @@ -2882,11 +2862,9 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) len = strlen (sym_name); len += 23; - stub_name = malloc (len); + stub_name = bfd_malloc (len); if (!stub_name) { - bfd_set_error (bfd_error_no_memory); - /* Because sym_name was mallocd above for local symbols. */ if (r_index < symtab_hdr->sh_info) diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index cb2a3dc75dc..9ee5966b2c4 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -902,6 +902,9 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, else { h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) { diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index d712569d391..2303f62be3a 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -873,6 +873,9 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section, else { h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) { diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index b599c12cd49..8b68031a23c 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -437,7 +437,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = false), /* pcrel_offset */ /* Like R_PPC_ADDR16_HA, but referring to the GOT table entry for - the symbol. FIXME: Not supported. */ + the symbol. */ HOWTO (R_PPC_GOT16_HA, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -678,7 +678,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = false), /* pcrel_offset */ /* A sign-extended 16 bit value relative to _SDA_BASE_, for use with - small data items. FIXME: Not supported. */ + small data items. */ HOWTO (R_PPC_SDAREL16, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -693,7 +693,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - /* 32-bit section relative relocation. FIXME: not supported. */ + /* 32-bit section relative relocation. */ HOWTO (R_PPC_SECTOFF, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ @@ -708,7 +708,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = 0, /* dst_mask */ true), /* pcrel_offset */ - /* 16-bit lower half section relative relocation. FIXME: not supported. */ + /* 16-bit lower half section relative relocation. */ HOWTO (R_PPC_SECTOFF_LO, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -723,7 +723,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - /* 16-bit upper half section relative relocation. FIXME: not supported. */ + /* 16-bit upper half section relative relocation. */ HOWTO (R_PPC_SECTOFF_HI, /* type */ 16, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -738,7 +738,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - /* 16-bit upper half adjusted section relative relocation. FIXME: not supported. */ + /* 16-bit upper half adjusted section relative relocation. */ HOWTO (R_PPC_SECTOFF_HA, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -868,7 +868,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = false), /* pcrel_offset */ /* A sign-extended 16 bit value relative to _SDA2_BASE_, for use with - small data items. FIXME: Not supported. */ + small data items. */ HOWTO (R_PPC_EMB_SDA2REL, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -888,7 +888,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = field with the appropriate register (0, 2, or 13). */ HOWTO (R_PPC_EMB_SDA21, /* type */ 0, /* rightshift */ - 1, /* size (0 = byte, 1 = short, 2 = long) */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ @@ -2137,6 +2137,9 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, else { h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; sym_name = h->root.root.string; if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) @@ -2343,9 +2346,9 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, if (r_type == R_PPC_EMB_SDA21) { /* fill in register field */ - insn = bfd_get_32 (output_bfd, contents + offset - 2); + insn = bfd_get_32 (output_bfd, contents + offset); insn = (insn & ~RA_REGISTER_MASK) | (reg << RA_REGISTER_SHIFT); - bfd_put_32 (output_bfd, insn, contents + offset - 2); + bfd_put_32 (output_bfd, insn, contents + offset); } } break; -- 2.30.2