From 921b53228fa18e00beca6b19b3aa43c23903b900 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 14 Aug 2012 03:39:03 +0000 Subject: [PATCH] * 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. --- gold/ChangeLog | 7 +++++++ gold/layout.cc | 7 ++++++- gold/powerpc.cc | 13 +++++++++++++ gold/target.h | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index d7ccce7e527..70c15b79f8d 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,10 @@ +2012-08-14 Alan Modra + + * 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 * powerpc.cc: Update for renamed R_PPC_REL16 relocs. diff --git a/gold/layout.cc b/gold/layout.cc index d597fa6f61f..006afefc305 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -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); diff --git a/gold/powerpc.cc b/gold/powerpc.cc index 3c84fd6524d..35cf83476dc 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -125,6 +125,19 @@ class Target_powerpc : public Sized_target 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*); diff --git a/gold/target.h b/gold/target.h index 81c8114e5f2..19092e15a31 100644 --- a/gold/target.h +++ b/gold/target.h @@ -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. -- 2.30.2