* target.h (Target::output_section_name): New function.

(Target::do_output_section_name): New function.
	* layout.cc (Layout::choose_output_section): Call the above.
	* powerpc.cc (Target_powerpc::do_output_section_name): New function.
This commit is contained in:
Alan Modra 2012-08-14 03:39:03 +00:00
parent a6f7924a83
commit 921b53228f
4 changed files with 40 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2012-08-14 Alan Modra <amodra@gmail.com>
* target.h (Target::output_section_name): New function.
(Target::do_output_section_name): New function.
* layout.cc (Layout::choose_output_section): Call the above.
* powerpc.cc (Target_powerpc::do_output_section_name): New function.
2012-08-14 Alan Modra <amodra@gmail.com>
* powerpc.cc: Update for renamed R_PPC_REL16 relocs.

View file

@ -939,7 +939,12 @@ Layout::choose_output_section(const Relobj* relobj, const char* name,
if (is_input_section
&& !this->script_options_->saw_sections_clause()
&& !parameters->options().relocatable())
name = Layout::output_section_name(relobj, name, &len);
{
const char *orig_name = name;
name = parameters->target().output_section_name(relobj, name, &len);
if (name == NULL)
name = Layout::output_section_name(relobj, orig_name, &len);
}
Stringpool::Key name_key;
name = this->namepool_.add_with_length(name, len, true, &name_key);

View file

@ -125,6 +125,19 @@ class Target_powerpc : public Sized_target<size, big_endian>
bool needs_special_offset_handling,
size_t local_symbol_count,
const unsigned char* plocal_symbols);
// Map input .toc section to output .got section.
const char*
do_output_section_name(const Relobj*, const char* name, size_t* plen) const
{
if (size == 64 && strcmp(name, ".toc") == 0)
{
*plen = 4;
return ".got";
}
return NULL;
}
// Finalize the sections.
void
do_finalize_sections(Layout*, const Input_objects*, Symbol_table*);

View file

@ -412,6 +412,15 @@ class Target
define_standard_symbols(Symbol_table* symtab, Layout* layout)
{ this->do_define_standard_symbols(symtab, layout); }
// Return the output section name to use given an input section
// name, or NULL if no target specific name mapping is required.
// Set *PLEN to the length of the name if returning non-NULL.
const char*
output_section_name(const Relobj* relobj,
const char* name,
size_t* plen) const
{ return this->do_output_section_name(relobj, name, plen); }
protected:
// This struct holds the constant information for a child class. We
// use a struct to avoid the overhead of virtual function calls for
@ -655,6 +664,11 @@ class Target
do_define_standard_symbols(Symbol_table*, Layout*)
{ }
// This may be overridden by the child class.
virtual const char*
do_output_section_name(const Relobj*, const char*, size_t*) const
{ return NULL; }
private:
// The implementations of the four do_make_elf_object virtual functions are
// almost identical except for their sizes and endianness. We use a template.