// ehframe.cc -- handle exception frame sections for gold
-// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
this->set_data_size(data_size);
}
-// Write the data to the flie.
+// Write the data to the file.
void
Eh_frame_hdr::do_write(Output_file* of)
{
- if (parameters->get_size() == 32)
+ switch (parameters->size_and_endianness())
{
- if (!parameters->is_big_endian())
- {
#ifdef HAVE_TARGET_32_LITTLE
- this->do_sized_write<32, false>(of);
-#else
- gold_unreachable();
+ case Parameters::TARGET_32_LITTLE:
+ this->do_sized_write<32, false>(of);
+ break;
#endif
- }
- else
- {
#ifdef HAVE_TARGET_32_BIG
- this->do_sized_write<32, true>(of);
-#else
- gold_unreachable();
+ case Parameters::TARGET_32_BIG:
+ this->do_sized_write<32, true>(of);
+ break;
#endif
- }
- }
- else if (parameters->get_size() == 64)
- {
- if (!parameters->is_big_endian())
- {
#ifdef HAVE_TARGET_64_LITTLE
- this->do_sized_write<64, false>(of);
-#else
- gold_unreachable();
+ case Parameters::TARGET_64_LITTLE:
+ this->do_sized_write<64, false>(of);
+ break;
#endif
- }
- else
- {
#ifdef HAVE_TARGET_64_BIG
- this->do_sized_write<64, true>(of);
-#else
- gold_unreachable();
+ case Parameters::TARGET_64_BIG:
+ this->do_sized_write<64, true>(of);
+ break;
#endif
- }
+ default:
+ gold_unreachable();
}
- else
- gold_unreachable();
}
// Write the data to the file with the right endianness.
eh_frame_hdr_(NULL),
cie_offsets_(),
unmergeable_cie_offsets_(),
- merge_map_()
+ merge_map_(),
+ mappings_are_done_(false),
+ final_data_size_(0)
{
}
reloc_type, pcontents,
contents_len, &new_cies))
{
- this->eh_frame_hdr_->found_unrecognized_eh_frame_section();
+ if (this->eh_frame_hdr_ != NULL)
+ this->eh_frame_hdr_->found_unrecognized_eh_frame_section();
for (New_cies::iterator p = new_cies.begin();
p != new_cies.end();
section_size_type symbol_names_size,
const unsigned char* pcontents,
const unsigned char* pcie,
- const unsigned char *pcieend,
+ const unsigned char* pcieend,
Track_relocs<size, big_endian>* relocs,
Offsets_to_cie* cies,
New_cies* new_cies)
const unsigned char* pcontents,
unsigned int offset,
const unsigned char* pfde,
- const unsigned char *pfdeend,
+ const unsigned char* pfdeend,
Track_relocs<size, big_endian>* relocs,
Offsets_to_cie* cies)
{
if (symndx >= symbols_size / sym_size)
return false;
elfcpp::Sym<size, big_endian> sym(symbols + symndx * sym_size);
- fde_shndx = sym.get_st_shndx();
+ bool is_ordinary;
+ fde_shndx = object->adjust_sym_shndx(symndx, sym.get_st_shndx(),
+ &is_ordinary);
- if (fde_shndx != elfcpp::SHN_UNDEF
+ if (is_ordinary
+ && fde_shndx != elfcpp::SHN_UNDEF
&& fde_shndx < object->shnum()
&& !object->is_section_included(fde_shndx))
{
void
Eh_frame::set_final_data_size()
{
+ // We can be called more than once if Layout::set_segment_offsets
+ // finds a better mapping. We don't want to add all the mappings
+ // again.
+ if (this->mappings_are_done_)
+ {
+ this->set_data_size(this->final_data_size_);
+ return;
+ }
+
section_offset_type output_offset = 0;
for (Unmergeable_cie_offsets::iterator p =
this->addralign(),
&this->merge_map_);
+ this->mappings_are_done_ = true;
+ this->final_data_size_ = output_offset;
+
gold_assert((output_offset & (this->addralign() - 1)) == 0);
this->set_data_size(output_offset);
}
const off_t oview_size = this->data_size();
unsigned char* const oview = of->get_output_view(offset, oview_size);
- if (parameters->get_size() == 32)
+ switch (parameters->size_and_endianness())
{
- if (!parameters->is_big_endian())
- {
#ifdef HAVE_TARGET_32_LITTLE
- this->do_sized_write<32, false>(oview);
-#else
- gold_unreachable();
+ case Parameters::TARGET_32_LITTLE:
+ this->do_sized_write<32, false>(oview);
+ break;
#endif
- }
- else
- {
#ifdef HAVE_TARGET_32_BIG
- this->do_sized_write<32, true>(oview);
-#else
- gold_unreachable();
+ case Parameters::TARGET_32_BIG:
+ this->do_sized_write<32, true>(oview);
+ break;
#endif
- }
- }
- else if (parameters->get_size() == 64)
- {
- if (!parameters->is_big_endian())
- {
#ifdef HAVE_TARGET_64_LITTLE
- this->do_sized_write<64, false>(oview);
-#else
- gold_unreachable();
+ case Parameters::TARGET_64_LITTLE:
+ this->do_sized_write<64, false>(oview);
+ break;
#endif
- }
- else
- {
#ifdef HAVE_TARGET_64_BIG
- this->do_sized_write<64, true>(oview);
-#else
- gold_unreachable();
+ case Parameters::TARGET_64_BIG:
+ this->do_sized_write<64, true>(oview);
+ break;
#endif
- }
+ default:
+ gold_unreachable();
}
- else
- gold_unreachable();
of->write_output_view(offset, oview_size, oview);
}