Don't record file offset for CIEs.

This commit is contained in:
Ian Lance Taylor
2008-02-02 06:50:45 +00:00
parent f964a7562a
commit 1cac254c18
2 changed files with 21 additions and 26 deletions

View File

@ -561,12 +561,10 @@ Eh_frame::add_ehframe_input_section(
p != new_cies.end(); p != new_cies.end();
++p) ++p)
{ {
uint64_t zero = 0;
if (p->second) if (p->second)
this->cie_offsets_.insert(std::make_pair(p->first, zero)); this->cie_offsets_.insert(p->first);
else else
this->unmergeable_cie_offsets_.push_back(std::make_pair(p->first, this->unmergeable_cie_offsets_.push_back(p->first);
zero));
} }
return true; return true;
@ -875,7 +873,7 @@ Eh_frame::read_cie(Sized_relobj<size, big_endian>* object,
{ {
Cie_offsets::iterator find_cie = this->cie_offsets_.find(&cie); Cie_offsets::iterator find_cie = this->cie_offsets_.find(&cie);
if (find_cie != this->cie_offsets_.end()) if (find_cie != this->cie_offsets_.end())
cie_pointer = find_cie->first; cie_pointer = *find_cie;
else else
{ {
// See if we already saw this CIE in this object file. // See if we already saw this CIE in this object file.
@ -990,11 +988,11 @@ Eh_frame::fde_count() const
this->unmergeable_cie_offsets_.begin(); this->unmergeable_cie_offsets_.begin();
p != this->unmergeable_cie_offsets_.end(); p != this->unmergeable_cie_offsets_.end();
++p) ++p)
ret += p->first->fde_count(); ret += (*p)->fde_count();
for (Cie_offsets::const_iterator p = this->cie_offsets_.begin(); for (Cie_offsets::const_iterator p = this->cie_offsets_.begin();
p != this->cie_offsets_.end(); p != this->cie_offsets_.end();
++p) ++p)
ret += p->first->fde_count(); ret += (*p)->fde_count();
return ret; return ret;
} }
@ -1003,29 +1001,22 @@ Eh_frame::fde_count() const
void void
Eh_frame::set_final_data_size() Eh_frame::set_final_data_size()
{ {
off_t start_file_offset = this->offset();
section_offset_type output_offset = 0; section_offset_type output_offset = 0;
for (Unmergeable_cie_offsets::iterator p = for (Unmergeable_cie_offsets::iterator p =
this->unmergeable_cie_offsets_.begin(); this->unmergeable_cie_offsets_.begin();
p != this->unmergeable_cie_offsets_.end(); p != this->unmergeable_cie_offsets_.end();
++p) ++p)
{ output_offset = (*p)->set_output_offset(output_offset,
p->second = start_file_offset + output_offset;
output_offset = p->first->set_output_offset(output_offset,
this->addralign(), this->addralign(),
&this->merge_map_); &this->merge_map_);
}
for (Cie_offsets::iterator p = this->cie_offsets_.begin(); for (Cie_offsets::iterator p = this->cie_offsets_.begin();
p != this->cie_offsets_.end(); p != this->cie_offsets_.end();
++p) ++p)
{ output_offset = (*p)->set_output_offset(output_offset,
p->second = start_file_offset + output_offset;
output_offset = p->first->set_output_offset(output_offset,
this->addralign(), this->addralign(),
&this->merge_map_); &this->merge_map_);
}
gold_assert((output_offset & (this->addralign() - 1)) == 0); gold_assert((output_offset & (this->addralign() - 1)) == 0);
this->set_data_size(output_offset); this->set_data_size(output_offset);
@ -1114,11 +1105,11 @@ Eh_frame::do_sized_write(unsigned char* oview)
this->unmergeable_cie_offsets_.begin(); this->unmergeable_cie_offsets_.begin();
p != this->unmergeable_cie_offsets_.end(); p != this->unmergeable_cie_offsets_.end();
++p) ++p)
o = p->first->write<size, big_endian>(oview, o, this->eh_frame_hdr_); o = (*p)->write<size, big_endian>(oview, o, this->eh_frame_hdr_);
for (Cie_offsets::iterator p = this->cie_offsets_.begin(); for (Cie_offsets::iterator p = this->cie_offsets_.begin();
p != this->cie_offsets_.end(); p != this->cie_offsets_.end();
++p) ++p)
o = p->first->write<size, big_endian>(oview, o, this->eh_frame_hdr_); o = (*p)->write<size, big_endian>(oview, o, this->eh_frame_hdr_);
} }
#ifdef HAVE_TARGET_32_LITTLE #ifdef HAVE_TARGET_32_LITTLE

View File

@ -23,6 +23,10 @@
#ifndef GOLD_EHFRAME_H #ifndef GOLD_EHFRAME_H
#define GOLD_EHFRAME_H #define GOLD_EHFRAME_H
#include <map>
#include <set>
#include <vector>
#include "output.h" #include "output.h"
#include "merge.h" #include "merge.h"
@ -343,11 +347,11 @@ class Eh_frame : public Output_section_data
{ return *cie1 < *cie2; } { return *cie1 < *cie2; }
}; };
// A mapping from unique CIEs to their offset in the output file. // A set of unique CIEs.
typedef std::map<Cie*, uint64_t, Cie_less> Cie_offsets; typedef std::set<Cie*, Cie_less> Cie_offsets;
// A list of unmergeable CIEs with their offsets. // A list of unmergeable CIEs.
typedef std::vector<std::pair<Cie*, uint64_t> > Unmergeable_cie_offsets; typedef std::vector<Cie*> Unmergeable_cie_offsets;
// A mapping from offsets to CIEs. This is used while reading an // A mapping from offsets to CIEs. This is used while reading an
// input section. // input section.