aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorDan Gissel <dgisselq@ieee.org>2016-03-11 09:17:28 +0000
committerNick Clifton <nickc@redhat.com>2016-03-11 09:17:28 +0000
commit37b01f6a13f21f274bf9758ecbf5d9efd6153444 (patch)
tree5e877ed6002a0f657aad14edad65e2faefa4efb4 /bfd/elf.c
parentaa667814c7c9b77822d2ac2152dde4c01527da70 (diff)
downloadgdb-37b01f6a13f21f274bf9758ecbf5d9efd6153444.zip
gdb-37b01f6a13f21f274bf9758ecbf5d9efd6153444.tar.gz
gdb-37b01f6a13f21f274bf9758ecbf5d9efd6153444.tar.bz2
Fix some places where octet to byte conversions are needed.
PR 19713 * elf.c (_bfd_elf_section_offset): Ensure that the returned offset uses bytes not octets. * elflink.c (resolve_section): Likewise. Add a bfd parameter. (eval_section): Pass the input_bfd to resolve_section. (bfd_elf_perform_complex_relocation): Convert byte offset to octets before read and writing values. (elf_link_input_bfd): Add byte to octet conversions. (elf_reloc_link_order): Likewise. (elf_fixup_link_order): Likewise. (bfd_elf_final_link): Likewise. * reloc.c (_bfd_final_link_relocate): Likewise. * syms.c (_bfd_stab_section_find_nearest_line): Likewise.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 1013644..90319a2 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10464,6 +10464,12 @@ _bfd_elf_rel_local_sym (bfd *abfd,
sym->st_value + addend);
}
+/* Adjust an address within a section. Given OFFSET within SEC, return
+ the new offset within the section, based upon changes made to the
+ section. Returns -1 if the offset is now invalid.
+ The offset (in abnd out) is in target sized bytes, however big a
+ byte may be. */
+
bfd_vma
_bfd_elf_section_offset (bfd *abfd,
struct bfd_link_info *info,
@@ -10477,12 +10483,17 @@ _bfd_elf_section_offset (bfd *abfd,
offset);
case SEC_INFO_TYPE_EH_FRAME:
return _bfd_elf_eh_frame_section_offset (abfd, info, sec, offset);
+
default:
if ((sec->flags & SEC_ELF_REVERSE_COPY) != 0)
{
+ /* Reverse the offset. */
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
bfd_size_type address_size = bed->s->arch_size / 8;
- offset = sec->size - offset - address_size;
+
+ /* address_size and sec->size are in octets. Convert
+ to bytes before subtracting the original offset. */
+ offset = (sec->size - address_size) / bfd_octets_per_byte (abfd) - offset;
}
return offset;
}