* elf64-ppc.c (ppc64_elf_check_relocs): Use a local var and cast

result of ELF64_R_TYPE to enum before using in a switch.
	(ppc64_elf_gc_mark_hook): Likewise.
	(ppc64_elf_gc_sweep_hook): Likewise.
	(ppc64_elf_reloc_type_class): Likewise.
This commit is contained in:
Alan Modra 2001-10-02 09:22:46 +00:00
parent f97d5f7ca4
commit a33d1f7775
2 changed files with 125 additions and 108 deletions

View file

@ -1,3 +1,11 @@
2001-10-02 Alan Modra <amodra@bigpond.net.au>
* elf64-ppc.c (ppc64_elf_check_relocs): Use a local var and cast
result of ELF64_R_TYPE to enum before using in a switch.
(ppc64_elf_gc_mark_hook): Likewise.
(ppc64_elf_gc_sweep_hook): Likewise.
(ppc64_elf_reloc_type_class): Likewise.
2001-10-02 Alan Modra <amodra@bigpond.net.au> 2001-10-02 Alan Modra <amodra@bigpond.net.au>
* version.h: New file. * version.h: New file.

View file

@ -1842,6 +1842,7 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs)
{ {
unsigned long r_symndx; unsigned long r_symndx;
struct elf_link_hash_entry *h; struct elf_link_hash_entry *h;
enum elf_ppc_reloc_type r_type;
r_symndx = ELF64_R_SYM (rel->r_info); r_symndx = ELF64_R_SYM (rel->r_info);
if (r_symndx < symtab_hdr->sh_info) if (r_symndx < symtab_hdr->sh_info)
@ -1849,7 +1850,8 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs)
else else
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; h = sym_hashes[r_symndx - symtab_hdr->sh_info];
switch (ELF64_R_TYPE (rel->r_info)) r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
switch (r_type)
{ {
/* GOT16 relocations */ /* GOT16 relocations */
case R_PPC64_GOT16: case R_PPC64_GOT16:
@ -1997,7 +1999,7 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs)
symbol. */ symbol. */
if ((info->shared if ((info->shared
&& (sec->flags & SEC_ALLOC) != 0 && (sec->flags & SEC_ALLOC) != 0
&& (IS_ABSOLUTE_RELOC (ELF64_R_TYPE (rel->r_info)) && (IS_ABSOLUTE_RELOC (r_type)
|| (h != NULL || (h != NULL
&& (! info->symbolic && (! info->symbolic
|| h->root.type == bfd_link_hash_defweak || h->root.type == bfd_link_hash_defweak
@ -2081,7 +2083,7 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs)
} }
p->count += 1; p->count += 1;
if (!IS_ABSOLUTE_RELOC (ELF64_R_TYPE (rel->r_info))) if (!IS_ABSOLUTE_RELOC (r_type))
p->pc_count += 1; p->pc_count += 1;
} }
else else
@ -2112,7 +2114,10 @@ ppc64_elf_gc_mark_hook (abfd, info, rel, h, sym)
{ {
if (h != NULL) if (h != NULL)
{ {
switch (ELF64_R_TYPE (rel->r_info)) enum elf_ppc_reloc_type r_type;
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
switch (r_type)
{ {
case R_PPC64_GNU_VTINHERIT: case R_PPC64_GNU_VTINHERIT:
case R_PPC64_GNU_VTENTRY: case R_PPC64_GNU_VTENTRY:
@ -2161,8 +2166,6 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
struct elf_link_hash_entry **sym_hashes; struct elf_link_hash_entry **sym_hashes;
bfd_signed_vma *local_got_refcounts; bfd_signed_vma *local_got_refcounts;
const Elf_Internal_Rela *rel, *relend; const Elf_Internal_Rela *rel, *relend;
unsigned long r_symndx;
struct elf_link_hash_entry *h;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd); sym_hashes = elf_sym_hashes (abfd);
@ -2170,116 +2173,119 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
relend = relocs + sec->reloc_count; relend = relocs + sec->reloc_count;
for (rel = relocs; rel < relend; rel++) for (rel = relocs; rel < relend; rel++)
switch (ELF64_R_TYPE (rel->r_info)) {
{ unsigned long r_symndx;
case R_PPC64_GOT16: enum elf_ppc_reloc_type r_type;
case R_PPC64_GOT16_DS: struct elf_link_hash_entry *h;
case R_PPC64_GOT16_HA:
case R_PPC64_GOT16_HI:
case R_PPC64_GOT16_LO:
case R_PPC64_GOT16_LO_DS:
r_symndx = ELF64_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info)
{
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
if (h->got.refcount > 0)
h->got.refcount--;
}
else
{
if (local_got_refcounts[r_symndx] > 0)
local_got_refcounts[r_symndx]--;
}
break;
case R_PPC64_PLT16_HA: r_symndx = ELF64_R_SYM (rel->r_info);
case R_PPC64_PLT16_HI: r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
case R_PPC64_PLT16_LO: switch (r_type)
case R_PPC64_PLT32: {
case R_PPC64_PLT64: case R_PPC64_GOT16:
r_symndx = ELF64_R_SYM (rel->r_info); case R_PPC64_GOT16_DS:
if (r_symndx >= symtab_hdr->sh_info) case R_PPC64_GOT16_HA:
{ case R_PPC64_GOT16_HI:
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; case R_PPC64_GOT16_LO:
if (h->plt.refcount > 0) case R_PPC64_GOT16_LO_DS:
h->plt.refcount--; if (r_symndx >= symtab_hdr->sh_info)
} {
break; h = sym_hashes[r_symndx - symtab_hdr->sh_info];
if (h->got.refcount > 0)
h->got.refcount--;
}
else
{
if (local_got_refcounts[r_symndx] > 0)
local_got_refcounts[r_symndx]--;
}
break;
case R_PPC64_REL14: case R_PPC64_PLT16_HA:
case R_PPC64_REL14_BRNTAKEN: case R_PPC64_PLT16_HI:
case R_PPC64_REL14_BRTAKEN: case R_PPC64_PLT16_LO:
case R_PPC64_REL24: case R_PPC64_PLT32:
case R_PPC64_REL32: case R_PPC64_PLT64:
case R_PPC64_REL64: if (r_symndx >= symtab_hdr->sh_info)
r_symndx = ELF64_R_SYM (rel->r_info); {
if (r_symndx >= symtab_hdr->sh_info) h = sym_hashes[r_symndx - symtab_hdr->sh_info];
{ if (h->plt.refcount > 0)
struct ppc_link_hash_entry *eh; h->plt.refcount--;
struct ppc_dyn_relocs **pp; }
struct ppc_dyn_relocs *p; break;
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; case R_PPC64_REL14:
eh = (struct ppc_link_hash_entry *) h; case R_PPC64_REL14_BRNTAKEN:
case R_PPC64_REL14_BRTAKEN:
case R_PPC64_REL24:
case R_PPC64_REL32:
case R_PPC64_REL64:
if (r_symndx >= symtab_hdr->sh_info)
{
struct ppc_link_hash_entry *eh;
struct ppc_dyn_relocs **pp;
struct ppc_dyn_relocs *p;
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) h = sym_hashes[r_symndx - symtab_hdr->sh_info];
if (p->sec == sec) eh = (struct ppc_link_hash_entry *) h;
{
p->pc_count -= 1;
p->count -= 1;
if (p->count == 0)
*pp = p->next;
break;
}
}
break;
case R_PPC64_ADDR14: for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
case R_PPC64_ADDR14_BRNTAKEN: if (p->sec == sec)
case R_PPC64_ADDR14_BRTAKEN: {
case R_PPC64_ADDR16: p->pc_count -= 1;
case R_PPC64_ADDR16_DS: p->count -= 1;
case R_PPC64_ADDR16_HA: if (p->count == 0)
case R_PPC64_ADDR16_HI: *pp = p->next;
case R_PPC64_ADDR16_HIGHER: break;
case R_PPC64_ADDR16_HIGHERA: }
case R_PPC64_ADDR16_HIGHEST: }
case R_PPC64_ADDR16_HIGHESTA: break;
case R_PPC64_ADDR16_LO:
case R_PPC64_ADDR16_LO_DS:
case R_PPC64_ADDR24:
case R_PPC64_ADDR30:
case R_PPC64_ADDR32:
case R_PPC64_ADDR64:
case R_PPC64_UADDR16:
case R_PPC64_UADDR32:
case R_PPC64_UADDR64:
case R_PPC64_TOC:
r_symndx = ELF64_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info)
{
struct ppc_link_hash_entry *eh;
struct ppc_dyn_relocs **pp;
struct ppc_dyn_relocs *p;
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; case R_PPC64_ADDR14:
eh = (struct ppc_link_hash_entry *) h; case R_PPC64_ADDR14_BRNTAKEN:
case R_PPC64_ADDR14_BRTAKEN:
case R_PPC64_ADDR16:
case R_PPC64_ADDR16_DS:
case R_PPC64_ADDR16_HA:
case R_PPC64_ADDR16_HI:
case R_PPC64_ADDR16_HIGHER:
case R_PPC64_ADDR16_HIGHERA:
case R_PPC64_ADDR16_HIGHEST:
case R_PPC64_ADDR16_HIGHESTA:
case R_PPC64_ADDR16_LO:
case R_PPC64_ADDR16_LO_DS:
case R_PPC64_ADDR24:
case R_PPC64_ADDR30:
case R_PPC64_ADDR32:
case R_PPC64_ADDR64:
case R_PPC64_UADDR16:
case R_PPC64_UADDR32:
case R_PPC64_UADDR64:
case R_PPC64_TOC:
if (r_symndx >= symtab_hdr->sh_info)
{
struct ppc_link_hash_entry *eh;
struct ppc_dyn_relocs **pp;
struct ppc_dyn_relocs *p;
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) h = sym_hashes[r_symndx - symtab_hdr->sh_info];
if (p->sec == sec) eh = (struct ppc_link_hash_entry *) h;
{
p->count -= 1;
if (p->count == 0)
*pp = p->next;
break;
}
}
break;
default: for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
break; if (p->sec == sec)
} {
p->count -= 1;
if (p->count == 0)
*pp = p->next;
break;
}
}
break;
default:
break;
}
}
return true; return true;
} }
@ -3833,7 +3839,10 @@ static enum elf_reloc_type_class
ppc64_elf_reloc_type_class (rela) ppc64_elf_reloc_type_class (rela)
const Elf_Internal_Rela *rela; const Elf_Internal_Rela *rela;
{ {
switch ((int) ELF64_R_TYPE (rela->r_info)) enum elf_ppc_reloc_type r_type;
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rela->r_info);
switch (r_type)
{ {
case R_PPC64_RELATIVE: case R_PPC64_RELATIVE:
return reloc_class_relative; return reloc_class_relative;