public:
Relocate()
: skip_call_tls_get_addr_(false),
- local_dynamic_type_(LOCAL_DYNAMIC_NONE), ldo_addrs_()
+ local_dynamic_type_(LOCAL_DYNAMIC_NONE)
{ }
~Relocate()
unsigned char* view,
section_size_type view_size);
- // Fix up LDO_32 relocations we've already seen.
- void
- fix_up_ldo(const Relocate_info<32, false>*);
-
// We need to keep track of which type of local dynamic relocation
// we have seen, so that we can optimize R_386_TLS_LDO_32 correctly.
enum Local_dynamic_type
// The type of local dynamic relocation we have seen in the section
// being relocated, if any.
Local_dynamic_type local_dynamic_type_;
- // A list of LDO_32 offsets, in case we find LDM after LDO_32.
- std::vector<unsigned char*> ldo_addrs_;
};
// A class which returns the size required for a relocation type,
case elfcpp::R_386_TLS_GOTDESC: // Global-dynamic (from ~oliva url)
case elfcpp::R_386_TLS_DESC_CALL:
- if (this->local_dynamic_type_ == LOCAL_DYNAMIC_NONE)
- this->fix_up_ldo(relinfo);
this->local_dynamic_type_ = LOCAL_DYNAMIC_GNU;
if (optimized_type == tls::TLSOPT_TO_LE)
{
"TLS relocations"));
break;
}
- else if (this->local_dynamic_type_ == LOCAL_DYNAMIC_NONE)
- this->fix_up_ldo(relinfo);
this->local_dynamic_type_ = LOCAL_DYNAMIC_GNU;
if (optimized_type == tls::TLSOPT_TO_LE)
{
break;
case elfcpp::R_386_TLS_LDO_32: // Alternate local-dynamic
- // This reloc can appear in debugging sections, in which case we
- // won't see the TLS_LDM reloc. The local_dynamic_type field
- // tells us this.
if (optimized_type == tls::TLSOPT_TO_LE)
{
- if (this->local_dynamic_type_ != LOCAL_DYNAMIC_NONE)
+ // This reloc can appear in debugging sections, in which
+ // case we must not convert to local-exec. We decide what
+ // to do based on whether the section is marked as
+ // containing executable code. That is what the GNU linker
+ // does as well.
+ elfcpp::Shdr<32, false> shdr(relinfo->data_shdr);
+ if ((shdr.get_sh_flags() & elfcpp::SHF_EXECINSTR) != 0)
{
gold_assert(tls_segment != NULL);
value -= tls_segment->memsz();
}
- else
- {
- // We may see the LDM later.
- this->ldo_addrs_.push_back(view);
- }
}
Relocate_functions<32, false>::rel32(view, value);
break;
Relocate_functions<32, false>::rel32(view, value);
}
-// If we see an LDM reloc after we handled any LDO_32 relocs, fix up
-// the LDO_32 relocs.
-
-void
-Target_i386::Relocate::fix_up_ldo(const Relocate_info<32, false>* relinfo)
-{
- if (this->ldo_addrs_.empty())
- return;
- Output_segment* tls_segment = relinfo->layout->tls_segment();
- gold_assert(tls_segment != NULL);
- elfcpp::Elf_types<32>::Elf_Addr value = - tls_segment->memsz();
- for (std::vector<unsigned char*>::const_iterator p = this->ldo_addrs_.begin();
- p != this->ldo_addrs_.end();
- ++p)
- Relocate_functions<32, false>::rel32(*p, value);
- this->ldo_addrs_.clear();
-}
-
// Relocate section data.
void