mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 19:50:13 +08:00
Fix race condition while building EH frame header.
gold/ PR gold/14860 * ehframe.cc (Eh_frame_hdr::Eh_frame_hdr): Initialize lock_. (Ehframe_hdr::set_final_data_size): Allocate a Lock. * ehframe.h (Eh_frame_hdr::record_fde): Hold the lock while updating fde_offsets_. (Eh_frame_hdr::lock_): New data member.
This commit is contained in:
@ -1,3 +1,12 @@
|
||||
2013-11-14 Cary Coutant <ccoutant@google.com>
|
||||
|
||||
PR gold/14860
|
||||
* ehframe.cc (Eh_frame_hdr::Eh_frame_hdr): Initialize lock_.
|
||||
(Ehframe_hdr::set_final_data_size): Allocate a Lock.
|
||||
* ehframe.h (Eh_frame_hdr::record_fde): Hold the lock while
|
||||
updating fde_offsets_.
|
||||
(Eh_frame_hdr::lock_): New data member.
|
||||
|
||||
2013-11-06 Cary Coutant <ccoutant@google.com>
|
||||
|
||||
PR gold/15758
|
||||
|
@ -84,7 +84,8 @@ Eh_frame_hdr::Eh_frame_hdr(Output_section* eh_frame_section,
|
||||
eh_frame_section_(eh_frame_section),
|
||||
eh_frame_data_(eh_frame_data),
|
||||
fde_offsets_(),
|
||||
any_unrecognized_eh_frame_sections_(false)
|
||||
any_unrecognized_eh_frame_sections_(false),
|
||||
lock_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -102,6 +103,9 @@ Eh_frame_hdr::set_final_data_size()
|
||||
this->fde_offsets_.reserve(fde_count);
|
||||
}
|
||||
this->set_data_size(data_size);
|
||||
// We need a lock for updating the fde_offsets_ vector while writing
|
||||
// the FDEs.
|
||||
this->lock_ = new Lock();
|
||||
}
|
||||
|
||||
// Write the data to the file.
|
||||
|
@ -60,7 +60,10 @@ class Eh_frame_hdr : public Output_section_data
|
||||
record_fde(section_offset_type fde_offset, unsigned char fde_encoding)
|
||||
{
|
||||
if (!this->any_unrecognized_eh_frame_sections_)
|
||||
this->fde_offsets_.push_back(std::make_pair(fde_offset, fde_encoding));
|
||||
{
|
||||
Hold_lock(*this->lock_);
|
||||
this->fde_offsets_.push_back(std::make_pair(fde_offset, fde_encoding));
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -157,6 +160,8 @@ class Eh_frame_hdr : public Output_section_data
|
||||
// Whether we found any .eh_frame sections which we could not
|
||||
// process.
|
||||
bool any_unrecognized_eh_frame_sections_;
|
||||
// Lock held while updating fde_offsets_.
|
||||
Lock* lock_;
|
||||
};
|
||||
|
||||
// This class holds an FDE.
|
||||
|
Reference in New Issue
Block a user