Correct nios2 _gp address computation.
2015-12-27 Sandra Loosemore <sandra@codesourcery.com> bfd/ * elf32-nios2.c (nios2_elf_assign_gp): Correct computation of _gp address. (nios2_elf32_relocate_section): Tidy code for R_NIOS2_GPREL error messages.
This commit is contained in:
parent
5d01527536
commit
a7be2893a6
@ -1,3 +1,10 @@
|
|||||||
|
2015-12-27 Sandra Loosemore <sandra@codesourcery.com>
|
||||||
|
|
||||||
|
* elf32-nios2.c (nios2_elf_assign_gp): Correct computation of _gp
|
||||||
|
address.
|
||||||
|
(nios2_elf32_relocate_section): Tidy code for R_NIOS2_GPREL error
|
||||||
|
messages.
|
||||||
|
|
||||||
2015-12-24 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
2015-12-24 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
||||||
|
|
||||||
* elf32-arm.c (using_thumb_only): Check that profile is 'M' and update
|
* elf32-arm.c (using_thumb_only): Check that profile is 'M' and update
|
||||||
|
@ -3086,7 +3086,15 @@ lookup:
|
|||||||
case bfd_link_hash_defined:
|
case bfd_link_hash_defined:
|
||||||
case bfd_link_hash_defweak:
|
case bfd_link_hash_defweak:
|
||||||
gp_found = TRUE;
|
gp_found = TRUE;
|
||||||
*pgp = lh->u.def.value;
|
{
|
||||||
|
asection *sym_sec = lh->u.def.section;
|
||||||
|
bfd_vma sym_value = lh->u.def.value;
|
||||||
|
|
||||||
|
if (sym_sec->output_section)
|
||||||
|
sym_value = (sym_value + sym_sec->output_offset
|
||||||
|
+ sym_sec->output_section->vma);
|
||||||
|
*pgp = sym_value;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case bfd_link_hash_indirect:
|
case bfd_link_hash_indirect:
|
||||||
case bfd_link_hash_warning:
|
case bfd_link_hash_warning:
|
||||||
@ -3719,7 +3727,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
struct elf32_nios2_link_hash_entry *eh;
|
struct elf32_nios2_link_hash_entry *eh;
|
||||||
bfd_vma relocation;
|
bfd_vma relocation;
|
||||||
bfd_vma gp;
|
bfd_vma gp;
|
||||||
bfd_vma reloc_address;
|
|
||||||
bfd_reloc_status_type r = bfd_reloc_ok;
|
bfd_reloc_status_type r = bfd_reloc_ok;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
int r_type;
|
int r_type;
|
||||||
@ -3762,12 +3769,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
if (bfd_link_relocatable (info))
|
if (bfd_link_relocatable (info))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sec && sec->output_section)
|
|
||||||
reloc_address = (sec->output_section->vma + sec->output_offset
|
|
||||||
+ rel->r_offset);
|
|
||||||
else
|
|
||||||
reloc_address = 0;
|
|
||||||
|
|
||||||
if (howto)
|
if (howto)
|
||||||
{
|
{
|
||||||
switch (howto->type)
|
switch (howto->type)
|
||||||
@ -3816,6 +3817,15 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
/* Turns an absolute address into a gp-relative address. */
|
/* Turns an absolute address into a gp-relative address. */
|
||||||
if (!nios2_elf_assign_gp (output_bfd, &gp, info))
|
if (!nios2_elf_assign_gp (output_bfd, &gp, info))
|
||||||
{
|
{
|
||||||
|
bfd_vma reloc_address;
|
||||||
|
|
||||||
|
if (sec && sec->output_section)
|
||||||
|
reloc_address = (sec->output_section->vma
|
||||||
|
+ sec->output_offset
|
||||||
|
+ rel->r_offset);
|
||||||
|
else
|
||||||
|
reloc_address = 0;
|
||||||
|
|
||||||
format = _("global pointer relative relocation at address "
|
format = _("global pointer relative relocation at address "
|
||||||
"0x%08x when _gp not defined\n");
|
"0x%08x when _gp not defined\n");
|
||||||
sprintf (msgbuf, format, reloc_address);
|
sprintf (msgbuf, format, reloc_address);
|
||||||
@ -3825,7 +3835,7 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bfd_vma symbol_address = rel->r_addend + relocation;
|
bfd_vma symbol_address = rel->r_addend + relocation;
|
||||||
relocation = relocation + rel->r_addend - gp;
|
relocation = symbol_address - gp;
|
||||||
rel->r_addend = 0;
|
rel->r_addend = 0;
|
||||||
if (((signed) relocation < -32768
|
if (((signed) relocation < -32768
|
||||||
|| (signed) relocation > 32767)
|
|| (signed) relocation > 32767)
|
||||||
@ -3833,6 +3843,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
|| h->root.type == bfd_link_hash_defined
|
|| h->root.type == bfd_link_hash_defined
|
||||||
|| h->root.type == bfd_link_hash_defweak))
|
|| h->root.type == bfd_link_hash_defweak))
|
||||||
{
|
{
|
||||||
|
if (h)
|
||||||
|
name = h->root.root.string;
|
||||||
format = _("Unable to reach %s (at 0x%08x) from the "
|
format = _("Unable to reach %s (at 0x%08x) from the "
|
||||||
"global pointer (at 0x%08x) because the "
|
"global pointer (at 0x%08x) because the "
|
||||||
"offset (%d) is out of the allowed range, "
|
"offset (%d) is out of the allowed range, "
|
||||||
@ -3848,7 +3860,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
|||||||
rel->r_offset, relocation,
|
rel->r_offset, relocation,
|
||||||
rel->r_addend);
|
rel->r_addend);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case R_NIOS2_UJMP:
|
case R_NIOS2_UJMP:
|
||||||
r = nios2_elf32_do_ujmp_relocate (input_bfd, howto,
|
r = nios2_elf32_do_ujmp_relocate (input_bfd, howto,
|
||||||
|
Loading…
Reference in New Issue
Block a user