// layout.cc -- lay out output file sections for gold
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
return k.first + k.second.first + k.second.second;
}
-// Return whether PREFIX is a prefix of STR.
-
-static inline bool
-is_prefix_of(const char* prefix, const char* str)
-{
- return strncmp(prefix, str, strlen(prefix)) == 0;
-}
-
// Returns whether the given section is in the list of
// debug-sections-used-by-some-version-of-gdb. Currently,
// we've checked versions of gdb up to and including 6.7.1.
// output section.
size_t len = strlen(name);
- if (is_input_section && !parameters->options().relocatable())
+ if (is_input_section
+ && !this->script_options_->saw_sections_clause()
+ && !parameters->options().relocatable())
name = Layout::output_section_name(name, &len);
Stringpool::Key name_key;
return name;
}
-// Record the signature of a comdat section, and return whether to
-// include it in the link. If GROUP is true, this is a regular
-// section group. If GROUP is false, this is a group signature
-// derived from the name of a linkonce section. We want linkonce
-// signatures and group signatures to block each other, but we don't
-// want a linkonce signature to block another linkonce signature.
+// Check if a comdat group or .gnu.linkonce section with the given
+// NAME is selected for the link. If there is already a section,
+// *KEPT_SECTION is set to point to the signature and the function
+// returns false. Otherwise, the CANDIDATE signature is recorded for
+// this NAME in the layout object, *KEPT_SECTION is set to the
+// internal copy and the function return false. In some cases, with
+// CANDIDATE->GROUP_ being false, KEPT_SECTION can point back to
+// CANDIDATE.
bool
-Layout::add_comdat(Relobj* object, unsigned int shndx,
- const std::string& signature, bool group)
+Layout::find_or_add_kept_section(const std::string name,
+ Kept_section* candidate,
+ Kept_section** kept_section)
{
- Kept_section kept(object, shndx, group);
std::pair<Signatures::iterator, bool> ins(
- this->signatures_.insert(std::make_pair(signature, kept)));
+ this->signatures_.insert(std::make_pair(name, *candidate)));
+ if (kept_section)
+ *kept_section = &ins.first->second;
if (ins.second)
{
// This is the first time we've seen this signature.
return true;
}
- if (ins.first->second.group_)
+ if (ins.first->second.is_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
+ if (ins.first->second.object == NULL
&& parameters->options().plugins()->in_replacement_phase())
{
- ins.first->second = kept;
+ ins.first->second = *candidate;
return true;
}
return false;
}
- else if (group)
+ else if (candidate->is_group)
{
// This is a real section group, and we've already seen a
// linkonce section with this signature. Record that we've seen
// a section group, and don't include this section group.
- ins.first->second.group_ = true;
+ ins.first->second.is_group = true;
return false;
}
else
// We've already seen a linkonce section and this is a linkonce
// section. These don't block each other--this may be the same
// symbol name with different section types.
+ *kept_section = candidate;
return true;
}
}
if (p == this->signatures_.end())
return NULL;
if (pshndx != NULL)
- *pshndx = p->second.shndx_;
- return p->second.object_;
+ *pshndx = p->second.shndx;
+ return p->second.object;
}
// Store the allocated sections into the section list.
{
off_t off = this->output_file_size_;
off = this->set_section_offsets(off, POSTPROCESSING_SECTIONS_PASS);
-
+
// Now that we've finalized the names, we can finalize the shstrab.
off =
this->set_section_offsets(off,
void
Write_symbols_task::run(Workqueue*)
{
- this->symtab_->write_globals(this->input_objects_, this->sympool_,
- this->dynpool_, this->layout_->symtab_xindex(),
+ this->symtab_->write_globals(this->sympool_, this->dynpool_,
+ this->layout_->symtab_xindex(),
this->layout_->dynsym_xindex(), this->of_);
}