#include "reloc.h"
#include "descriptors.h"
#include "layout.h"
+#include "plugin.h"
namespace gold
{
Layout::include_section(Sized_relobj<size, big_endian>*, const char* name,
const elfcpp::Shdr<size, big_endian>& shdr)
{
+ if (shdr.get_sh_flags() & elfcpp::SHF_EXCLUDE)
+ return false;
+
switch (shdr.get_sh_type())
{
case elfcpp::SHT_NULL:
&& !is_gdb_debug_section(name))
return false;
}
+ if (parameters->options().strip_lto_sections()
+ && !parameters->options().relocatable()
+ && (shdr.get_sh_flags() & elfcpp::SHF_ALLOC) == 0)
+ {
+ // Ignore LTO sections containing intermediate code.
+ if (is_prefix_of(".gnu.lto_", name))
+ return false;
+ }
return true;
default:
if ((flags & elfcpp::SHF_TLS) != 0)
{
if (this->tls_segment_ == NULL)
- this->tls_segment_ = this->make_output_segment(elfcpp::PT_TLS,
- seg_flags);
+ this->make_output_segment(elfcpp::PT_TLS, seg_flags);
this->tls_segment_->add_output_section(os, seg_flags);
}
{
gold_assert(seg_flags == (elfcpp::PF_R | elfcpp::PF_W));
if (this->relro_segment_ == NULL)
- this->relro_segment_ = this->make_output_segment(elfcpp::PT_GNU_RELRO,
- seg_flags);
+ this->make_output_segment(elfcpp::PT_GNU_RELRO, seg_flags);
this->relro_segment_->add_output_section(os, seg_flags);
}
}
}
if (parameters->options().shared() && this->has_static_tls())
flags |= elfcpp::DF_STATIC_TLS;
+ if (parameters->options().origin())
+ flags |= elfcpp::DF_ORIGIN;
odyn->add_constant(elfcpp::DT_FLAGS, flags);
flags = 0;
flags &= ~(elfcpp::DF_1_INITFIRST
| elfcpp::DF_1_NODELETE
| elfcpp::DF_1_NOOPEN);
+ if (parameters->options().origin())
+ flags |= elfcpp::DF_1_ORIGIN;
if (flags)
odyn->add_constant(elfcpp::DT_FLAGS_1, flags);
}
if (ins.first->second.group_)
{
// We've already seen a real section group with this signature.
+ // If the kept group is from a plugin object, and we're in
+ // the replacement phase, accept the new one as a replacement.
+ if (ins.first->second.object_ == NULL
+ && parameters->options().plugins()->in_replacement_phase())
+ {
+ ins.first->second = kept;
+ return true;
+ }
return false;
}
else if (group)
gold_assert(!parameters->options().relocatable());
Output_segment* oseg = new Output_segment(type, flags);
this->segment_list_.push_back(oseg);
+
+ if (type == elfcpp::PT_TLS)
+ this->tls_segment_ = oseg;
+ else if (type == elfcpp::PT_GNU_RELRO)
+ this->relro_segment_ = oseg;
+
return oseg;
}