aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-12-19 19:45:43 +0000
committerH.J. Lu <hjl.tools@gmail.com>2012-12-19 19:45:43 +0000
commit59d6ffb2c9f99611fd9942516c434215f560d9ce (patch)
tree45581f0a6d6aa1396ffed907698da431eb1d7af5 /bfd
parent13ca314985e8d50c15a7f147e768581737847f3c (diff)
downloadgdb-59d6ffb2c9f99611fd9942516c434215f560d9ce.zip
gdb-59d6ffb2c9f99611fd9942516c434215f560d9ce.tar.gz
gdb-59d6ffb2c9f99611fd9942516c434215f560d9ce.tar.bz2
Fix and use elf_append_rel
* elf32-i386.c (elf_i386_relocate_section): Replace bfd_elf32_swap_reloc_out with elf_append_rel. (elf_i386_finish_dynamic_symbol): Likewise. * elflink.c (elf_append_rel): Call swap_reloc_out instead of swap_reloca_out.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elf32-i386.c62
-rw-r--r--bfd/elflink.c2
3 files changed, 23 insertions, 50 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e869b90..2ceee8d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2012-12-19 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf32-i386.c (elf_i386_relocate_section): Replace
+ bfd_elf32_swap_reloc_out with elf_append_rel.
+ (elf_i386_finish_dynamic_symbol): Likewise.
+
+ * elflink.c (elf_append_rel): Call swap_reloc_out instead of
+ swap_reloca_out.
+
2012-12-18 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_finish_dynamic_symbol): Reindent.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 4ca25f2..f031eac 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -3365,7 +3365,6 @@ elf_i386_relocate_section (bfd *output_bfd,
if (info->shared && h->non_got_ref)
{
Elf_Internal_Rela outrel;
- bfd_byte *loc;
asection *sreloc;
bfd_vma offset;
@@ -3399,10 +3398,7 @@ elf_i386_relocate_section (bfd *output_bfd,
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
sreloc = htab->elf.irelifunc;
- loc = sreloc->contents;
- loc += (sreloc->reloc_count++
- * sizeof (Elf32_External_Rel));
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, sreloc, &outrel);
/* If this reloc is against an external symbol, we
do not want to fiddle with the addend. Otherwise,
@@ -3556,7 +3552,6 @@ elf_i386_relocate_section (bfd *output_bfd,
{
asection *s;
Elf_Internal_Rela outrel;
- bfd_byte *loc;
s = htab->elf.srelgot;
if (s == NULL)
@@ -3566,9 +3561,7 @@ elf_i386_relocate_section (bfd *output_bfd,
+ htab->elf.sgot->output_offset
+ off);
outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
- loc = s->contents;
- loc += s->reloc_count++ * sizeof (Elf32_External_Rel);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, s, &outrel);
}
local_got_offsets[r_symndx] |= 1;
@@ -3696,7 +3689,6 @@ elf_i386_relocate_section (bfd *output_bfd,
|| h->root.type == bfd_link_hash_undefined)))
{
Elf_Internal_Rela outrel;
- bfd_byte *loc;
bfd_boolean skip, relocate;
asection *sreloc;
@@ -3741,10 +3733,7 @@ elf_i386_relocate_section (bfd *output_bfd,
goto check_relocation_error;
}
- loc = sreloc->contents;
- loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
-
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, sreloc, &outrel);
/* If this reloc is against an external symbol, we do
not want to fiddle with the addend. Otherwise, we
@@ -3759,7 +3748,6 @@ elf_i386_relocate_section (bfd *output_bfd,
if (!info->executable)
{
Elf_Internal_Rela outrel;
- bfd_byte *loc;
asection *sreloc;
outrel.r_offset = rel->r_offset
@@ -3769,9 +3757,7 @@ elf_i386_relocate_section (bfd *output_bfd,
sreloc = elf_section_data (input_section)->sreloc;
if (sreloc == NULL)
abort ();
- loc = sreloc->contents;
- loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, sreloc, &outrel);
}
/* Fall through */
@@ -3997,7 +3983,6 @@ elf_i386_relocate_section (bfd *output_bfd,
else
{
Elf_Internal_Rela outrel;
- bfd_byte *loc;
int dr_type;
asection *sreloc;
@@ -4008,6 +3993,7 @@ elf_i386_relocate_section (bfd *output_bfd,
if (GOT_TLS_GDESC_P (tls_type))
{
+ bfd_byte *loc;
outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_DESC);
BFD_ASSERT (htab->sgotplt_jump_table_size + offplt + 8
<= htab->elf.sgotplt->size);
@@ -4020,7 +4006,7 @@ elf_i386_relocate_section (bfd *output_bfd,
loc += (htab->next_tls_desc_index++
* sizeof (Elf32_External_Rel));
BFD_ASSERT (loc + sizeof (Elf32_External_Rel)
- <= sreloc->contents + sreloc->size);
+ <= sreloc->contents + sreloc->size);
bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
if (indx == 0)
{
@@ -4065,11 +4051,7 @@ elf_i386_relocate_section (bfd *output_bfd,
htab->elf.sgot->contents + off);
outrel.r_info = ELF32_R_INFO (indx, dr_type);
- loc = sreloc->contents;
- loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
- BFD_ASSERT (loc + sizeof (Elf32_External_Rel)
- <= sreloc->contents + sreloc->size);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, sreloc, &outrel);
if (GOT_TLS_GD_P (tls_type))
{
@@ -4087,11 +4069,7 @@ elf_i386_relocate_section (bfd *output_bfd,
outrel.r_info = ELF32_R_INFO (indx,
R_386_TLS_DTPOFF32);
outrel.r_offset += 4;
- sreloc->reloc_count++;
- loc += sizeof (Elf32_External_Rel);
- BFD_ASSERT (loc + sizeof (Elf32_External_Rel)
- <= sreloc->contents + sreloc->size);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, sreloc, &outrel);
}
}
else if (tls_type == GOT_TLS_IE_BOTH)
@@ -4103,9 +4081,7 @@ elf_i386_relocate_section (bfd *output_bfd,
htab->elf.sgot->contents + off + 4);
outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF);
outrel.r_offset += 4;
- sreloc->reloc_count++;
- loc += sizeof (Elf32_External_Rel);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, sreloc, &outrel);
}
dr_done:
@@ -4287,7 +4263,6 @@ elf_i386_relocate_section (bfd *output_bfd,
else
{
Elf_Internal_Rela outrel;
- bfd_byte *loc;
if (htab->elf.srelgot == NULL)
abort ();
@@ -4300,9 +4275,7 @@ elf_i386_relocate_section (bfd *output_bfd,
bfd_put_32 (output_bfd, 0,
htab->elf.sgot->contents + off + 4);
outrel.r_info = ELF32_R_INFO (0, R_386_TLS_DTPMOD32);
- loc = htab->elf.srelgot->contents;
- loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, htab->elf.srelgot, &outrel);
htab->tls_ldm_got.offset |= 1;
}
relocation = htab->elf.sgot->output_section->vma
@@ -4326,7 +4299,6 @@ elf_i386_relocate_section (bfd *output_bfd,
{
Elf_Internal_Rela outrel;
asection *sreloc;
- bfd_byte *loc;
outrel.r_offset = rel->r_offset
+ input_section->output_section->vma
@@ -4342,9 +4314,7 @@ elf_i386_relocate_section (bfd *output_bfd,
sreloc = elf_section_data (input_section)->sreloc;
if (sreloc == NULL)
abort ();
- loc = sreloc->contents;
- loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ elf_append_rel (output_bfd, sreloc, &outrel);
if (indx)
continue;
else if (r_type == R_386_TLS_LE_32)
@@ -4632,7 +4602,6 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
&& (elf_i386_hash_entry(h)->tls_type & GOT_TLS_IE) == 0)
{
Elf_Internal_Rela rel;
- bfd_byte *loc;
/* This symbol has an entry in the global offset table. Set it
up. */
@@ -4690,15 +4659,12 @@ do_glob_dat:
rel.r_info = ELF32_R_INFO (h->dynindx, R_386_GLOB_DAT);
}
- loc = htab->elf.srelgot->contents;
- loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
- bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
+ elf_append_rel (output_bfd, htab->elf.srelgot, &rel);
}
if (h->needs_copy)
{
Elf_Internal_Rela rel;
- bfd_byte *loc;
/* This symbol needs a copy reloc. Set it up. */
@@ -4712,9 +4678,7 @@ do_glob_dat:
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset);
rel.r_info = ELF32_R_INFO (h->dynindx, R_386_COPY);
- loc = htab->srelbss->contents;
- loc += htab->srelbss->reloc_count++ * sizeof (Elf32_External_Rel);
- bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
+ elf_append_rel (output_bfd, htab->srelbss, &rel);
}
return TRUE;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f22e023..661b2eb 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -13077,5 +13077,5 @@ elf_append_rel (bfd *abfd, asection *s, Elf_Internal_Rela *rel)
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
bfd_byte *loc = s->contents + (s->reloc_count++ * bed->s->sizeof_rel);
BFD_ASSERT (loc + bed->s->sizeof_rel <= s->contents + s->size);
- bed->s->swap_reloca_out (abfd, rel, loc);
+ bed->s->swap_reloc_out (abfd, rel, loc);
}