// object.cc -- support for an object file for linking in gold
-// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
{
return (shdr->get_sh_size() > 0
&& shdr->get_sh_type() == elfcpp::SHT_PROGBITS
- && shdr->get_sh_flags() == elfcpp::SHF_ALLOC);
+ && (shdr->get_sh_flags() & elfcpp::SHF_ALLOC) != 0);
}
// Return whether there is a GNU .eh_frame section, given the section
const unsigned char* namesu = sd->section_names->data();
const char* names = reinterpret_cast<const char*>(namesu);
- if (this->find_eh_frame(pshdrs, names, sd->section_names_size))
- this->has_eh_frame_ = true;
+ if (memmem(names, sd->section_names_size, ".eh_frame", 10) != NULL)
+ {
+ if (this->find_eh_frame(pshdrs, names, sd->section_names_size))
+ this->has_eh_frame_ = true;
+ }
sd->symbols = NULL;
sd->symbols_size = 0;
if ((flags & elfcpp::GRP_COMDAT) == 0
|| layout->add_comdat(signature, true))
{
- if (parameters->output_is_object())
+ if (parameters->options().relocatable())
layout->layout_group(symtab, this, index, name, signature, shdr,
pword);
return true;
// Keep track of which sections to omit.
std::vector<bool> omit(shnum, false);
- // Keep track of reloc sections when doing a relocatable link.
- const bool output_is_object = parameters->output_is_object();
+ // Keep track of reloc sections when emitting relocations.
+ const bool relocatable = parameters->options().relocatable();
+ const bool emit_relocs = (relocatable
+ || parameters->options().emit_relocs());
std::vector<unsigned int> reloc_sections;
// Keep track of .eh_frame sections.
if (this->handle_gnu_warning_section(name, i, symtab))
{
- if (!output_is_object)
+ if (!relocatable)
omit[i] = true;
}
// ones associated with sections which are not being discarded.
// However, we don't know that yet for all sections. So save
// reloc sections and process them later.
- if (output_is_object
+ if (emit_relocs
&& (shdr.get_sh_type() == elfcpp::SHT_REL
|| shdr.get_sh_type() == elfcpp::SHT_RELA))
{
continue;
}
- if (output_is_object && shdr.get_sh_type() == elfcpp::SHT_GROUP)
+ if (relocatable && shdr.get_sh_type() == elfcpp::SHT_GROUP)
continue;
// The .eh_frame section is special. It holds exception frame
// sections so that the exception frame reader can reliably
// determine which sections are being discarded, and discard the
// corresponding information.
- if (!output_is_object
+ if (!relocatable
&& strcmp(name, ".eh_frame") == 0
&& this->check_eh_frame_flags(&shdr))
{
// When doing a relocatable link handle the reloc sections at the
// end.
- if (output_is_object)
+ if (emit_relocs)
this->size_relocatable_relocs();
for (std::vector<unsigned int>::const_iterator p = reloc_sections.begin();
p != reloc_sections.end();
if (shndx < shnum && mo[shndx].output_section == NULL)
{
lv.set_no_output_symtab_entry();
+ gold_assert(!lv.needs_output_dynsym_entry());
continue;
}
if (sym.get_st_type() == elfcpp::STT_SECTION)
{
lv.set_no_output_symtab_entry();
+ gold_assert(!lv.needs_output_dynsym_entry());
continue;
}
if (shndx >= elfcpp::SHN_LORESERVE)
{
- if (shndx == elfcpp::SHN_ABS)
+ if (shndx == elfcpp::SHN_ABS || shndx == elfcpp::SHN_COMMON)
lv.set_output_value(lv.input_value());
else
{
return this->output_local_dynsym_count_;
}
-// Return the value of the local symbol symndx.
-template<int size, bool big_endian>
-typename elfcpp::Elf_types<size>::Elf_Addr
-Sized_relobj<size, big_endian>::local_symbol_value(unsigned int symndx) const
-{
- gold_assert(symndx < this->local_symbol_count_);
- gold_assert(symndx < this->local_values_.size());
- const Symbol_value<size>& lv(this->local_values_[symndx]);
- return lv.value(this, 0);
-}
-
// Write out the local symbols.
template<int size, bool big_endian>
const Stringpool* sympool,
const Stringpool* dynpool)
{
- if (parameters->strip_all() && this->output_local_dynsym_count_ == 0)
+ if (parameters->options().strip_all()
+ && this->output_local_dynsym_count_ == 0)
return;
gold_assert(this->symtab_shndx_ != -1U);
}
// Write the symbol to the output symbol table.
- if (!parameters->strip_all()
+ if (!parameters->options().strip_all()
&& this->local_values_[i].needs_output_symtab_entry())
{
elfcpp::Sym_write<size, big_endian> osym(ov);
else
{
info->enclosing_symbol_name = symbol_names + sym.get_st_name();
- if (parameters->demangle())
+ if (parameters->options().demangle())
{
char* demangled_name = cplus_demangle(
info->enclosing_symbol_name.c_str(),
{
// Set the global target from the first object file we recognize.
Target* target = obj->target();
- if (!parameters->is_target_valid())
+ if (!parameters->target_valid())
set_parameters_target(target);
- else if (target != parameters->target())
+ else if (target != ¶meters->target())
{
obj->error(_("incompatible target"));
return false;