* 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,7 +2173,14 @@ 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;
enum elf_ppc_reloc_type r_type;
struct elf_link_hash_entry *h;
r_symndx = ELF64_R_SYM (rel->r_info);
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
switch (r_type)
{ {
case R_PPC64_GOT16: case R_PPC64_GOT16:
case R_PPC64_GOT16_DS: case R_PPC64_GOT16_DS:
@ -2178,7 +2188,6 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
case R_PPC64_GOT16_HI: case R_PPC64_GOT16_HI:
case R_PPC64_GOT16_LO: case R_PPC64_GOT16_LO:
case R_PPC64_GOT16_LO_DS: case R_PPC64_GOT16_LO_DS:
r_symndx = ELF64_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info) if (r_symndx >= symtab_hdr->sh_info)
{ {
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; h = sym_hashes[r_symndx - symtab_hdr->sh_info];
@ -2197,7 +2206,6 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
case R_PPC64_PLT16_LO: case R_PPC64_PLT16_LO:
case R_PPC64_PLT32: case R_PPC64_PLT32:
case R_PPC64_PLT64: case R_PPC64_PLT64:
r_symndx = ELF64_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info) if (r_symndx >= symtab_hdr->sh_info)
{ {
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; h = sym_hashes[r_symndx - symtab_hdr->sh_info];
@ -2212,7 +2220,6 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
case R_PPC64_REL24: case R_PPC64_REL24:
case R_PPC64_REL32: case R_PPC64_REL32:
case R_PPC64_REL64: case R_PPC64_REL64:
r_symndx = ELF64_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info) if (r_symndx >= symtab_hdr->sh_info)
{ {
struct ppc_link_hash_entry *eh; struct ppc_link_hash_entry *eh;
@ -2255,7 +2262,6 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
case R_PPC64_UADDR32: case R_PPC64_UADDR32:
case R_PPC64_UADDR64: case R_PPC64_UADDR64:
case R_PPC64_TOC: case R_PPC64_TOC:
r_symndx = ELF64_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info) if (r_symndx >= symtab_hdr->sh_info)
{ {
struct ppc_link_hash_entry *eh; struct ppc_link_hash_entry *eh;
@ -2279,7 +2285,7 @@ ppc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
default: default:
break; 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;