summaryrefslogtreecommitdiff
path: root/gold/ehframe.cc
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-07-01 14:37:49 +0930
committerAlan Modra <amodra@gmail.com>2019-07-13 09:57:50 +0930
commit220f99066d6ce2a6caf17692fcc57d714d8f6910 (patch)
tree81dbd577f8116359ab582788dd808abaf08da32a /gold/ehframe.cc
parent32f598441988e5a086ba8580e82f4944c3692eb5 (diff)
downloadbinutils-gdb-220f99066d6ce2a6caf17692fcc57d714d8f6910.tar.gz
[GOLD] PowerPC notoc eh_frame
When generating notoc call and branch stubs without the benefit of pc-relative insns, the stubs need to use LR to access the run time PC. All LR changes must be described in .eh_frame if we're to support unwinding through asynchronous exceptions. That's what this patch does. The patch has gone through way too many iterations. At first I attempted to add multiple FDEs, one for each stub. That ran into difficulties with do_plt_fde_location which is only capable of setting the address of a single FDE per Output_data section, and with removing any FDEs added on a previous do_relax pass. Removing FDEs (git commit be897fb774) went overboard in matching the FDE contents. That means either stashing the contents created for add_eh_frame_for_plt to use when calling remove_eh_frame_for_plt, or recreating contents on the fly (*) just to remove FDEs. In fact, FDE content matching is quite unnecesary. FDEs added by a previous do_relax pass are those with u_.from_linker.post_map set. So they can easily be recognised just by looking at that flag. This patch keeps that part of the multiple FDE changes. In the end I went for just one FDE per stub group to describe the call stubs. That's reasonably efficient for the common case of only needing to describe the __tls_get_addr_opt call stub. We don't expect to be making many calls using notoc stubs without pc-relative insns. *) Which has it's own set of problems. The contents must be recreated using the old stub layout, but .eh_frame size can affect stub requirements so you need to temporarily keep the old .eh_frame size when creating new stubs, then reset .eh_frame size before adding new FDEs. * ehframe.cc (Fde::operator==): Delete. (Cie::remove_fde): Delete. (Eh_frame::remove_ehframe_for_plt): Delete fde_data and fde_length parameters. Remove all post-map plt FDEs. * ehframe.h (Fde:post_map): Make const, add variant to compare plt. (Fde::operator==): Delete. (Cie::remove_fde): Implement here. (Cie::last_fde): New accessor. (Eh_frame::remove_ehframe_for_plt): Update prototype. * layout.cc (Layout::remove_eh_frame_for_plt): Delete fde_data and fde_length parameters. * layout.h (Layout::remove_eh_frame_for_plt): Update prototype. * powerpc.cc (Stub_table::tls_get_addr_opt_bctrl_): Delete. (Stub_table::plt_fde_len_, plt_fde_, init_plt_fde): Delete. (Stub_table::add_plt_call_entry): Don't set tls_get_addr_opt_bctrl_. (eh_advance): New function. (stub_sort): New function. (Stub_table::add_eh_frame): Emit eh_frame for notoc plt calls and branches as well as __tls_get_addr_opt plt call stub. (Stub_table::remove_eh_frame): Update to suit.
Diffstat (limited to 'gold/ehframe.cc')
-rw-r--r--gold/ehframe.cc47
1 files changed, 14 insertions, 33 deletions
diff --git a/gold/ehframe.cc b/gold/ehframe.cc
index df056d3d362..51490e0e908 100644
--- a/gold/ehframe.cc
+++ b/gold/ehframe.cc
@@ -325,21 +325,6 @@ Eh_frame_hdr::get_fde_addresses(Output_file* of,
// Class Fde.
-bool
-Fde::operator==(const Fde& that) const
-{
- if (this->object_ != that.object_
- || this->contents_ != that.contents_)
- return false;
- if (this->object_ == NULL)
- return (this->u_.from_linker.plt == that.u_.from_linker.plt
- && this->u_.from_linker.post_map == that.u_.from_linker.post_map);
- else
- return (this->u_.from_object.shndx == that.u_.from_object.shndx
- && (this->u_.from_object.input_offset
- == that.u_.from_object.input_offset));
-}
-
// Write the FDE to OVIEW starting at OFFSET. CIE_OFFSET is the
// offset of the CIE in OVIEW. OUTPUT_OFFSET is the offset of the
// Eh_frame section within the output section. FDE_ENCODING is the
@@ -458,15 +443,6 @@ Cie::set_output_offset(section_offset_type output_offset,
return output_offset + length;
}
-// Remove FDE. Only the last FDE using this CIE may be removed.
-
-void
-Cie::remove_fde(const Fde* fde)
-{
- gold_assert(*fde == *this->fdes_.back());
- this->fdes_.pop_back();
-}
-
// Write the CIE to OVIEW starting at OFFSET. OUTPUT_OFFSET is the
// offset of the Eh_frame section within the output section. Round up
// the bytes to ADDRALIGN. ADDRESS is the virtual address of OVIEW.
@@ -1167,26 +1143,31 @@ Eh_frame::add_ehframe_for_plt(Output_data* plt, const unsigned char* cie_data,
this->final_data_size_ += align_address(fde_length + 8, this->addralign());
}
-// Remove unwind information for a PLT. Only the last FDE added may be removed.
+// Remove all post-map unwind information for a PLT.
void
Eh_frame::remove_ehframe_for_plt(Output_data* plt,
const unsigned char* cie_data,
- size_t cie_length,
- const unsigned char* fde_data,
- size_t fde_length)
+ size_t cie_length)
{
+ if (!this->mappings_are_done_)
+ return;
+
Cie cie(NULL, 0, 0, elfcpp::DW_EH_PE_pcrel | elfcpp::DW_EH_PE_sdata4, "",
cie_data, cie_length);
Cie_offsets::iterator find_cie = this->cie_offsets_.find(&cie);
gold_assert (find_cie != this->cie_offsets_.end());
Cie* pcie = *find_cie;
- Fde* fde = new Fde(plt, fde_data, fde_length, this->mappings_are_done_);
- pcie->remove_fde(fde);
-
- if (this->mappings_are_done_)
- this->final_data_size_ -= align_address(fde_length + 8, this->addralign());
+ while (pcie->fde_count() != 0)
+ {
+ const Fde* fde = pcie->last_fde();
+ if (!fde->post_map(plt))
+ break;
+ size_t length = fde->length();
+ this->final_data_size_ -= align_address(length + 8, this->addralign());
+ pcie->remove_fde();
+ }
}
// Return the number of FDEs.