aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
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;
}