Adapt `info probes' to support printing probes of different types.
[deliverable/binutils-gdb.git] / gold / ehframe.cc
index 82a6d6e8986b01fd365e8335f42bc209d82d3795..faea1a8381ebfc6a9182b44c220db59edbaad269 100644 (file)
@@ -1,6 +1,6 @@
 // ehframe.cc -- handle exception frame sections for gold
 
-// Copyright 2006, 2007, 2008, 2010, 2011, 2012 Free Software Foundation, Inc.
+// Copyright (C) 2006-2015 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -326,15 +326,16 @@ Eh_frame_hdr::get_fde_addresses(Output_file* of,
 // Class Fde.
 
 // Write the FDE to OVIEW starting at OFFSET.  CIE_OFFSET is the
-// offset of the CIE in OVIEW.  FDE_ENCODING is the encoding, from the
-// CIE.  ADDRALIGN is the required alignment.  ADDRESS is the virtual
-// address of OVIEW.  Record the FDE pc for EH_FRAME_HDR.  Return the
-// new offset.
+// offset of the CIE in OVIEW.  OUTPUT_OFFSET is the offset of the
+// Eh_frame section within the output section.  FDE_ENCODING is the
+// encoding, from the CIE.  ADDRALIGN is the required alignment.
+// ADDRESS is the virtual address of OVIEW.  Record the FDE pc for
+// EH_FRAME_HDR.  Return the new offset.
 
 template<int size, bool big_endian>
 section_offset_type
-Fde::write(unsigned char* oview, section_offset_type offset,
-          uint64_t address, unsigned int addralign,
+Fde::write(unsigned char* oview, section_offset_type output_offset,
+          section_offset_type offset, uint64_t address, unsigned int addralign,
           section_offset_type cie_offset, unsigned char fde_encoding,
           Eh_frame_hdr* eh_frame_hdr)
 {
@@ -389,7 +390,7 @@ Fde::write(unsigned char* oview, section_offset_type offset,
 
   // Tell the exception frame header about this FDE.
   if (eh_frame_hdr != NULL)
-    eh_frame_hdr->record_fde(offset, fde_encoding);
+    eh_frame_hdr->record_fde(output_offset + offset, fde_encoding);
 
   return offset + aligned_full_length;
 }
@@ -441,30 +442,19 @@ Cie::set_output_offset(section_offset_type output_offset,
   return output_offset + length;
 }
 
-// A FDE plus some info from a CIE to allow later writing of the FDE.
-
-struct Post_fde
-{
-  Post_fde(Fde* f, section_offset_type cie_off, unsigned char encoding)
-    : fde(f), cie_offset(cie_off), fde_encoding(encoding)
-  { }
-
-  Fde* fde;
-  section_offset_type cie_offset;
-  unsigned char fde_encoding;
-};
-
-// Write the CIE to OVIEW starting at OFFSET.  Round up the bytes to
-// ADDRALIGN.  ADDRESS is the virtual address of OVIEW.
+// 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.
 // EH_FRAME_HDR is the exception frame header for FDE recording.
 // POST_FDES stashes FDEs created after mappings were done, for later
 // writing.  Return the new offset.
 
 template<int size, bool big_endian>
 section_offset_type
-Cie::write(unsigned char* oview, section_offset_type offset,
-          uint64_t address, unsigned int addralign,
-          Eh_frame_hdr* eh_frame_hdr, Post_fdes* post_fdes)
+Cie::write(unsigned char* oview, section_offset_type output_offset,
+          section_offset_type offset, uint64_t address,
+          unsigned int addralign, Eh_frame_hdr* eh_frame_hdr,
+          Post_fdes* post_fdes)
 {
   gold_assert((offset & (addralign - 1)) == 0);
 
@@ -499,10 +489,10 @@ Cie::write(unsigned char* oview, section_offset_type offset,
        ++p)
     {
       if ((*p)->post_map())
-       post_fdes->push_back(new Post_fde(*p, cie_offset, fde_encoding));
+       post_fdes->push_back(Post_fde(*p, cie_offset, fde_encoding));
       else
-       offset = (*p)->write<size, big_endian>(oview, offset, address,
-                                              addralign, cie_offset,
+       offset = (*p)->write<size, big_endian>(oview, output_offset, offset,
+                                              address, addralign, cie_offset,
                                               fde_encoding, eh_frame_hdr);
     }
 
@@ -1106,7 +1096,10 @@ Eh_frame::set_final_data_size()
       return;
     }
 
-  section_offset_type output_offset = 0;
+  section_offset_type output_start = 0;
+  if (this->is_offset_valid())
+    output_start = this->offset() - this->output_section()->offset();
+  section_offset_type output_offset = output_start;
 
   for (Unmergeable_cie_offsets::iterator p =
         this->unmergeable_cie_offsets_.begin();
@@ -1124,10 +1117,10 @@ Eh_frame::set_final_data_size()
                                            &this->merge_map_);
 
   this->mappings_are_done_ = true;
-  this->final_data_size_ = output_offset;
+  this->final_data_size_ = output_offset - output_start;
 
   gold_assert((output_offset & (this->addralign() - 1)) == 0);
-  this->set_data_size(output_offset);
+  this->set_data_size(this->final_data_size_);
 }
 
 // Return an output offset for an input offset.
@@ -1196,28 +1189,28 @@ Eh_frame::do_sized_write(unsigned char* oview)
   uint64_t address = this->address();
   unsigned int addralign = this->addralign();
   section_offset_type o = 0;
+  const off_t output_offset = this->offset() - this->output_section()->offset();
   Post_fdes post_fdes;
   for (Unmergeable_cie_offsets::iterator p =
         this->unmergeable_cie_offsets_.begin();
        p != this->unmergeable_cie_offsets_.end();
        ++p)
-    o = (*p)->write<size, big_endian>(oview, o, address, addralign,
-                                      this->eh_frame_hdr_, &post_fdes);
+    o = (*p)->write<size, big_endian>(oview, output_offset, o, address,
+                                     addralign, this->eh_frame_hdr_,
+                                     &post_fdes);
   for (Cie_offsets::iterator p = this->cie_offsets_.begin();
        p != this->cie_offsets_.end();
        ++p)
-    o = (*p)->write<size, big_endian>(oview, o, address, addralign,
-                                      this->eh_frame_hdr_, &post_fdes);
+    o = (*p)->write<size, big_endian>(oview, output_offset, o, address,
+                                     addralign, this->eh_frame_hdr_,
+                                     &post_fdes);
   for (Post_fdes::iterator p = post_fdes.begin();
        p != post_fdes.end();
        ++p)
-    {
-      o = (*p)->fde->write<size, big_endian>(oview, o, address, addralign,
-                                            (*p)->cie_offset,
-                                            (*p)->fde_encoding,
-                                            this->eh_frame_hdr_);
-      delete *p;
-    }
+    o = (*p).fde->write<size, big_endian>(oview, output_offset, o, address,
+                                         addralign, (*p).cie_offset,
+                                         (*p).fde_encoding,
+                                         this->eh_frame_hdr_);
 }
 
 #ifdef HAVE_TARGET_32_LITTLE
This page took 0.026318 seconds and 4 git commands to generate.