summaryrefslogtreecommitdiff
path: root/bfd/elf-eh-frame.c
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2005-01-31 20:39:11 +0000
committerRichard Sandiford <rdsandiford@googlemail.com>2005-01-31 20:39:11 +0000
commit8c946ed5d5af555d95f39630fcb56bfc6b0ce93b (patch)
tree65cab0a41c020d51a982aef8b506199ec171ea51 /bfd/elf-eh-frame.c
parent89fac5e3c33745a93c9b90538048505d46ca365c (diff)
downloadbinutils-gdb-8c946ed5d5af555d95f39630fcb56bfc6b0ce93b.tar.gz
* elf-bfd.h (elf_backend_data): Add elf_backend_eh_frame_address_size.
(_bfd_elf_eh_frame_address_size): Declare. * elfxx-target.h (elf_backend_eh_frame_address_size): Define a default. (elfNN_bed): Initialize elf_backend_eh_frame_address_size. * elfxx-mips.h (_bfd_mips_elf_eh_frame_address_size): Declare. (elf_backend_eh_frame_address_size): Define. * elfxx-mips.c (_bfd_mips_elf_eh_frame_address_size): New function. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Get the address size from the new backend hook. (_bfd_elf_write_section_eh_frame): Likewise. (_bfd_elf_eh_frame_address_size): New function.
Diffstat (limited to 'bfd/elf-eh-frame.c')
-rw-r--r--bfd/elf-eh-frame.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index ab316adeab3..389f6f30933 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -418,8 +418,10 @@ _bfd_elf_discard_section_eh_frame
it (it would need to use 64-bit .eh_frame format anyway). */
REQUIRE (sec->size == (unsigned int) sec->size);
- ptr_size = (elf_elfheader (abfd)->e_ident[EI_CLASS]
- == ELFCLASS64) ? 8 : 4;
+ ptr_size = (get_elf_backend_data (abfd)
+ ->elf_backend_eh_frame_address_size (abfd, sec));
+ REQUIRE (ptr_size != 0);
+
buf = ehbuf;
last_cie = NULL;
last_cie_inf = NULL;
@@ -987,12 +989,14 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
unsigned int ptr_size;
struct eh_cie_fde *ent;
- ptr_size = (elf_elfheader (sec->owner)->e_ident[EI_CLASS]
- == ELFCLASS64) ? 8 : 4;
-
if (sec->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
return bfd_set_section_contents (abfd, sec->output_section, contents,
sec->output_offset, sec->size);
+
+ ptr_size = (get_elf_backend_data (abfd)
+ ->elf_backend_eh_frame_address_size (abfd, sec));
+ BFD_ASSERT (ptr_size != 0);
+
sec_info = elf_section_data (sec)->sec_info;
htab = elf_hash_table (info);
hdr_info = &htab->eh_info;
@@ -1407,6 +1411,14 @@ _bfd_elf_write_section_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info)
return retval;
}
+/* Return the width of FDE addresses. This is the default implementation. */
+
+unsigned int
+_bfd_elf_eh_frame_address_size (bfd *abfd, asection *sec ATTRIBUTE_UNUSED)
+{
+ return elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64 ? 8 : 4;
+}
+
/* Decide whether we can use a PC-relative encoding within the given
EH frame section. This is the default implementation. */