object.cc \
options.cc \
output.cc \
+ parameters.cc \
readsyms.cc \
reloc.cc \
resolve.cc \
object.h \
options.h \
output.h \
+ parameters.h \
readsyms.h \
reloc.h \
reloc-types.h \
dirsearch.$(OBJEXT) dynobj.$(OBJEXT) fileread.$(OBJEXT) \
gold.$(OBJEXT) gold-threads.$(OBJEXT) layout.$(OBJEXT) \
merge.$(OBJEXT) object.$(OBJEXT) options.$(OBJEXT) \
- output.$(OBJEXT) readsyms.$(OBJEXT) reloc.$(OBJEXT) \
- resolve.$(OBJEXT) script.$(OBJEXT) symtab.$(OBJEXT) \
- stringpool.$(OBJEXT) target-select.$(OBJEXT) \
+ output.$(OBJEXT) parameters.$(OBJEXT) readsyms.$(OBJEXT) \
+ reloc.$(OBJEXT) resolve.$(OBJEXT) script.$(OBJEXT) \
+ symtab.$(OBJEXT) stringpool.$(OBJEXT) target-select.$(OBJEXT) \
workqueue.$(OBJEXT)
am__objects_2 =
am__objects_3 = yyscript.$(OBJEXT)
object.cc \
options.cc \
output.cc \
+ parameters.cc \
readsyms.cc \
reloc.cc \
resolve.cc \
object.h \
options.h \
output.h \
+ parameters.h \
readsyms.h \
reloc.h \
reloc-types.h \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parameters.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readsyms.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reloc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resolve.Po@am__quote@
#include <vector>
#include "elfcpp.h"
+#include "options.h"
#include "fileread.h"
#include "readsyms.h"
#include "symtab.h"
// may be satisfied by other objects in the archive.
void
-Archive::add_symbols(const General_options& options, Symbol_table* symtab,
- Layout* layout, Input_objects* input_objects)
+Archive::add_symbols(Symbol_table* symtab, Layout* layout,
+ Input_objects* input_objects)
{
if (this->input_file_->options().include_whole_archive())
- return this->include_all_members(options, symtab, layout, input_objects);
+ return this->include_all_members(symtab, layout, input_objects);
const size_t armap_size = this->armap_.size();
last_seen_offset = this->armap_[i].offset;
this->seen_offsets_.insert(last_seen_offset);
this->armap_checked_[i] = true;
- this->include_member(options, symtab, layout, input_objects,
+ this->include_member(symtab, layout, input_objects,
last_seen_offset);
added_new_object = true;
}
// Include all the archive members in the link. This is for --whole-archive.
void
-Archive::include_all_members(const General_options& options,
- Symbol_table* symtab, Layout* layout,
+Archive::include_all_members(Symbol_table* symtab, Layout* layout,
Input_objects* input_objects)
{
off_t off = sarmag;
// Extended name table.
}
else
- this->include_member(options, symtab, layout, input_objects, off);
+ this->include_member(symtab, layout, input_objects, off);
off += sizeof(Archive_header) + size;
if ((off & 1) != 0)
// the member header.
void
-Archive::include_member(const General_options& options, Symbol_table* symtab,
- Layout* layout, Input_objects* input_objects,
- off_t off)
+Archive::include_member(Symbol_table* symtab, Layout* layout,
+ Input_objects* input_objects, off_t off)
{
std::string n;
this->read_header(off, &n);
Read_symbols_data sd;
obj->read_symbols(&sd);
- obj->layout(options, symtab, layout, &sd);
+ obj->layout(symtab, layout, &sd);
obj->add_symbols(symtab, &sd);
}
void
Add_archive_symbols::run(Workqueue*)
{
- this->archive_->add_symbols(this->options_, this->symtab_, this->layout_,
- this->input_objects_);
+ this->archive_->add_symbols(this->symtab_, this->layout_,
+ this->input_objects_);
if (this->input_group_ != NULL)
this->input_group_->add_archive(this->archive_);
namespace gold
{
-class General_options;
class Input_file;
class Input_objects;
class Input_group;
// Select members from the archive as needed and add them to the
// link.
void
- add_symbols(const General_options&, Symbol_table*, Layout*, Input_objects*);
+ add_symbols(Symbol_table*, Layout*, Input_objects*);
private:
Archive(const Archive&);
// Include all the archive members in the link.
void
- include_all_members(const General_options&, Symbol_table*, Layout*,
- Input_objects*);
+ include_all_members(Symbol_table*, Layout*, Input_objects*);
// Include an archive member in the link.
void
- include_member(const General_options&, Symbol_table*, Layout*,
- Input_objects*, off_t off);
+ include_member(Symbol_table*, Layout*, Input_objects*, off_t off);
// An entry in the archive map of symbols to object files.
struct Armap_entry
class Add_archive_symbols : public Task
{
public:
- Add_archive_symbols(const General_options& options, Symbol_table* symtab,
- Layout* layout, Input_objects* input_objects,
+ Add_archive_symbols(Symbol_table* symtab, Layout* layout,
+ Input_objects* input_objects,
Archive* archive, Input_group* input_group,
Task_token* this_blocker,
Task_token* next_blocker)
- : options_(options), symtab_(symtab), layout_(layout),
- input_objects_(input_objects), archive_(archive),
- input_group_(input_group), this_blocker_(this_blocker),
- next_blocker_(next_blocker)
+ : symtab_(symtab), layout_(layout), input_objects_(input_objects),
+ archive_(archive), input_group_(input_group),
+ this_blocker_(this_blocker), next_blocker_(next_blocker)
{ }
~Add_archive_symbols();
private:
class Add_archive_symbols_locker;
- const General_options& options_;
Symbol_table* symtab_;
Layout* layout_;
Input_objects* input_objects_;
#include <cstring>
#include "elfcpp.h"
+#include "parameters.h"
#include "symtab.h"
#include "dynobj.h"
template<int size, bool big_endian>
void
-Sized_dynobj<size, big_endian>::do_layout(const General_options&,
- Symbol_table* symtab,
+Sized_dynobj<size, big_endian>::do_layout(Symbol_table* symtab,
Layout*,
Read_symbols_data* sd)
{
if (!sym->is_from_dynobj())
{
- if (options->is_shared())
+ if (parameters->output_is_shared())
this->add_def(options, sym, version, version_key);
}
else
// If we are creating a shared object, it is an error to
// find a definition of a symbol with a version which is not
// in the version script.
- if (options->is_shared())
+ if (parameters->output_is_shared())
{
fprintf(stderr, _("%s: symbol %s has undefined version %s\n"),
program_name, sym->name(), version);
// pointers.
unsigned int
-Versions::version_index(const General_options* options,
- const Stringpool* dynpool, const Symbol* sym) const
+Versions::version_index(const Stringpool* dynpool, const Symbol* sym) const
{
Stringpool::Key version_key;
const char* version = dynpool->find(sym->version(), &version_key);
Key k;
if (!sym->is_from_dynobj())
{
- if (!options->is_shared())
+ if (!parameters->output_is_shared())
return elfcpp::VER_NDX_GLOBAL;
k = Key(version_key, 0);
}
template<int size, bool big_endian>
void
-Versions::symbol_section_contents(const General_options* options,
- const Stringpool* dynpool,
+Versions::symbol_section_contents(const Stringpool* dynpool,
unsigned int local_symcount,
const std::vector<Symbol*>& syms,
unsigned char** pp,
if (version == NULL)
version_index = elfcpp::VER_NDX_GLOBAL;
else
- version_index = this->version_index(options, dynpool, *p);
+ version_index = this->version_index(dynpool, *p);
elfcpp::Swap<16, big_endian>::writeval(pbuf + (*p)->dynsym_index() * 2,
version_index);
}
template
void
Versions::symbol_section_contents<32, false>(
- const General_options*,
const Stringpool*,
unsigned int,
const std::vector<Symbol*>&,
template
void
Versions::symbol_section_contents<32, true>(
- const General_options*,
const Stringpool*,
unsigned int,
const std::vector<Symbol*>&,
template
void
Versions::symbol_section_contents<64, false>(
- const General_options*,
const Stringpool*,
unsigned int,
const std::vector<Symbol*>&,
template
void
Versions::symbol_section_contents<64, true>(
- const General_options*,
const Stringpool*,
unsigned int,
const std::vector<Symbol*>&,
// Lay out the input sections.
void
- do_layout(const General_options&, Symbol_table*, Layout*,
- Read_symbols_data*);
+ do_layout(Symbol_table*, Layout*, Read_symbols_data*);
// Add the symbols to the symbol table.
void
// version section (.gnu.version).
template<int size, bool big_endian>
void
- symbol_section_contents(const General_options*, const Stringpool*,
- unsigned int local_symcount,
+ symbol_section_contents(const Stringpool*, unsigned int local_symcount,
const std::vector<Symbol*>& syms,
unsigned char**, unsigned int*
ACCEPT_SIZE_ENDIAN) const;
// Return the version index to use for SYM.
unsigned int
- version_index(const General_options*, const Stringpool*,
- const Symbol* sym) const;
+ version_index(const Stringpool*, const Symbol* sym) const;
// We keep a hash table mapping canonicalized name/version pairs to
// a version base.
#include <cstring>
#include "elfcpp.h"
+#include "parameters.h"
#include "reloc.h"
#include "i386.h"
#include "object.h"
// Finalize the sections.
void
- do_finalize_sections(const General_options*, Layout*);
+ do_finalize_sections(Layout*);
// Relocate a section.
void
// Adjust TLS relocation type based on the options and whether this
// is a local symbol.
static unsigned int
- optimize_tls_reloc(const General_options*, bool is_final, int r_type);
+ optimize_tls_reloc(bool is_final, int r_type);
// Get the GOT section, creating it if necessary.
Output_data_got<32, false>*
- got_section(const General_options*, Symbol_table*, Layout*);
+ got_section(Symbol_table*, Layout*);
// Create a PLT entry for a global symbol.
void
- make_plt_entry(const General_options* options, Symbol_table*,
- Layout*, Symbol*);
+ make_plt_entry(Symbol_table*, Layout*, Symbol*);
// Get the PLT section.
Output_data_plt_i386*
// Get the GOT section, creating it if necessary.
Output_data_got<32, false>*
-Target_i386::got_section(const General_options* options, Symbol_table* symtab,
- Layout* layout)
+Target_i386::got_section(Symbol_table* symtab, Layout* layout)
{
if (this->got_ == NULL)
{
- gold_assert(options != NULL && symtab != NULL && layout != NULL);
+ gold_assert(symtab != NULL && layout != NULL);
- this->got_ = new Output_data_got<32, false>(options);
+ this->got_ = new Output_data_got<32, false>();
layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE,
public:
typedef Output_data_reloc<elfcpp::SHT_REL, true, 32, false> Reloc_section;
- Output_data_plt_i386(Layout*, Output_data_space*, bool is_shared);
+ Output_data_plt_i386(Layout*, Output_data_space*);
// Add an entry to the PLT.
void
Output_data_space* got_plt_;
// The number of PLT entries.
unsigned int count_;
- // Whether we are generated a shared object.
- bool is_shared_;
};
// Create the PLT section. The ordinary .got section is an argument,
// section just for PLT entries.
Output_data_plt_i386::Output_data_plt_i386(Layout* layout,
- Output_data_space* got_plt,
- bool is_shared)
- : Output_section_data(4), got_plt_(got_plt), is_shared_(is_shared)
+ Output_data_space* got_plt)
+ : Output_section_data(4), got_plt_(got_plt)
{
this->rel_ = new Reloc_section();
layout->add_output_section_data(".rel.plt", elfcpp::SHT_REL,
elfcpp::Elf_types<32>::Elf_Addr plt_address = this->address();
elfcpp::Elf_types<32>::Elf_Addr got_address = this->got_plt_->address();
- if (this->is_shared_)
+ if (parameters->output_is_shared())
memcpy(pov, dyn_first_plt_entry, plt_entry_size);
else
{
{
// Set and adjust the PLT entry itself.
- if (this->is_shared_)
+ if (parameters->output_is_shared())
{
memcpy(pov, dyn_plt_entry, plt_entry_size);
elfcpp::Swap_unaligned<32, false>::writeval(pov + 2, got_offset);
// Create a PLT entry for a global symbol.
void
-Target_i386::make_plt_entry(const General_options* options,
- Symbol_table* symtab, Layout* layout, Symbol* gsym)
+Target_i386::make_plt_entry(Symbol_table* symtab, Layout* layout, Symbol* gsym)
{
if (gsym->has_plt_offset())
return;
if (this->plt_ == NULL)
{
// Create the GOT sections first.
- this->got_section(options, symtab, layout);
+ this->got_section(symtab, layout);
- this->plt_ = new Output_data_plt_i386(layout, this->got_plt_,
- options->is_shared());
+ this->plt_ = new Output_data_plt_i386(layout, this->got_plt_);
layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
(elfcpp::SHF_ALLOC
| elfcpp::SHF_EXECINSTR),
// known at link time.
unsigned int
-Target_i386::optimize_tls_reloc(const General_options* options,
- bool is_final,
- int r_type)
+Target_i386::optimize_tls_reloc(bool is_final, int r_type)
{
// If we are generating a shared library, then we can't do anything
// in the linker.
- if (options->is_shared())
+ if (parameters->output_is_shared())
return r_type;
switch (r_type)
// Scan a relocation for a local symbol.
inline void
-Target_i386::Scan::local(const General_options& options,
+Target_i386::Scan::local(const General_options&,
Symbol_table* symtab,
Layout* layout,
Target_i386* target,
case elfcpp::R_386_8:
// FIXME: If we are generating a shared object we need to copy
// this relocation into the object.
- gold_assert(!options.is_shared());
+ gold_assert(!parameters->output_is_shared());
break;
case elfcpp::R_386_PC32:
case elfcpp::R_386_GOTOFF:
case elfcpp::R_386_GOTPC:
// We need a GOT section.
- target->got_section(&options, symtab, layout);
+ target->got_section(symtab, layout);
break;
case elfcpp::R_386_COPY:
case elfcpp::R_386_TLS_LE_32:
case elfcpp::R_386_TLS_GOTDESC:
case elfcpp::R_386_TLS_DESC_CALL:
- r_type = Target_i386::optimize_tls_reloc(&options,
- !options.is_shared(),
- r_type);
- switch (r_type)
- {
- case elfcpp::R_386_TLS_LE:
- case elfcpp::R_386_TLS_LE_32:
- // FIXME: If generating a shared object, we need to copy
- // this relocation into the object.
- gold_assert(!options.is_shared());
- break;
+ {
+ bool output_is_executable = parameters->output_is_executable();
+ r_type = Target_i386::optimize_tls_reloc(output_is_executable,
+ r_type);
+ switch (r_type)
+ {
+ case elfcpp::R_386_TLS_LE:
+ case elfcpp::R_386_TLS_LE_32:
+ // FIXME: If generating a shared object, we need to copy
+ // this relocation into the object.
+ gold_assert(output_is_executable);
+ break;
- case elfcpp::R_386_TLS_IE:
- case elfcpp::R_386_TLS_GOTIE:
- case elfcpp::R_386_TLS_GD:
- case elfcpp::R_386_TLS_LDM:
- case elfcpp::R_386_TLS_LDO_32:
- case elfcpp::R_386_TLS_IE_32:
- case elfcpp::R_386_TLS_GOTDESC:
- case elfcpp::R_386_TLS_DESC_CALL:
- fprintf(stderr,
- _("%s: %s: unsupported reloc %u against local symbol\n"),
- program_name, object->name().c_str(), r_type);
- break;
- }
+ case elfcpp::R_386_TLS_IE:
+ case elfcpp::R_386_TLS_GOTIE:
+ case elfcpp::R_386_TLS_GD:
+ case elfcpp::R_386_TLS_LDM:
+ case elfcpp::R_386_TLS_LDO_32:
+ case elfcpp::R_386_TLS_IE_32:
+ case elfcpp::R_386_TLS_GOTDESC:
+ case elfcpp::R_386_TLS_DESC_CALL:
+ fprintf(stderr,
+ _("%s: %s: unsupported reloc %u against local symbol\n"),
+ program_name, object->name().c_str(), r_type);
+ break;
+ }
+ }
break;
case elfcpp::R_386_GOT32:
// copy this relocation into the object. If this symbol is
// defined in a shared object, we may need to copy this
// relocation in order to avoid a COPY relocation.
- gold_assert(!options.is_shared());
+ gold_assert(!parameters->output_is_shared());
if (gsym->is_from_dynobj())
{
// function, we make a PLT entry. Otherwise we need to
// either generate a COPY reloc or copy this reloc.
if (gsym->type() == elfcpp::STT_FUNC)
- target->make_plt_entry(&options, symtab, layout, gsym);
+ target->make_plt_entry(symtab, layout, gsym);
else
target->copy_reloc(&options, symtab, layout, object, data_shndx,
gsym, reloc);
case elfcpp::R_386_GOT32:
{
// The symbol requires a GOT entry.
- Output_data_got<32, false>* got = target->got_section(&options, symtab,
- layout);
+ Output_data_got<32, false>* got = target->got_section(symtab, layout);
if (got->add_global(gsym))
{
// If this symbol is not fully resolved, we need to add a
// dynamic relocation for it.
- if (!gsym->final_value_is_known(&options))
+ if (!gsym->final_value_is_known())
{
Reloc_section* rel_dyn = target->rel_dyn_section(layout);
rel_dyn->add_global(gsym, elfcpp::R_386_GLOB_DAT, got,
case elfcpp::R_386_PLT32:
// If the symbol is fully resolved, this is just a PC32 reloc.
// Otherwise we need a PLT entry.
- if (gsym->final_value_is_known(&options))
+ if (gsym->final_value_is_known())
break;
- target->make_plt_entry(&options, symtab, layout, gsym);
+ target->make_plt_entry(symtab, layout, gsym);
break;
case elfcpp::R_386_GOTOFF:
case elfcpp::R_386_GOTPC:
// We need a GOT section.
- target->got_section(&options, symtab, layout);
+ target->got_section(symtab, layout);
break;
case elfcpp::R_386_COPY:
case elfcpp::R_386_TLS_GOTDESC:
case elfcpp::R_386_TLS_DESC_CALL:
{
- const bool is_final = gsym->final_value_is_known(&options);
- r_type = Target_i386::optimize_tls_reloc(&options, is_final, r_type);
+ const bool is_final = gsym->final_value_is_known();
+ r_type = Target_i386::optimize_tls_reloc(is_final, r_type);
switch (r_type)
{
case elfcpp::R_386_TLS_LE:
case elfcpp::R_386_TLS_LE_32:
// FIXME: If generating a shared object, we need to copy
// this relocation into the object.
- gold_assert(!options.is_shared());
+ gold_assert(!parameters->output_is_shared());
break;
case elfcpp::R_386_TLS_IE:
// Finalize the sections.
void
-Target_i386::do_finalize_sections(const General_options* options,
- Layout* layout)
+Target_i386::do_finalize_sections(Layout* layout)
{
// Fill in some more dynamic tags.
Output_data_dynamic* const odyn = layout->dynamic_data();
elfcpp::Elf_sizes<32>::rel_size);
}
- if (!options->is_shared())
+ if (!parameters->output_is_shared())
{
// The value of the DT_DEBUG tag is filled in by the dynamic
// linker at run time, and used by the debugger.
case elfcpp::R_386_PLT32:
gold_assert(gsym->has_plt_offset()
- || gsym->final_value_is_known(relinfo->options));
+ || gsym->final_value_is_known());
Relocate_functions<32, false>::pcrel32(view, object, psymval, address);
break;
{
elfcpp::Elf_types<32>::Elf_Addr value;
value = (psymval->value(object, 0)
- - target->got_section(NULL, NULL, NULL)->address());
+ - target->got_section(NULL, NULL)->address());
Relocate_functions<32, false>::rel32(view, value);
}
break;
case elfcpp::R_386_GOTPC:
{
elfcpp::Elf_types<32>::Elf_Addr value;
- value = target->got_section(NULL, NULL, NULL)->address();
+ value = target->got_section(NULL, NULL)->address();
Relocate_functions<32, false>::pcrel32(view, value, address);
}
break;
elfcpp::Elf_types<32>::Elf_Addr value = psymval->value(relinfo->object, 0);
const bool is_final = (gsym == NULL
- ? !relinfo->options->is_shared()
- : gsym->final_value_is_known(relinfo->options));
+ ? !parameters->output_is_shared()
+ : gsym->final_value_is_known());
const unsigned int opt_r_type =
- Target_i386::optimize_tls_reloc(relinfo->options, is_final, r_type);
+ Target_i386::optimize_tls_reloc(is_final, r_type);
switch (r_type)
{
case elfcpp::R_386_TLS_LE_32:
#include <iostream>
#include <utility>
+#include "parameters.h"
#include "output.h"
#include "symtab.h"
#include "dynobj.h"
case elfcpp::SHT_RELA:
case elfcpp::SHT_REL:
case elfcpp::SHT_GROUP:
- return this->options_.is_relocatable();
+ return parameters->output_is_object();
default:
// FIXME: Handle stripping debug sections here.
// If we are not doing a relocateable link, choose the name to use
// for the output section.
size_t len = strlen(name);
- if (!this->options_.is_relocatable())
+ if (!parameters->output_is_object())
name = Layout::output_section_name(name, &len);
// FIXME: Handle SHF_OS_NONCONFORMING here.
Target* const target = input_objects->target();
const int size = target->get_size();
- target->finalize_sections(&this->options_, this);
+ target->finalize_sections(this);
Output_segment* phdr_seg = NULL;
if (input_objects->any_dynamic())
Output_file_header* file_header;
file_header = new Output_file_header(size,
big_endian,
- this->options_,
target,
symtab,
segment_headers);
unsigned char* vbuf;
unsigned int vsize;
versions->symbol_section_contents SELECT_SIZE_ENDIAN_NAME(size, big_endian)(
- &this->options_, &this->dynpool_, local_symcount, dynamic_symbols,
- &vbuf, &vsize SELECT_SIZE_ENDIAN(size, big_endian));
+ &this->dynpool_, local_symcount, dynamic_symbols, &vbuf, &vsize
+ SELECT_SIZE_ENDIAN(size, big_endian));
Output_section_data* vdata = new Output_data_const_buffer(vbuf, vsize, 2);
#include "gold.h"
#include "options.h"
+#include "parameters.h"
#include "dirsearch.h"
#include "workqueue.h"
#include "object.h"
// Handle the command line options.
Command_line command_line;
command_line.process(argc - 1, argv + 1);
+ initialize_parameters(&command_line.options());
// The work queue.
Workqueue workqueue(command_line.options());
template<int size, bool big_endian>
void
-Sized_relobj<size, big_endian>::do_layout(const General_options& options,
- Symbol_table* symtab,
+Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
Layout* layout,
Read_symbols_data* sd)
{
if (this->handle_gnu_warning_section(name, i, symtab))
{
- if (!options.is_relocatable())
+ if (!parameters->output_is_object())
omit[i] = true;
}
// Pass sections which should be included in the link to the Layout
// object, and record where the sections go in the output file.
void
- layout(const General_options& options, Symbol_table* symtab,
- Layout* layout, Read_symbols_data* sd)
- { this->do_layout(options, symtab, layout, sd); }
+ layout(Symbol_table* symtab, Layout* layout, Read_symbols_data* sd)
+ { this->do_layout(symtab, layout, sd); }
// Add symbol information to the global symbol table.
void
// Lay out sections--implemented by child class.
virtual void
- do_layout(const General_options&, Symbol_table*, Layout*,
- Read_symbols_data*) = 0;
+ do_layout(Symbol_table*, Layout*, Read_symbols_data*) = 0;
// Add symbol information to the global symbol table--implemented by
// child class.
// Lay out the input sections.
void
- do_layout(const General_options&, Symbol_table*, Layout*,
- Read_symbols_data*);
+ do_layout(Symbol_table*, Layout*, Read_symbols_data*);
// Add the symbols to the symbol table.
void
#include <sys/mman.h>
#include <algorithm>
+#include "parameters.h"
#include "object.h"
#include "symtab.h"
#include "reloc.h"
Output_file_header::Output_file_header(int size,
bool big_endian,
- const General_options& options,
const Target* target,
const Symbol_table* symtab,
const Output_segment_headers* osh)
: size_(size),
big_endian_(big_endian),
- options_(options),
target_(target),
symtab_(symtab),
segment_header_(osh),
elfcpp::ET e_type;
// FIXME: ET_DYN.
- if (this->options_.is_relocatable())
+ if (parameters->output_is_object())
e_type = elfcpp::ET_REL;
else
e_type = elfcpp::ET_EXEC;
template<int size, bool big_endian>
void
-Output_data_got<size, big_endian>::Got_entry::write(
- const General_options* options,
- unsigned char* pov) const
+Output_data_got<size, big_endian>::Got_entry::write(unsigned char* pov) const
{
Valtype val = 0;
// value. Otherwise we just write zero. The target code is
// responsible for creating a relocation entry to fill in the
// value at runtime.
- if (gsym->final_value_is_known(options))
+ if (gsym->final_value_is_known())
{
Sized_symbol<size>* sgsym;
// This cast is a bit ugly. We don't want to put a
p != this->entries_.end();
++p)
{
- p->write(this->options_, pov);
+ p->write(pov);
pov += add;
}
{
this->file_size_ = file_size;
- int mode = this->options_.is_relocatable() ? 0666 : 0777;
+ int mode = parameters->output_is_object() ? 0666 : 0777;
int o = ::open(this->name_, O_RDWR | O_CREAT | O_TRUNC, mode);
if (o < 0)
{
public:
Output_file_header(int size,
bool big_endian,
- const General_options&,
const Target*,
const Symbol_table*,
const Output_segment_headers*);
int size_;
bool big_endian_;
- const General_options& options_;
const Target* target_;
const Symbol_table* symtab_;
const Output_segment_headers* segment_header_;
public:
typedef typename elfcpp::Elf_types<size>::Elf_Addr Valtype;
- Output_data_got(const General_options* options)
- : Output_section_data(Output_data::default_alignment(size)),
- options_(options), entries_()
+ Output_data_got()
+ : Output_section_data(Output_data::default_alignment(size)), entries_()
{ }
// Add an entry for a global symbol to the GOT. Return true if this
// Write the GOT entry to an output view.
void
- write(const General_options*, unsigned char* pov) const;
+ write(unsigned char* pov) const;
private:
enum
set_got_size()
{ this->set_data_size(this->got_offset(this->entries_.size())); }
- // Options.
- const General_options* options_;
// The list of GOT entries.
Got_entries entries_;
};
--- /dev/null
+// parameters.cc -- general parameters for a link using gold
+
+#include "gold.h"
+
+#include "options.h"
+#include "parameters.h"
+
+namespace gold
+{
+
+// Initialize the parameters from the options.
+
+Parameters::Parameters(const General_options* options)
+ : optimization_level_(options->optimization_level())
+{
+ if (options->is_shared())
+ this->output_file_type_ = OUTPUT_SHARED;
+ else if (options->is_relocatable())
+ this->output_file_type_ = OUTPUT_OBJECT;
+ else
+ this->output_file_type_ = OUTPUT_EXECUTABLE;
+}
+
+// The global variable.
+
+const Parameters* parameters;
+
+// Initialize the global variable.
+
+void
+initialize_parameters(const General_options* options)
+{
+ parameters = new Parameters(options);
+}
+
+} // End namespace gold.
--- /dev/null
+// parameters.h -- general parameters for a link using gold -*- C++ -*-
+
+#ifndef GOLD_PARAMETERS_H
+#define GOLD_PARAMETERS_H
+
+namespace gold
+{
+
+class General_options;
+
+// Here we define the Parameters class which simply holds simple
+// general parameters which apply to the entire link. We use a global
+// variable for this. This is in contrast to the General_options
+// class, which holds the complete state of position independent
+// command line options. The hope is that Parameters will stay fairly
+// simple, so that if this turns into a library it will be clear how
+// these parameters should be set.
+
+class Parameters
+{
+ public:
+ Parameters(const General_options*);
+
+ // Whether we are generating a regular executable.
+ bool
+ output_is_executable() const
+ { return this->output_file_type_ == OUTPUT_EXECUTABLE; }
+
+ // Whether we are generating a shared library.
+ bool
+ output_is_shared() const
+ { return this->output_file_type_ == OUTPUT_SHARED; }
+
+ // Whether we are generating an object file.
+ bool
+ output_is_object() const
+ { return this->output_file_type_ == OUTPUT_OBJECT; }
+
+ // The general linker optimization level.
+ int
+ optimization_level() const
+ { return this->optimization_level_; }
+
+ private:
+ // The types of output files.
+ enum Output_file_type
+ {
+ // Generating executable.
+ OUTPUT_EXECUTABLE,
+ // Generating shared library.
+ OUTPUT_SHARED,
+ // Generating object file.
+ OUTPUT_OBJECT
+ };
+
+ // The type of the output file.
+ Output_file_type output_file_type_;
+ // The optimization level.
+ int optimization_level_;
+};
+
+// This is a global variable.
+extern const Parameters* parameters;
+
+// Initialize the global variable.
+extern void initialize_parameters(const General_options*);
+
+} // End namespace gold.
+
+#endif // !defined(GOLD_PARAMATERS_H)
options.h
output.cc
output.h
+parameters.cc
+parameters.h
readsyms.cc
readsyms.h
reloc.cc
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-05-16 10:40-0700\n"
+"POT-Creation-Date: 2007-09-21 00:18-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: archive.cc:62
+#: archive.cc:69
#, c-format
msgid "%s: %s: no archive symbol table (run ranlib)\n"
msgstr ""
-#: archive.cc:91
+#: archive.cc:121
#, c-format
msgid "%s: %s: bad archive symbol table names\n"
msgstr ""
-#: archive.cc:129
+#: archive.cc:153
#, c-format
msgid "%s; %s: malformed archive header at %ld\n"
msgstr ""
-#: archive.cc:150
+#: archive.cc:174
#, c-format
msgid "%s: %s: malformed archive header size at %ld\n"
msgstr ""
-#: archive.cc:162
+#: archive.cc:186
#, c-format
msgid "%s: %s: malformed archive header name at %ld\n"
msgstr ""
-#: archive.cc:188
+#: archive.cc:212
#, c-format
msgid "%s: %s: bad extended name index at %ld\n"
msgstr ""
-#: archive.cc:199
+#: archive.cc:223
#, c-format
msgid "%s: %s: bad extended name entry at header %ld\n"
msgstr ""
-#: archive.cc:280 archive.cc:293
+#: archive.cc:318
+#, c-format
+msgid "%s: %s: short archive header at %ld\n"
+msgstr ""
+
+#: archive.cc:367 archive.cc:380
#, c-format
msgid "%s: %s: member at %ld is not an ELF object"
msgstr ""
msgid "can not read directory %s"
msgstr ""
-#: dynobj.cc:109
+#: dynobj.cc:110
#, c-format
msgid "%s: %s: unexpected duplicate type %u section: %u, %u\n"
msgstr ""
-#: dynobj.cc:150
+#: dynobj.cc:151
#, c-format
msgid "%s: %s: unexpected link in section %u header: %u != %u\n"
msgstr ""
-#: dynobj.cc:188
+#: dynobj.cc:189
#, c-format
msgid "%s: %s: DYNAMIC section %u link out of range: %u\n"
msgstr ""
-#: dynobj.cc:198
+#: dynobj.cc:199
#, c-format
msgid "%s: %s: DYNAMIC section %u link %u is not a strtab\n"
msgstr ""
-#: dynobj.cc:220
+#: dynobj.cc:221
#, c-format
msgid "%s: %s: DT_SONAME value out of range: %lld >= %lld\n"
msgstr ""
-#: dynobj.cc:237
+#: dynobj.cc:238
#, c-format
msgid "%s: %s: missing DT_NULL in dynamic segment\n"
msgstr ""
-#: dynobj.cc:285
+#: dynobj.cc:286
#, c-format
msgid "%s: %s: invalid dynamic symbol table name index: %u\n"
msgstr ""
-#: dynobj.cc:293
+#: dynobj.cc:294
#, c-format
msgid "%s: %s: dynamic symbol table name section has wrong type: %u\n"
msgstr ""
-#: dynobj.cc:368 object.cc:420
+#: dynobj.cc:368 object.cc:419
#, c-format
msgid "%s: %s: bad section name offset for section %u: %lu\n"
msgstr ""
msgid "%s: %s: size of dynamic symbols is not multiple of symbol size\n"
msgstr ""
-#: dynobj.cc:1241
+#: dynobj.cc:1244
#, c-format
msgid "%s: symbol %s has undefined version %s\n"
msgstr ""
msgstr ""
#. FIXME: This needs to specify the location somehow.
-#: i386.cc:100
+#: i386.cc:105
#, c-format
msgid "%s: missing expected TLS relocation\n"
msgstr ""
-#: i386.cc:729 i386.cc:870 i386.cc:1136
+#: i386.cc:726 i386.cc:876 i386.cc:1138
#, c-format
msgid "%s: %s: unexpected reloc %u in object file\n"
msgstr ""
-#: i386.cc:765 i386.cc:784
+#: i386.cc:763 i386.cc:783
#, c-format
msgid "%s: %s: unsupported reloc %u against local symbol\n"
msgstr ""
-#: i386.cc:906 i386.cc:927
+#: i386.cc:912 i386.cc:933
#, c-format
msgid "%s: %s: unsupported reloc %u against global symbol %s\n"
msgstr ""
-#: i386.cc:950
+#: i386.cc:956
#, c-format
msgid "%s: %s: unsupported RELA reloc section\n"
msgstr ""
-#: i386.cc:1041
+#: i386.cc:1046
#, c-format
msgid "%s: %s: missing expected TLS relocation\n"
msgstr ""
-#: i386.cc:1168 i386.cc:1245 i386.cc:1256
+#: i386.cc:1170 i386.cc:1247 i386.cc:1258
#, c-format
msgid "%s: %s: unsupported reloc %u\n"
msgstr ""
-#: i386.cc:1195
+#: i386.cc:1197
#, c-format
msgid "%s: %s: TLS reloc but no TLS segment\n"
msgstr ""
-#: i386.cc:1230
+#: i386.cc:1232
#, c-format
msgid "%s: %s: unsupported reloc type %u\n"
msgstr ""
-#: i386.cc:1439
+#: i386.cc:1441
#, c-format
msgid "%s: %s: TLS relocation out of range\n"
msgstr ""
-#: i386.cc:1457
+#: i386.cc:1459
#, c-format
msgid "%s: %s: TLS relocation against invalid instruction\n"
msgstr ""
msgid "%s: %s: unsupported ELF file type %d\n"
msgstr ""
-#: object.cc:853 object.cc:906 object.cc:927
+#: object.cc:853 object.cc:906 object.cc:941
#, c-format
msgid "%s: %s: ELF file too short\n"
msgstr ""
msgid "%s: %s: unsupported ELF data encoding %d\n"
msgstr ""
+#: object.cc:918
+#, c-format
+msgid "%s: %s: not configured to support 32-bit big-endian object\n"
+msgstr ""
+
+#: object.cc:931
+#, c-format
+msgid "%s: %s: not configured to support 32-bit little-endian object\n"
+msgstr ""
+
+#: object.cc:953
+#, c-format
+msgid "%s: %s: not configured to support 64-bit big-endian object\n"
+msgstr ""
+
+#: object.cc:966
+#, c-format
+msgid "%s: %s: not configured to support 64-bit little-endian object\n"
+msgstr ""
+
#: options.cc:115
#, c-format
msgid ""
"Options:\n"
msgstr ""
-#: options.cc:227
+#: options.cc:230
msgid "Search for library LIBNAME"
msgstr ""
-#: options.cc:228
-msgid "-lLIBNAME --library LIBNAME"
+#: options.cc:231
+msgid "-lLIBNAME, --library LIBNAME"
msgstr ""
-#: options.cc:230
+#: options.cc:233
msgid "Start a library search group"
msgstr ""
-#: options.cc:232
+#: options.cc:235
msgid "End a library search group"
msgstr ""
-#: options.cc:234
+#: options.cc:237
+msgid "Export all dynamic symbols"
+msgstr ""
+
+#: options.cc:239
msgid "Set dynamic linker path"
msgstr ""
-#: options.cc:235
+#: options.cc:240
msgid "-I PROGRAM, --dynamic-linker PROGRAM"
msgstr ""
-#: options.cc:237
+#: options.cc:242
msgid "Add directory to search path"
msgstr ""
-#: options.cc:238
+#: options.cc:243
msgid "-L DIR, --library-path DIR"
msgstr ""
-#: options.cc:240
+#: options.cc:245
msgid "Ignored for compatibility"
msgstr ""
-#: options.cc:242
+#: options.cc:247
+msgid "Optimize output file size"
+msgstr ""
+
+#: options.cc:248
+msgid "-O level"
+msgstr ""
+
+#: options.cc:250
msgid "Set output file name"
msgstr ""
-#: options.cc:243
+#: options.cc:251
msgid "-o FILE, --output FILE"
msgstr ""
-#: options.cc:245
+#: options.cc:253
msgid "Generate relocatable output"
msgstr ""
-#: options.cc:247
+#: options.cc:255
+msgid "Add DIR to runtime search path"
+msgstr ""
+
+#: options.cc:256
+msgid "-R DIR, -rpath DIR"
+msgstr ""
+
+#: options.cc:258
+msgid "Create exception frame header"
+msgstr ""
+
+#: options.cc:261
+msgid "Add DIR to link time shared library search path"
+msgstr ""
+
+#: options.cc:262
+msgid "--rpath-link DIR"
+msgstr ""
+
+#: options.cc:264
msgid "Generate shared library"
msgstr ""
-#: options.cc:249
+#: options.cc:266
msgid "Do not link against shared libraries"
msgstr ""
-#: options.cc:252
-msgid "Only set DT_NEEDED for following dynamic libs if used"
+#: options.cc:269
+msgid "Only set DT_NEEDED for dynamic libs if used"
msgstr ""
-#: options.cc:255
-msgid "Always DT_NEEDED for following dynamic libs (default)"
+#: options.cc:272
+msgid "Always DT_NEEDED for dynamic libs (default)"
msgstr ""
-#: options.cc:257
+#: options.cc:275
+msgid "Include all archive contents"
+msgstr ""
+
+#: options.cc:279
+msgid "Include only needed archive contents"
+msgstr ""
+
+#: options.cc:282
msgid "Report usage information"
msgstr ""
-#: options.cc:393 options.cc:444 options.cc:523
+#: options.cc:425 options.cc:476 options.cc:555
msgid "missing argument"
msgstr ""
-#: options.cc:406 options.cc:453
+#: options.cc:438 options.cc:485
msgid "unknown option"
msgstr ""
-#: options.cc:461
+#: options.cc:493
#, c-format
msgid "%s: missing group end"
msgstr ""
-#: options.cc:536
+#: options.cc:568
msgid "may not nest groups"
msgstr ""
-#: options.cc:546
+#: options.cc:578
msgid "group end without group start"
msgstr ""
-#: options.cc:556
+#: options.cc:588
#, c-format
msgid "%s: use the --help option for usage information\n"
msgstr ""
-#: options.cc:565 script.cc:1133
+#: options.cc:597 script.cc:1133
#, c-format
msgid "%s: %s: %s\n"
msgstr ""
-#: options.cc:574
+#: options.cc:606
#, c-format
msgid "%s: -%c: %s\n"
msgstr ""
-#: output.cc:903
+#: output.cc:901
#, c-format
msgid "%s: %s: invalid alignment %lu for section \"%s\"\n"
msgstr ""
-#: output.cc:1519
+#: output.cc:1550
#, c-format
msgid "%s: %s: open: %s\n"
msgstr ""
-#: output.cc:1528
+#: output.cc:1559
#, c-format
msgid "%s: %s: lseek: %s\n"
msgstr ""
-#: output.cc:1535
+#: output.cc:1566
#, c-format
msgid "%s: %s: write: %s\n"
msgstr ""
-#: output.cc:1545
+#: output.cc:1576
#, c-format
msgid "%s: %s: mmap: %s\n"
msgstr ""
-#: output.cc:1559
+#: output.cc:1590
#, c-format
msgid "%s: %s: munmap: %s\n"
msgstr ""
-#: output.cc:1567
+#: output.cc:1598
#, c-format
msgid "%s: %s: close: %s\n"
msgstr ""
msgid "%s: %s: ordinary object found in input group\n"
msgstr ""
-#: readsyms.cc:136
+#: readsyms.cc:134
#, c-format
msgid "%s: %s: file is empty\n"
msgstr ""
#. Here we have to handle any other input file types we need.
-#: readsyms.cc:149
+#: readsyms.cc:147
#, c-format
msgid "%s: %s: not an object or archive\n"
msgstr ""
msgid "%s: %s: reloc section %u size %lu uneven"
msgstr ""
-#: resolve.cc:147
+#: resolve.cc:117
#, c-format
msgid "%s: %s: invalid STB_LOCAL symbol %s in external symbols\n"
msgstr ""
-#: resolve.cc:153
+#: resolve.cc:123
#, c-format
msgid "%s: %s: unsupported symbol binding %d for symbol %s\n"
msgstr ""
-#: symtab.cc:450 symtab.cc:547
+#: symtab.cc:456 symtab.cc:553
#, c-format
msgid "%s: %s: mixing 32-bit and 64-bit ELF objects\n"
msgstr ""
-#: symtab.cc:467
+#: symtab.cc:473
#, c-format
msgid "%s: %s: bad global symbol name offset %u at %lu\n"
msgstr ""
-#: symtab.cc:554
+#: symtab.cc:560
#, c-format
msgid "%s: %s: too few symbol versions\n"
msgstr ""
-#: symtab.cc:574
+#: symtab.cc:580
#, c-format
msgid "%s: %s: bad symbol name offset %u at %lu\n"
msgstr ""
-#: symtab.cc:618
+#: symtab.cc:633
#, c-format
msgid "%s: %s: versym for symbol %zu out of range: %u\n"
msgstr ""
-#: symtab.cc:626
+#: symtab.cc:641
#, c-format
msgid "%s: %s: versym for symbol %zu has no name: %u\n"
msgstr ""
-#: symtab.cc:1106 symtab.cc:1278
+#: symtab.cc:1174 symtab.cc:1346
#, c-format
msgid "%s: %s: unsupported symbol section 0x%x\n"
msgstr ""
-#: symtab.cc:1471
+#: symtab.cc:1539
#, c-format
msgid "%s: %s: warning: %s\n"
msgstr ""
Read_symbols_data* sd = new Read_symbols_data;
obj->read_symbols(sd);
- workqueue->queue_front(new Add_symbols(this->options_,
- this->input_objects_,
+ workqueue->queue_front(new Add_symbols(this->input_objects_,
this->symtab_, this->layout_,
obj, sd,
this->this_blocker_,
Archive* arch = new Archive(this->input_argument_->file().name(),
input_file);
arch->setup();
- workqueue->queue(new Add_archive_symbols(this->options_,
- this->symtab_,
+ workqueue->queue(new Add_archive_symbols(this->symtab_,
this->layout_,
this->input_objects_,
arch,
}
const int saw_undefined = this->symtab_->saw_undefined();
- workqueue->queue(new Finish_group(this->options_,
- this->input_objects_,
+ workqueue->queue(new Finish_group(this->input_objects_,
this->symtab_,
this->layout_,
input_group,
}
else
{
- this->object_->layout(this->options_, this->symtab_, this->layout_,
- this->sd_);
+ this->object_->layout(this->symtab_, this->layout_, this->sd_);
this->object_->add_symbols(this->symtab_, this->sd_);
}
delete this->sd_;
{
Task_lock_obj<Archive> tl(**p);
- (*p)->add_symbols(this->options_, this->symtab_, this->layout_,
+ (*p)->add_symbols(this->symtab_, this->layout_,
this->input_objects_);
}
}
// THIS_BLOCKER is used to prevent this task from running before the
// one for the previous input file. NEXT_BLOCKER is used to prevent
// the next task from running.
- Add_symbols(const General_options& options, Input_objects* input_objects,
- Symbol_table* symtab, Layout* layout, Object* object,
+ Add_symbols(Input_objects* input_objects, Symbol_table* symtab,
+ Layout* layout, Object* object,
Read_symbols_data* sd, Task_token* this_blocker,
Task_token* next_blocker)
- : options_(options), input_objects_(input_objects), symtab_(symtab),
- layout_(layout), object_(object), sd_(sd), this_blocker_(this_blocker),
+ : input_objects_(input_objects), symtab_(symtab), layout_(layout),
+ object_(object), sd_(sd), this_blocker_(this_blocker),
next_blocker_(next_blocker)
{ }
private:
class Add_symbols_locker;
- const General_options& options_;
Input_objects* input_objects_;
Symbol_table* symtab_;
Layout* layout_;
class Finish_group : public Task
{
public:
- Finish_group(const General_options& options, Input_objects* input_objects,
- Symbol_table* symtab, Layout* layout, Input_group* input_group,
+ Finish_group(Input_objects* input_objects, Symbol_table* symtab,
+ Layout* layout, Input_group* input_group,
int saw_undefined, Task_token* this_blocker,
Task_token* next_blocker)
- : options_(options), input_objects_(input_objects), symtab_(symtab),
+ : input_objects_(input_objects), symtab_(symtab),
layout_(layout), input_group_(input_group),
saw_undefined_(saw_undefined), this_blocker_(this_blocker),
next_blocker_(next_blocker)
run(Workqueue*);
private:
- const General_options& options_;
Input_objects* input_objects_;
Symbol_table* symtab_;
Layout* layout_;
#include <vector>
#include "elfcpp.h"
+#include "parameters.h"
#include "stringpool.h"
#include "object.h"
// Return true if the final value of this symbol is known at link
// time.
bool
- final_value_is_known(const General_options* options) const
+ final_value_is_known() const
{
- if (options->is_shared())
+ if (parameters->output_is_shared())
return false;
return this->source_ != FROM_OBJECT || !this->object()->is_dynamic();
}
// This is called to tell the target to complete any sections it is
// handling. After this all sections must have their final size.
void
- finalize_sections(const General_options* options, Layout* layout)
- { return this->do_finalize_sections(options, layout); }
+ finalize_sections(Layout* layout)
+ { return this->do_finalize_sections(layout); }
// Return a string to use to fill out a code section. This is
// basically one or more NOPS which must fill out the specified
// Virtual function which may be implemented by the child class.
virtual void
- do_finalize_sections(const General_options*, Layout*)
+ do_finalize_sections(Layout*)
{ }
// Virtual function which must be implemented by the child class if