2010-09-24 Thomas Schwinge <thomas@codesourcery.com>
+ * elf32-arm.c, elf32-cris.c, elf32-hppa.c, elf32-i370.c, elf32-m32r.c,
+ elf32-m68k.c, elf32-microblaze.c, elf32-ppc.c, elf32-score.c,
+ elf32-score7.c, elf32-sh.c, elf32-vax.c, elf32-xtensa.c, elf64-alpha.c,
+ elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-sparc.c, elfcode.h,
+ elflink.c, elfxx-ia64.c, elfxx-mips.c: Use STN_UNDEF when referring to
+ the zero symbol index.
+
* elflink.c (bfd_elf_reloc_symbol_deleted_p): Compare the symbol index
to STN_UNDEF, not SHN_UNDEF.
name = bfd_section_name (input_bfd, sec);
}
- if (r_symndx != 0
+ if (r_symndx != STN_UNDEF
&& r_type != R_ARM_NONE
&& (h == NULL
|| h->root.type == bfd_link_hash_defined
/* PR 9934: It is possible to have relocations that do not
refer to symbols, thus it is also possible to have an
object file containing relocations but no symbol table. */
- && (r_symndx > 0 || nsyms > 0))
+ && (r_symndx > STN_UNDEF || nsyms > 0))
{
(*_bfd_error_handler) (_("%B: bad symbol index: %d"), abfd,
r_symndx);
case R_CRIS_16:
case R_CRIS_32:
if (info->shared
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0
&& ((r_type != R_CRIS_8_PCREL
&& r_type != R_CRIS_16_PCREL
elf32_hppa_reloc_type_class (const Elf_Internal_Rela *rela)
{
/* Handle TLS relocs first; we don't want them to be marked
- relative by the "if (ELF32_R_SYM (rela->r_info) == 0)"
+ relative by the "if (ELF32_R_SYM (rela->r_info) == STN_UNDEF)"
check below. */
switch ((int) ELF32_R_TYPE (rela->r_info))
{
return reloc_class_normal;
}
- if (ELF32_R_SYM (rela->r_info) == 0)
+ if (ELF32_R_SYM (rela->r_info) == STN_UNDEF)
return reloc_class_relative;
switch ((int) ELF32_R_TYPE (rela->r_info))
case (int) R_I370_ADDR31:
case (int) R_I370_ADDR16:
if (info->shared
- && r_symndx != 0)
+ && r_symndx != STN_UNDEF)
{
Elf_Internal_Rela outrel;
bfd_byte *loc;
case R_M32R_HI16_ULO_RELA:
case R_M32R_LO16_RELA:
if (info->shared
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0
&& (( r_type != R_M32R_10_PCREL_RELA
&& r_type != R_M32R_18_PCREL_RELA
case R_68K_PC16:
case R_68K_PC32:
if (info->shared
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
return FALSE;
}
- if (r_symndx != 0
+ if (r_symndx != STN_UNDEF
&& r_type != R_68K_NONE
&& (h == NULL
|| h->root.type == bfd_link_hash_defined
case (int) R_MICROBLAZE_64:
case (int) R_MICROBLAZE_32:
{
- /* r_symndx will be zero only for relocs against symbols
+ /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
from removed linkonce sections, or sections discarded by
a linker script. */
- if (r_symndx == 0 || (input_section->flags & SEC_ALLOC) == 0)
+ if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
{
relocation += addend;
if (r_type == R_MICROBLAZE_32)
if (local_sections[r_symndx] == sec)
break;
if (r_symndx >= symtab_hdr->sh_info)
- r_symndx = 0;
+ r_symndx = STN_UNDEF;
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
- if (r_symndx != 0)
+ if (r_symndx != STN_UNDEF)
rel->r_addend -= (local_syms[r_symndx].st_value
+ sec->output_offset
+ sec->output_section->vma);
if (local_sections[r_symndx] == sec)
break;
if (r_symndx >= symtab_hdr->sh_info)
- r_symndx = 0;
+ r_symndx = STN_UNDEF;
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
- if (r_symndx != 0)
+ if (r_symndx != STN_UNDEF)
rel->r_addend -= (local_syms[r_symndx].st_value
+ sec->output_offset
+ sec->output_section->vma);
sym_name);
ret = FALSE;
}
- else if (r_symndx == 0 || bfd_is_abs_section (sec))
+ else if (r_symndx == STN_UNDEF || bfd_is_abs_section (sec))
;
else if (sec == NULL || sec->owner == NULL)
{
&& h != NULL
&& h->root.def_dynamic
&& !h->root.def_regular))
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0)
{
/* If we're creating a shared library, or this relocation is against a symbol
input_section))
return bfd_reloc_undefined;
}
- else if (r_symndx == 0)
- /* r_symndx will be zero only for relocs against symbols
+ else if (r_symndx == STN_UNDEF)
+ /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
from removed linkonce sections, or sections discarded by
a linker script. */
value = 0;
&& h != NULL
&& h->root.def_dynamic
&& !h->root.def_regular))
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0)
{
/* If we're creating a shared library, or this relocation is against a symbol
input_section))
return bfd_reloc_undefined;
}
- else if (r_symndx == 0)
- /* r_symndx will be zero only for relocs against symbols
+ else if (r_symndx == STN_UNDEF)
+ /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
from removed linkonce sections, or sections discarded by
a linker script. */
value = 0;
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak)
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0
&& !is_vxworks_tls
&& (r_type == R_SH_DIR32
case R_VAX_16:
case R_VAX_32:
if (info->shared
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0
&& ((r_type != R_VAX_PC8
&& r_type != R_VAX_PC16
name = bfd_section_name (input_bfd, sec);
}
- if (r_symndx != 0
+ if (r_symndx != STN_UNDEF
&& r_type != R_XTENSA_NONE
&& (h == NULL
|| h->root.type == bfd_link_hash_defined
case R_ALPHA_TLSLDM:
/* The symbol for a TLSLDM reloc is ignored. Collapse the
- reloc to the 0 symbol so that they all match. */
- r_symndx = 0;
+ reloc to the STN_UNDEF (0) symbol so that they all match. */
+ r_symndx = STN_UNDEF;
h = 0;
maybe_dynamic = FALSE;
/* FALLTHRU */
as appropriate. */
use_gottprel = FALSE;
- new_symndx = is_gd ? ELF64_R_SYM (irel->r_info) : 0;
+ new_symndx = is_gd ? ELF64_R_SYM (irel->r_info) : STN_UNDEF;
/* Beware of the compiler hoisting part of the sequence out a loop
and adjusting the destination register for the TLSGD insn. If this
case R_ALPHA_TLSLDM:
/* The symbol for a TLSLDM reloc is ignored. Collapse the
- reloc to the 0 symbol so that they all match. */
- r_symndx = 0;
+ reloc to the STN_UNDEF (0) symbol so that they all match. */
+ r_symndx = STN_UNDEF;
break;
default:
r_symndx = ELF64_R_SYM(rel->r_info);
/* The symbol for a TLSLDM reloc is ignored. Collapse the
- reloc to the 0 symbol so that they all match. */
+ reloc to the STN_UNDEF (0) symbol so that they all match. */
if (r_type == R_ALPHA_TLSLDM)
- r_symndx = 0;
+ r_symndx = STN_UNDEF;
if (r_symndx < symtab_hdr->sh_info)
{
msec = sec;
value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel);
- /* If this is a tp-relative relocation against sym 0,
+ /* If this is a tp-relative relocation against sym STN_UNDEF (0),
this is hackery from relax_section. Force the value to
be the tls module base. */
- if (r_symndx == 0
+ if (r_symndx == STN_UNDEF
&& (r_type == R_ALPHA_TLSLDM
|| r_type == R_ALPHA_GOTTPREL
|| r_type == R_ALPHA_TPREL64
dynaddend = value - dtp_base;
}
else if (info->shared
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC)
&& !undef_weak_ref)
{
/* ??? .eh_frame references to discarded sections will be smashed
to relocations against SHN_UNDEF. The .eh_frame format allows
NULL to be encoded as 0 in any format, so this works here. */
- if (r_symndx == 0)
+ if (r_symndx == STN_UNDEF)
howto = (elf64_alpha_howto_table
+ (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG));
goto default_reloc;
static enum elf_reloc_type_class
elf64_hppa_reloc_type_class (const Elf_Internal_Rela *rela)
{
- if (ELF64_R_SYM (rela->r_info) == 0)
+ if (ELF64_R_SYM (rela->r_info) == STN_UNDEF)
return reloc_class_relative;
switch ((int) ELF64_R_TYPE (rela->r_info))
default:
if (! used_sym)
{
- if (rela.r_sym == 0)
+ if (rela.r_sym == STN_UNDEF)
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
else
{
/* Check that tls relocs are used with tls syms, and non-tls
relocs are used with non-tls syms. */
- if (r_symndx != 0
+ if (r_symndx != STN_UNDEF
&& r_type != R_PPC64_NONE
&& (h == NULL
|| h->elf.root.type == bfd_link_hash_defined
if (local_sections[r_symndx] == sec)
break;
if (r_symndx >= symtab_hdr->sh_info)
- r_symndx = 0;
+ r_symndx = STN_UNDEF;
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
- if (r_symndx != 0)
+ if (r_symndx != STN_UNDEF)
rel->r_addend -= (local_syms[r_symndx].st_value
+ sec->output_offset
+ sec->output_section->vma);
if (local_sections[r_symndx] == sec)
break;
if (r_symndx >= symtab_hdr->sh_info)
- r_symndx = 0;
+ r_symndx = STN_UNDEF;
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
- if (r_symndx != 0)
+ if (r_symndx != STN_UNDEF)
rel->r_addend -= (local_syms[r_symndx].st_value
+ sec->output_offset
+ sec->output_section->vma);
case R_PPC64_TOC:
/* Relocation value is TOC base. */
relocation = TOCstart;
- if (r_symndx == 0)
+ if (r_symndx == STN_UNDEF)
relocation += htab->stub_group[input_section->id].toc_off;
else if (unresolved_reloc)
;
sym_name);
ret = FALSE;
}
- else if (r_symndx == 0 || bfd_is_abs_section (sec))
+ else if (r_symndx == STN_UNDEF || bfd_is_abs_section (sec))
;
else if (sec == NULL || sec->owner == NULL)
{
else
relent->address = rela.r_offset - asect->vma;
- if (ELF64_R_SYM (rela.r_info) == 0)
+ if (ELF64_R_SYM (rela.r_info) == STN_UNDEF)
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
else
{
else
relent->address = rela.r_offset - asect->vma;
- if (ELF_R_SYM (rela.r_info) == 0)
+ if (ELF_R_SYM (rela.r_info) == STN_UNDEF)
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
else if (ELF_R_SYM (rela.r_info) > symcount)
{
return FALSE;
}
}
- else if (r_symndx != 0)
+ else if (r_symndx != STN_UNDEF)
{
(*_bfd_error_handler)
(_("%B: non-zero symbol index (0x%lx) for offset 0x%lx in section `%A'"
discarded section. */
if ((sec = *ps) != NULL && elf_discarded_section (sec))
{
- BFD_ASSERT (r_symndx != 0);
+ BFD_ASSERT (r_symndx != STN_UNDEF);
if (action_discarded & COMPLAIN)
(*finfo->info->callbacks->einfo)
(_("%X`%s' referenced in section `%A' of %B: "
/* I suppose the backend ought to fill in the
section of any STT_SECTION symbol against a
processor specific section. */
- r_symndx = 0;
+ r_symndx = STN_UNDEF;
if (bfd_is_abs_section (sec))
;
else if (sec == NULL || sec->owner == NULL)
if (!bfd_is_abs_section (osec))
{
r_symndx = osec->target_index;
- if (r_symndx == 0)
+ if (r_symndx == STN_UNDEF)
{
struct elf_link_hash_table *htab;
asection *oi;
}
}
- BFD_ASSERT (r_symndx != 0);
+ BFD_ASSERT (r_symndx != STN_UNDEF);
}
}
struct elf_link_hash_entry *h;
r_symndx = cookie->rel->r_info >> cookie->r_sym_shift;
- if (r_symndx == 0)
+ if (r_symndx == STN_UNDEF)
return NULL;
if (r_symndx >= cookie->locsymcount
case R_IA64_DIR64LSB:
/* Install a dynamic relocation for this reloc. */
if ((dynamic_symbol_p || info->shared)
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0)
{
unsigned int dyn_r_type;
case R_IA64_PCREL64MSB:
case R_IA64_PCREL64LSB:
/* Install a dynamic relocation for this reloc. */
- if (dynamic_symbol_p && r_symndx != 0)
+ if (dynamic_symbol_p && r_symndx != STN_UNDEF)
{
BFD_ASSERT (srel != NULL);
&& h->root.def_dynamic
&& !h->root.def_regular
&& !h->has_static_relocs))
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (h == NULL
|| h->root.root.type != bfd_link_hash_undefweak
|| ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
case R_MIPS_TLS_LDM:
if (r_type == R_MIPS_TLS_LDM)
{
- r_symndx = 0;
+ r_symndx = STN_UNDEF;
h = NULL;
}
/* Fall through */
}
else
{
- BFD_ASSERT (flag == GOT_TLS_LDM || r_symndx != 0);
+ BFD_ASSERT (flag == GOT_TLS_LDM || r_symndx != STN_UNDEF);
if (!mips_elf_record_local_got_symbol (abfd, r_symndx,
rel->r_addend,
case R_MIPS_HIGHEST:
/* Don't refuse a high part relocation if it's against
no symbol (e.g. part of a compound relocation). */
- if (r_symndx == 0)
+ if (r_symndx == STN_UNDEF)
break;
/* R_MIPS_HI16 against _gp_disp is used for $gp setup,