sized_target, and set_target methods.
(Object::sized_target): Remove.
(class Sized_relobj): Update declarations. Remove sized_target.
* object.cc (Sized_relobj::setup): Remove target parameter.
Change all callers.
(Input_objects::add_object): Don't do anything with the target.
(make_elf_sized_object): Add punconfigured parameter. Change all
callers. Set or test parameter target.
* dynobj.cc (Sized_dynobj::target): Remove target parameter.
Change all callers.
* parameters.cc (Parameters::set_target): Change parameter type to
be non-const.
(Parameters::default_target): Remove.
(set_parameters_target): Change parameter type to be non-const.
(parameters_force_valid_target): New function.
(parameters_clear_target): New function.
* parameters.h (class Parameters): Update declarations. Remove
default_target method. Add sized_target and clear_target
methods. Change target_ to be non-const.
(set_parameters_target): Update declaration.
(parameters_force_valid_target): Declare.
(parameters_clear_target): Declare.
* readsyms.cc (Read_symbols::do_read_symbols): Pass punconfigured
as NULL if we aren't searching.
(Add_symbols::run): Don't check for compatible target.
* fileread.cc (Input_file::open_binary): Call
parameters_force_valid_target.
* gold.cc (queue_middle_tasks): Likewise.
* plugin.cc (make_sized_plugin_object): Likewise. Don't call
set_target on object.
* dynobj.h (class Sized_dynobj): Update declarations.
* archive.cc (Archive::get_elf_object_for_member): Return NULL if
make_elf_object returns NULL.
(Archive::include_member): Don't check whether object target is
compatible.
* output.cc (Output_section::add_input_section): Get target from
parameters.
(Output_section::relax_input_section): Likewise.
* reloc.cc (Sized_relobj::do_gc_process_relocs): Get target from
parameters.
(Sized_relobj::do_scan_relocs): Likewise.
(Sized_relobj::relocate_sections): Likewise.
* resolve.cc (Symbol_table::resolve): Likewise.
* symtab.cc (Symbol_table::wrap_symbol): Likewise. Remove object
parameter. Change all callers.
(Symbol_table::add_from_object): Get target from parameters.
(Symbol_table::add_from_relobj): Don't check object target.
(Symbol_table::add_from_dynobj): Likewise.
(Symbol_table::define_special_symbol): Get target from
parameters.
* symtab.h (class Symbol_table): Update declaration.
* testsuite/binary_unittest.cc (gold_testsuite): Remove target
parameter. Change all callers. Clear parameter target.
(Binary_test): Test target here.
* testsuite/object_unittest.cc (gold_testsuite): Remove
target_test_pointer parameter. Change all callers.
(Object_test): Test target here.
+2009-09-30 Ian Lance Taylor <iant@google.com>
+
+ * object.h (class Object): Remove target_ field, and target,
+ sized_target, and set_target methods.
+ (Object::sized_target): Remove.
+ (class Sized_relobj): Update declarations. Remove sized_target.
+ * object.cc (Sized_relobj::setup): Remove target parameter.
+ Change all callers.
+ (Input_objects::add_object): Don't do anything with the target.
+ (make_elf_sized_object): Add punconfigured parameter. Change all
+ callers. Set or test parameter target.
+ * dynobj.cc (Sized_dynobj::target): Remove target parameter.
+ Change all callers.
+ * parameters.cc (Parameters::set_target): Change parameter type to
+ be non-const.
+ (Parameters::default_target): Remove.
+ (set_parameters_target): Change parameter type to be non-const.
+ (parameters_force_valid_target): New function.
+ (parameters_clear_target): New function.
+ * parameters.h (class Parameters): Update declarations. Remove
+ default_target method. Add sized_target and clear_target
+ methods. Change target_ to be non-const.
+ (set_parameters_target): Update declaration.
+ (parameters_force_valid_target): Declare.
+ (parameters_clear_target): Declare.
+ * readsyms.cc (Read_symbols::do_read_symbols): Pass punconfigured
+ as NULL if we aren't searching.
+ (Add_symbols::run): Don't check for compatible target.
+ * fileread.cc (Input_file::open_binary): Call
+ parameters_force_valid_target.
+ * gold.cc (queue_middle_tasks): Likewise.
+ * plugin.cc (make_sized_plugin_object): Likewise. Don't call
+ set_target on object.
+ * dynobj.h (class Sized_dynobj): Update declarations.
+ * archive.cc (Archive::get_elf_object_for_member): Return NULL if
+ make_elf_object returns NULL.
+ (Archive::include_member): Don't check whether object target is
+ compatible.
+ * output.cc (Output_section::add_input_section): Get target from
+ parameters.
+ (Output_section::relax_input_section): Likewise.
+ * reloc.cc (Sized_relobj::do_gc_process_relocs): Get target from
+ parameters.
+ (Sized_relobj::do_scan_relocs): Likewise.
+ (Sized_relobj::relocate_sections): Likewise.
+ * resolve.cc (Symbol_table::resolve): Likewise.
+ * symtab.cc (Symbol_table::wrap_symbol): Likewise. Remove object
+ parameter. Change all callers.
+ (Symbol_table::add_from_object): Get target from parameters.
+ (Symbol_table::add_from_relobj): Don't check object target.
+ (Symbol_table::add_from_dynobj): Likewise.
+ (Symbol_table::define_special_symbol): Get target from
+ parameters.
+ * symtab.h (class Symbol_table): Update declaration.
+ * testsuite/binary_unittest.cc (gold_testsuite): Remove target
+ parameter. Change all callers. Clear parameter target.
+ (Binary_test): Test target here.
+ * testsuite/object_unittest.cc (gold_testsuite): Remove
+ target_test_pointer parameter. Change all callers.
+ (Object_test): Test target here.
+
2009-09-26 Ian Lance Taylor <iant@google.com>
* testsuite/initpri1.c: Don't try to use constructor priorities if
+ "(" + member_name + ")"),
input_file, memoff, ehdr, read_size,
punconfigured);
+ if (obj == NULL)
+ return NULL;
obj->set_no_export(this->no_export());
return obj;
}
{
Object *obj = p->second.obj_;
- if (!this->included_member_
- && this->searched_for()
- && !parameters->is_compatible_target(obj->target()))
- return false;
-
Read_symbols_data *sd = p->second.sd_;
if (mapfile != NULL)
mapfile->report_include_archive_member(obj->name(), sym, why);
if (!this->included_member_
&& this->searched_for()
- && (obj == NULL
- ? unconfigured
- : !parameters->is_compatible_target(obj->target())))
+ && obj == NULL
+ && unconfigured)
{
if (obj != NULL)
delete obj;
template<int size, bool big_endian>
void
-Sized_dynobj<size, big_endian>::setup(Target *target)
+Sized_dynobj<size, big_endian>::setup()
{
- this->set_target(target);
const unsigned int shnum = this->elf_file_.shnum();
this->set_shnum(shnum);
}
// Set up the object file based on TARGET.
void
- setup(Target *target);
+ setup();
// Read the symbols.
void
// In order to open a binary file, we need machine code, size, and
// endianness. We may not have a valid target at this point, in
// which case we use the default target.
- const Target* target;
- if (parameters->target_valid())
- target = ¶meters->target();
- else
- target = ¶meters->default_target();
+ parameters_force_valid_target();
+ const Target& target(parameters->target());
- Binary_to_elf binary_to_elf(target->machine_code(),
- target->get_size(),
- target->is_big_endian(),
+ Binary_to_elf binary_to_elf(target.machine_code(),
+ target.get_size(),
+ target.is_big_endian(),
name);
if (!binary_to_elf.convert(task))
return false;
// pass an empty archive to the linker and get an empty object file
// out. In order to do this we need to use a default target.
if (input_objects->number_of_input_objects() == 0)
- set_parameters_target(¶meters->default_target());
+ parameters_force_valid_target();
int thread_count = options.thread_count_middle();
if (thread_count == 0)
}
// Set up an object file based on the file header. This sets up the
-// target and reads the section information.
+// section information.
template<int size, bool big_endian>
void
-Sized_relobj<size, big_endian>::setup(Target *target)
+Sized_relobj<size, big_endian>::setup()
{
- this->set_target(target);
-
const unsigned int shnum = this->elf_file_.shnum();
this->set_shnum(shnum);
}
bool
Input_objects::add_object(Object* obj)
{
- // Set the global target from the first object file we recognize.
- Target* target = obj->target();
- if (!parameters->target_valid())
- set_parameters_target(target);
- else if (target != ¶meters->target())
- {
- obj->error(_("incompatible target"));
- return false;
- }
-
// Print the filename if the -t/--trace option is selected.
if (parameters->options().trace())
gold_info("%s", obj->name().c_str());
template<int size, bool big_endian>
Object*
make_elf_sized_object(const std::string& name, Input_file* input_file,
- off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr)
+ off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr,
+ bool* punconfigured)
{
Target* target = select_target(ehdr.get_e_machine(), size, big_endian,
ehdr.get_e_ident()[elfcpp::EI_OSABI],
if (target == NULL)
gold_fatal(_("%s: unsupported ELF machine number %d"),
name.c_str(), ehdr.get_e_machine());
+
+ if (!parameters->target_valid())
+ set_parameters_target(target);
+ else if (target != ¶meters->target())
+ {
+ if (punconfigured != NULL)
+ *punconfigured = true;
+ else
+ gold_error(_("%s: incompatible target"), name.c_str());
+ return NULL;
+ }
+
return target->make_elf_object<size, big_endian>(name, input_file, offset,
ehdr);
}
#ifdef HAVE_TARGET_32_BIG
elfcpp::Ehdr<32, true> ehdr(p);
return make_elf_sized_object<32, true>(name, input_file,
- offset, ehdr);
+ offset, ehdr, punconfigured);
#else
if (punconfigured != NULL)
*punconfigured = true;
#ifdef HAVE_TARGET_32_LITTLE
elfcpp::Ehdr<32, false> ehdr(p);
return make_elf_sized_object<32, false>(name, input_file,
- offset, ehdr);
+ offset, ehdr, punconfigured);
#else
if (punconfigured != NULL)
*punconfigured = true;
#ifdef HAVE_TARGET_64_BIG
elfcpp::Ehdr<64, true> ehdr(p);
return make_elf_sized_object<64, true>(name, input_file,
- offset, ehdr);
+ offset, ehdr, punconfigured);
#else
if (punconfigured != NULL)
*punconfigured = true;
#ifdef HAVE_TARGET_64_LITTLE
elfcpp::Ehdr<64, false> ehdr(p);
return make_elf_sized_object<64, false>(name, input_file,
- offset, ehdr);
+ offset, ehdr, punconfigured);
#else
if (punconfigured != NULL)
*punconfigured = true;
Object(const std::string& name, Input_file* input_file, bool is_dynamic,
off_t offset = 0)
: name_(name), input_file_(input_file), offset_(offset), shnum_(-1U),
- is_dynamic_(is_dynamic), target_(NULL), xindex_(NULL), no_export_(false)
+ is_dynamic_(is_dynamic), xindex_(NULL), no_export_(false)
{ input_file->file().add_object(); }
virtual ~Object()
pluginobj()
{ return this->do_pluginobj(); }
- // Return the target structure associated with this object.
- Target*
- target() const
- { return this->target_; }
-
// Get the file. We pass on const-ness.
Input_file*
input_file()
just_symbols() const
{ return this->input_file()->just_symbols(); }
- // Return the sized target structure associated with this object.
- // This is like the target method but it returns a pointer of
- // appropriate checked type.
- template<int size, bool big_endian>
- Sized_target<size, big_endian>*
- sized_target() const;
-
// Get the number of sections.
unsigned int
shnum() const
size_t* used) const
{ this->do_get_global_symbol_counts(symtab, defined, used); }
- // Set the target.
- void
- set_target(Target* target)
- { this->target_ = target; }
-
// Return whether this object was found in a system directory.
bool
is_in_system_directory() const
unsigned int shnum_;
// Whether this is a dynamic object.
bool is_dynamic_;
- // Target functions--may be NULL if the target is not known.
- Target* target_;
// Many sections for objects with more than SHN_LORESERVE sections.
Xindex* xindex_;
// True if exclude this object from automatic symbol export.
bool no_export_;
};
-// Implement sized_target inline for efficiency. This approach breaks
-// static type checking, but is made safe using asserts.
-
-template<int size, bool big_endian>
-inline Sized_target<size, big_endian>*
-Object::sized_target() const
-{
- gold_assert(this->target_->get_size() == size);
- gold_assert(this->target_->is_big_endian() ? big_endian : !big_endian);
- return static_cast<Sized_target<size, big_endian>*>(this->target_);
-}
-
// A regular object (ET_REL). This is an abstract base class itself.
// The implementation is the template class Sized_relobj.
// Set up the object file based on TARGET.
void
- setup(Target *target);
+ setup();
// Return the number of symbols. This is only valid after
// Object::add_symbols has been called.
return this->local_values_[sym].input_shndx(is_ordinary);
}
- // Return the appropriate Sized_target structure.
- Sized_target<size, big_endian>*
- sized_target()
- { return this->Object::sized_target<size, big_endian>(); }
-
// Record that local symbol SYM needs a dynamic symbol entry.
void
set_needs_output_dynsym_entry(unsigned int sym)
if (aligned_offset_in_section > offset_in_section
&& !have_sections_script
&& (sh_flags & elfcpp::SHF_EXECINSTR) != 0
- && object->target()->has_code_fill())
+ && parameters->target().has_code_fill())
{
// We need to add some fill data. Using fill_list_ when
// possible is an optimization, since we will often have fill
{
// FIXME: When relaxing, the size needs to adjust to
// maintain a constant alignment.
- std::string fill_data(object->target()->code_fill(fill_len));
+ std::string fill_data(parameters->target().code_fill(fill_len));
Output_data_const* odc = new Output_data_const(fill_data, 1);
this->input_sections_.push_back(Input_section(odc));
}
|| this->may_sort_attached_input_sections()
|| this->must_sort_attached_input_sections()
|| parameters->options().user_set_Map()
- || object->target()->may_relax())
+ || parameters->target().may_relax())
this->input_sections_.push_back(Input_section(object, shndx,
shdr.get_sh_size(),
addralign));
Relobj* relobj = psection->relobj();
unsigned int shndx = psection->shndx();
- gold_assert(relobj->target()->may_relax());
+ gold_assert(parameters->target().may_relax());
// This is not very efficient if we a going to relax a number of sections
// in an Output_section with lot of Input_sections.
}
void
-Parameters::set_target(const Target* target)
+Parameters::set_target(Target* target)
{
if (!this->target_valid())
this->target_ = target;
gold_assert(target == this->target_);
}
-// The x86_64 kernel build converts a binary file to an object file
-// using -r --format binary --oformat elf32-i386 foo.o. In order to
-// support that for gold we support determining the default target
-// choice from the output format. We recognize names that the GNU
-// linker uses.
-
-const Target&
-Parameters::default_target() const
-{
- gold_assert(this->options_valid());
- if (this->options().user_set_oformat())
- {
- const Target* target
- = select_target_by_name(this->options().oformat());
- if (target != NULL)
- return *target;
-
- gold_error(_("unrecognized output format %s"),
- this->options().oformat());
- }
-
- // The GOLD_DEFAULT_xx macros are defined by the configure script.
- const Target* target = select_target(elfcpp::GOLD_DEFAULT_MACHINE,
- GOLD_DEFAULT_SIZE,
- GOLD_DEFAULT_BIG_ENDIAN,
- elfcpp::GOLD_DEFAULT_OSABI,
- 0);
- gold_assert(target != NULL);
- return *target;
-}
-
// Return whether TARGET is compatible with the target we are using.
bool
{ static_parameters.set_options(options); }
void
-set_parameters_target(const Target* target)
+set_parameters_target(Target* target)
{ static_parameters.set_target(target); }
void
set_parameters_doing_static_link(bool doing_static_link)
{ static_parameters.set_doing_static_link(doing_static_link); }
+// Force the target to be valid by using the default. Use the
+// --oformat option is set; this supports the x86_64 kernel build,
+// which converts a binary file to an object file using -r --format
+// binary --oformat elf32-i386 foo.o. Otherwise use the configured
+// default.
+
+void
+parameters_force_valid_target()
+{
+ if (parameters->target_valid())
+ return;
+
+ gold_assert(parameters->options_valid());
+ if (parameters->options().user_set_oformat())
+ {
+ Target* target = select_target_by_name(parameters->options().oformat());
+ if (target != NULL)
+ {
+ set_parameters_target(target);
+ return;
+ }
+
+ gold_error(_("unrecognized output format %s"),
+ parameters->options().oformat());
+ }
+
+ // The GOLD_DEFAULT_xx macros are defined by the configure script.
+ Target* target = select_target(elfcpp::GOLD_DEFAULT_MACHINE,
+ GOLD_DEFAULT_SIZE,
+ GOLD_DEFAULT_BIG_ENDIAN,
+ elfcpp::GOLD_DEFAULT_OSABI,
+ 0);
+ gold_assert(target != NULL);
+ set_parameters_target(target);
+}
+
+// Clear the current target, for testing.
+
+void
+parameters_clear_target()
+{
+ static_parameters.clear_target();
+}
+
} // End namespace gold.
class General_options;
class Errors;
class Target;
+template<int size, bool big_endian>
+class Sized_target;
// Here we define the Parameters class which simply holds simple
// general parameters which apply to the entire link. We use a global
set_options(const General_options* options);
void
- set_target(const Target* target);
+ set_target(Target* target);
void
set_doing_static_link(bool doing_static_link);
return *this->target_;
}
- // When we don't have an output file to associate a target, make a
- // default one, with guesses about size and endianness.
- const Target&
- default_target() const;
+ // The Sized_target of the output file. The caller must request the
+ // right size and endianness.
+ template<int size, bool big_endian>
+ Sized_target<size, big_endian>*
+ sized_target() const
+ {
+ gold_assert(this->target_valid());
+ return static_cast<Sized_target<size, big_endian>*>(this->target_);
+ }
+
+ // Clear the target, for testing.
+ void
+ clear_target()
+ { this->target_ = NULL; }
// Return true if TARGET is compatible with the current target.
bool
private:
Errors* errors_;
const General_options* options_;
- const Target* target_;
+ Target* target_;
bool doing_static_link_valid_;
bool doing_static_link_;
int debug_;
set_parameters_options(const General_options* options);
extern void
-set_parameters_target(const Target* target);
+set_parameters_target(Target* target);
extern void
set_parameters_doing_static_link(bool doing_static_link);
-
+
+// Ensure that the target to be valid by using the default target if
+// necessary.
+
+extern void
+parameters_force_valid_target();
+
+// Clear the current target, for testing.
+
+extern void
+parameters_clear_target();
+
// Return whether we are doing a particular debugging type. The
// argument is one of the flags from debug.h.
static Pluginobj*
make_sized_plugin_object(Input_file* input_file, off_t offset, off_t filesize)
{
- Target* target;
Pluginobj* obj = NULL;
- if (parameters->target_valid())
- target = const_cast<Target*>(¶meters->target());
- else
- target = const_cast<Target*>(¶meters->default_target());
+ parameters_force_valid_target();
+ const Target& target(parameters->target());
- if (target->get_size() == 32)
+ if (target.get_size() == 32)
{
- if (target->is_big_endian())
+ if (target.is_big_endian())
#ifdef HAVE_TARGET_32_BIG
obj = new Sized_pluginobj<32, true>(input_file->filename(),
input_file, offset, filesize);
input_file->filename().c_str());
#endif
}
- else if (target->get_size() == 64)
+ else if (target.get_size() == 64)
{
- if (target->is_big_endian())
+ if (target.is_big_endian())
#ifdef HAVE_TARGET_64_BIG
obj = new Sized_pluginobj<64, true>(input_file->filename(),
input_file, offset, filesize);
}
gold_assert(obj != NULL);
- obj->set_target(target);
return obj;
}
{
// This is an ELF object.
- bool unconfigured;
+ bool unconfigured = false;
+ bool* punconfigured = (input_file->will_search_for()
+ ? &unconfigured
+ : NULL);
Object* obj = make_elf_object(input_file->filename(),
input_file, 0, ehdr, read_size,
- &unconfigured);
+ punconfigured);
if (obj == NULL)
{
- if (unconfigured && input_file->will_search_for())
+ if (unconfigured)
{
Read_symbols::incompatible_warning(this->input_argument_,
input_file);
// Add the symbols in the object to the symbol table.
void
-Add_symbols::run(Workqueue* workqueue)
+Add_symbols::run(Workqueue*)
{
Pluginobj* pluginobj = this->object_->pluginobj();
if (pluginobj != NULL)
return;
}
- // If this file has an incompatible format, try for another file
- // with the same name.
- if (this->object_->searched_for()
- && !parameters->is_compatible_target(this->object_->target()))
- {
- Read_symbols::incompatible_warning(this->input_argument_,
- this->object_->input_file());
- Read_symbols::requeue(workqueue, this->input_objects_, this->symtab_,
- this->layout_, this->dirpath_, this->dirindex_,
- this->mapfile_, this->input_argument_,
- this->input_group_, this->next_blocker_);
- this->object_->release();
- delete this->object_;
- }
- else if (!this->input_objects_->add_object(this->object_))
+ if (!this->input_objects_->add_object(this->object_))
{
this->object_->release();
delete this->object_;
Layout* layout,
Read_relocs_data* rd)
{
- Sized_target<size, big_endian>* target = this->sized_target();
+ Sized_target<size, big_endian>* target =
+ parameters->sized_target<size, big_endian>();
const unsigned char* local_symbols;
if (rd->local_symbols == NULL)
Layout* layout,
Read_relocs_data* rd)
{
- Sized_target<size, big_endian>* target = this->sized_target();
+ Sized_target<size, big_endian>* target =
+ parameters->sized_target<size, big_endian>();
const unsigned char* local_symbols;
if (rd->local_symbols == NULL)
Views* pviews)
{
unsigned int shnum = this->shnum();
- Sized_target<size, big_endian>* target = this->sized_target();
+ Sized_target<size, big_endian>* target =
+ parameters->sized_target<size, big_endian>();
const Output_sections& out_sections(this->output_sections());
const std::vector<Address>& out_offsets(this->section_offsets_);
unsigned int orig_st_shndx,
Object* object, const char* version)
{
- if (object->target()->has_resolve())
+ if (parameters->target().has_resolve())
{
Sized_target<size, big_endian>* sized_target;
- sized_target = object->sized_target<size, big_endian>();
+ sized_target = parameters->sized_target<size, big_endian>();
sized_target->resolve(to, sym, object, version);
return;
}
// option was used.
const char*
-Symbol_table::wrap_symbol(Object* object, const char* name,
- Stringpool::Key* name_key)
+Symbol_table::wrap_symbol(const char* name, Stringpool::Key* name_key)
{
// For some targets, we need to ignore a specific character when
// wrapping, and add it back later.
char prefix = '\0';
- if (name[0] == object->target()->wrap_char())
+ if (name[0] == parameters->target().wrap_char())
{
prefix = name[0];
++name;
if (orig_st_shndx == elfcpp::SHN_UNDEF
&& parameters->options().any_wrap())
{
- const char* wrap_name = this->wrap_symbol(object, name, &name_key);
+ const char* wrap_name = this->wrap_symbol(name, &name_key);
if (wrap_name != name)
{
// If we see a reference to malloc with version GLIBC_2.0,
was_common = false;
Sized_target<size, big_endian>* target =
- object->sized_target<size, big_endian>();
+ parameters->sized_target<size, big_endian>();
if (!target->has_make_symbol())
ret = new Sized_symbol<size>();
else
{
*defined = 0;
- gold_assert(size == relobj->target()->get_size());
gold_assert(size == parameters->target().get_size());
const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
{
*defined = 0;
- gold_assert(size == dynobj->target()->get_size());
gold_assert(size == parameters->target().get_size());
if (dynobj->just_symbols())
sym = new Sized_symbol<size>();
else
{
- gold_assert(target.get_size() == size);
- gold_assert(target.is_big_endian() ? big_endian : !big_endian);
- typedef Sized_target<size, big_endian> My_target;
- const My_target* sized_target =
- static_cast<const My_target*>(&target);
+ Sized_target<size, big_endian>* sized_target =
+ parameters->sized_target<size, big_endian>();
sym = sized_target->make_symbol();
if (sym == NULL)
return NULL;
// Adjust NAME and *NAME_KEY for wrapping.
const char*
- wrap_symbol(Object* object, const char*, Stringpool::Key* name_key);
+ wrap_symbol(const char* name, Stringpool::Key* name_key);
// Whether we should override a symbol, based on flags in
// resolve.cc.
{
Sized_relobj<size, big_endian>* obj =
new Sized_relobj<size, big_endian>(name, input_file, offset, ehdr);
- obj->setup(this);
+ obj->setup();
return obj;
}
else if (et == elfcpp::ET_DYN)
{
Sized_dynobj<size, big_endian>* obj =
new Sized_dynobj<size, big_endian>(name, input_file, offset, ehdr);
- obj->setup(this);
+ obj->setup();
return obj;
}
else
template<int size, bool big_endian>
bool
-Sized_binary_test(Target* target)
+Sized_binary_test()
{
+ parameters_clear_target();
// We need a pretend Task.
const Task* task = reinterpret_cast<const Task*>(-1);
return false;
CHECK(!object->is_dynamic());
- CHECK(object->target() == target);
CHECK(object->shnum() == 5);
CHECK(object->section_name(1) == ".data");
CHECK(object->section_flags(1) == (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE));
int fail = 0;
#ifdef HAVE_TARGET_32_LITTLE
- if (!Sized_binary_test<32, false>(target_test_pointer_32_little))
+ if (!Sized_binary_test<32, false>())
++fail;
+ CHECK(¶meters->target() == target_test_pointer_32_little);
#endif
#ifdef HAVE_TARGET_32_BIG
- if (!Sized_binary_test<32, true>(target_test_pointer_32_big))
+ if (!Sized_binary_test<32, true>())
++fail;
+ CHECK(¶meters->target() == target_test_pointer_32_big);
#endif
#ifdef HAVE_TARGET_64_LITTLE
- if (!Sized_binary_test<64, false>(target_test_pointer_64_little))
+ if (!Sized_binary_test<64, false>())
++fail;
+ CHECK(¶meters->target() == target_test_pointer_64_little);
#endif
#ifdef HAVE_TARGET_64_BIG
- if (!Sized_binary_test<64, true>(target_test_pointer_64_big))
+ if (!Sized_binary_test<64, true>())
++fail;
+ CHECK(¶meters->target() == target_test_pointer_64_big);
#endif
return fail == 0;
template<int size, bool big_endian>
bool
-Sized_object_test(const unsigned char* test_file, unsigned int test_file_size,
- Target* target_test_pointer)
+Sized_object_test(const unsigned char* test_file, unsigned int test_file_size)
{
+ parameters_clear_target();
// We need a pretend Task.
const Task* task = reinterpret_cast<const Task*>(-1);
Input_file input_file(task, "test.o", test_file, test_file_size);
test_file, test_file_size, NULL);
CHECK(object->name() == "test.o");
CHECK(!object->is_dynamic());
- CHECK(object->target() == target_test_pointer);
CHECK(object->is_locked());
object->unlock(task);
CHECK(!object->is_locked());
#ifdef HAVE_TARGET_32_LITTLE
if (!Sized_object_test<32, false>(test_file_1_32_little,
- test_file_1_size_32_little,
- target_test_pointer_32_little))
+ test_file_1_size_32_little))
++fail;
+ CHECK(¶meters->target() == target_test_pointer_32_little);
#endif
#ifdef HAVE_TARGET_32_BIG
if (!Sized_object_test<32, true>(test_file_1_32_big,
- test_file_1_size_32_big,
- target_test_pointer_32_big))
+ test_file_1_size_32_big))
++fail;
+ CHECK(¶meters->target() == target_test_pointer_32_big);
#endif
#ifdef HAVE_TARGET_64_LITTLE
if (!Sized_object_test<64, false>(test_file_1_64_little,
- test_file_1_size_64_little,
- target_test_pointer_64_little))
+ test_file_1_size_64_little))
++fail;
+ CHECK(¶meters->target() == target_test_pointer_64_little);
#endif
#ifdef HAVE_TARGET_64_BIG
if (!Sized_object_test<64, true>(test_file_1_64_big,
- test_file_1_size_64_big,
- target_test_pointer_64_big))
+ test_file_1_size_64_big))
++fail;
+ CHECK(¶meters->target() == target_test_pointer_64_big);
#endif
return fail == 0;