#include <algorithm>
#include "workqueue.h"
+#include "mapfile.h"
#include "layout.h"
#include "output.h"
#include "symtab.h"
void
Allocate_commons_task::run(Workqueue*)
{
- this->symtab_->allocate_commons(this->layout_);
+ this->symtab_->allocate_commons(this->layout_, this->mapfile_);
}
// This class is used to sort the common symbol by size. We put the
// Allocate the common symbols.
void
-Symbol_table::allocate_commons(Layout* layout)
+Symbol_table::allocate_commons(Layout* layout, Mapfile* mapfile)
{
if (parameters->target().get_size() == 32)
{
#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
- this->do_allocate_commons<32>(layout);
+ this->do_allocate_commons<32>(layout, mapfile);
#else
gold_unreachable();
#endif
else if (parameters->target().get_size() == 64)
{
#if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
- this->do_allocate_commons<64>(layout);
+ this->do_allocate_commons<64>(layout, mapfile);
#else
gold_unreachable();
#endif
template<int size>
void
-Symbol_table::do_allocate_commons(Layout* layout)
+Symbol_table::do_allocate_commons(Layout* layout, Mapfile* mapfile)
{
- this->do_allocate_commons_list<size>(layout, false, &this->commons_);
- this->do_allocate_commons_list<size>(layout, true, &this->tls_commons_);
+ this->do_allocate_commons_list<size>(layout, false, &this->commons_,
+ mapfile);
+ this->do_allocate_commons_list<size>(layout, true, &this->tls_commons_,
+ mapfile);
}
// Allocate the common symbols in a list. IS_TLS indicates whether
template<int size>
void
Symbol_table::do_allocate_commons_list(Layout* layout, bool is_tls,
- Commons_type* commons)
+ Commons_type* commons,
+ Mapfile* mapfile)
{
typedef typename Sized_symbol<size>::Value_type Value_type;
typedef typename Sized_symbol<size>::Size_type Size_type;
// Place them in a newly allocated BSS section.
- Output_data_space *poc = new Output_data_space(addralign);
+ Output_data_space *poc = new Output_data_space(addralign,
+ (is_tls
+ ? "** tls common"
+ : "** common"));
const char* name = ".bss";
elfcpp::Elf_Xword flags = elfcpp::SHF_WRITE | elfcpp::SHF_ALLOC;
if (sym == NULL)
break;
Sized_symbol<size>* ssym = this->get_sized_symbol<size>(sym);
+
+ // Record the symbol in the map file now, before we change its
+ // value. Pass the size in separately so that we don't have to
+ // templatize the map code, which is not performance sensitive.
+ if (mapfile != NULL)
+ mapfile->report_allocate_common(sym, ssym->symsize());
+
off = align_address(off, ssym->value());
ssym->allocate_common(poc, off);
off += ssym->symsize();