16, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
+ complain_overflow_signed, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_PPC_EMB_SDAI16", /* name */
FALSE, /* partial_inplace */
16, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
+ complain_overflow_signed, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_PPC_EMB_SDA2I16", /* name */
FALSE, /* partial_inplace */
}
\f
static bfd_boolean
-create_sdata_sym (struct ppc_elf_link_hash_table *htab,
- elf_linker_section_t *lsect)
+create_sdata_sym (struct bfd_link_info *info, elf_linker_section_t *lsect)
{
+ struct ppc_elf_link_hash_table *htab = ppc_elf_hash_table (info);
+
lsect->sym = elf_link_hash_lookup (&htab->elf, lsect->sym_name,
TRUE, FALSE, TRUE);
if (lsect->sym == NULL)
if (lsect->sym->root.type == bfd_link_hash_new)
lsect->sym->non_elf = 0;
lsect->sym->ref_regular = 1;
+ _bfd_elf_link_hash_hide_symbol (info, lsect->sym, TRUE);
return TRUE;
}
return FALSE;
lsect->section = s;
- return create_sdata_sym (htab, lsect);
+ return create_sdata_sym (info, lsect);
}
/* Find a linker generated pointer with a given addend and type. */
break;
case R_PPC_SDAREL16:
- if (info->shared)
- {
- bad_shared_reloc (abfd, r_type);
- return FALSE;
- }
if (htab->sdata[0].sym == NULL
- && !create_sdata_sym (htab, &htab->sdata[0]))
+ && !create_sdata_sym (info, &htab->sdata[0]))
return FALSE;
if (h != NULL)
{
return FALSE;
}
if (htab->sdata[1].sym == NULL
- && !create_sdata_sym (htab, &htab->sdata[1]))
+ && !create_sdata_sym (info, &htab->sdata[1]))
return FALSE;
if (h != NULL)
{
return FALSE;
}
if (htab->sdata[0].sym == NULL
- && !create_sdata_sym (htab, &htab->sdata[0]))
+ && !create_sdata_sym (info, &htab->sdata[0]))
return FALSE;
if (htab->sdata[1].sym == NULL
- && !create_sdata_sym (htab, &htab->sdata[1]))
+ && !create_sdata_sym (info, &htab->sdata[1]))
return FALSE;
if (h != NULL)
{
htab->elf.hgot->root.u.def.value = g_o_t;
}
+ if (info->shared)
+ {
+ struct elf_link_hash_entry *sda = htab->sdata[0].sym;
+ if (sda != NULL
+ && !(sda->root.type == bfd_link_hash_defined
+ || sda->root.type == bfd_link_hash_defweak))
+ {
+ sda->root.type = bfd_link_hash_defined;
+ sda->root.u.def.section = htab->elf.hgot->root.u.def.section;
+ sda->root.u.def.value = htab->elf.hgot->root.u.def.value;
+ }
+ }
if (htab->glink != NULL
&& htab->glink->size != 0
linker_section_ptr->offset += 1;
}
- relocation = (lsect->section->output_offset
+ relocation = (lsect->section->output_section->vma
+ + lsect->section->output_offset
+ linker_section_ptr->offset - 1
- - 0x8000);
+ - SYM_VAL (lsect->sym));
#ifdef DEBUG
fprintf (stderr,
lsect->name, (long) relocation, (long) relocation);
#endif
- /* Subtract out the addend, because it will get added back in by the normal
- processing. */
- return relocation - linker_section_ptr->addend;
+ return relocation;
}
#define PPC_LO(v) ((v) & 0xffff)
}
}
+/* Return true if symbol is defined statically. */
+
+static bfd_boolean
+is_static_defined (struct elf_link_hash_entry *h)
+{
+ return ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && h->root.u.def.section != NULL
+ && h->root.u.def.section->output_section != NULL);
+}
+
/* The RELOCATE_SECTION function is called by the ELF backend linker
to handle the relocations for a section.
/* Indirect .sdata relocation. */
case R_PPC_EMB_SDAI16:
BFD_ASSERT (htab->sdata[0].section != NULL);
+ if (!is_static_defined (htab->sdata[0].sym))
+ {
+ unresolved_reloc = TRUE;
+ break;
+ }
relocation
= elf_finish_pointer_linker_section (input_bfd, &htab->sdata[0],
h, relocation, rel);
+ addend = 0;
break;
/* Indirect .sdata2 relocation. */
case R_PPC_EMB_SDA2I16:
BFD_ASSERT (htab->sdata[1].section != NULL);
+ if (!is_static_defined (htab->sdata[1].sym))
+ {
+ unresolved_reloc = TRUE;
+ break;
+ }
relocation
= elf_finish_pointer_linker_section (input_bfd, &htab->sdata[1],
h, relocation, rel);
+ addend = 0;
break;
/* Handle the TOC16 reloc. We want to use the offset within the .got
case R_PPC_SDAREL16:
{
const char *name;
+ struct elf_link_hash_entry *sda = htab->sdata[0].sym;
- if (sec == NULL || sec->output_section == NULL)
+ if (sec == NULL
+ || sec->output_section == NULL
+ || !is_static_defined (sda))
{
unresolved_reloc = TRUE;
break;
}
+ addend -= SYM_VAL (sda);
name = bfd_get_section_name (abfd, sec->output_section);
if (! ((CONST_STRNEQ (name, ".sdata")
howto->name,
name);
}
- addend -= SYM_VAL (htab->sdata[0].sym);
}
break;
case R_PPC_EMB_SDA2REL:
{
const char *name;
+ struct elf_link_hash_entry *sda = htab->sdata[1].sym;
- if (sec == NULL || sec->output_section == NULL)
+ if (sec == NULL
+ || sec->output_section == NULL
+ || !is_static_defined (sda))
{
unresolved_reloc = TRUE;
break;
}
+ addend -= SYM_VAL (sda);
name = bfd_get_section_name (abfd, sec->output_section);
if (! (CONST_STRNEQ (name, ".sdata2")
sym_name,
howto->name,
name);
-
- bfd_set_error (bfd_error_bad_value);
- ret = FALSE;
- continue;
}
- addend -= SYM_VAL (htab->sdata[1].sym);
}
break;
{
const char *name;
int reg;
+ struct elf_link_hash_entry *sda = NULL;
if (sec == NULL || sec->output_section == NULL)
{
&& (name[5] == 0 || name[5] == '.'))))
{
reg = 13;
- addend -= SYM_VAL (htab->sdata[0].sym);
+ sda = htab->sdata[0].sym;
}
else if (CONST_STRNEQ (name, ".sdata2")
|| CONST_STRNEQ (name, ".sbss2"))
{
reg = 2;
- addend -= SYM_VAL (htab->sdata[1].sym);
+ sda = htab->sdata[1].sym;
}
else if (strcmp (name, ".PPC.EMB.sdata0") == 0
|| strcmp (name, ".PPC.EMB.sbss0") == 0)
continue;
}
+ if (sda != NULL)
+ {
+ if (!is_static_defined (sda))
+ {
+ unresolved_reloc = TRUE;
+ break;
+ }
+ addend -= SYM_VAL (sda);
+ }
+
if (r_type == R_PPC_EMB_SDA21)
{ /* fill in register field */
insn = bfd_get_32 (output_bfd, contents + rel->r_offset);