Index: gold/arm.cc =================================================================== RCS file: /cvs/src/src/gold/arm.cc,v retrieving revision 1.5 diff -u -u -p -r1.5 arm.cc --- gold/arm.cc 3 Jun 2009 19:33:05 -0000 1.5 +++ gold/arm.cc 3 Jun 2009 21:42:44 -0000 @@ -77,8 +77,6 @@ class Output_data_plt_arm; // Coming soon (pending patches): // - Defining section symbols __exidx_start and __exidx_stop. // - Support interworking. -// - Mergeing all .ARM.xxx.yyy sections into .ARM.xxx. Currently, they -// are incorrectly merged into an .ARM section. // // TODOs: // - Create a PT_ARM_EXIDX program header for a shared object that @@ -97,7 +95,7 @@ namespace utils static inline int32_t sign_extend(uint32_t bits) { - gold_assert(no_bits < 1 || no_bits > 32); + gold_assert(no_bits >= 0 && no_bits <= 32); if (no_bits == 32) return static_cast(bits); uint32_t mask = (~((uint32_t) 0)) >> (32 - no_bits); @@ -112,7 +110,7 @@ namespace utils static inline bool has_overflow(uint32_t bits) { - gold_assert(no_bits < 1 || no_bits > 32); + gold_assert(no_bits >= 0 && no_bits <= 32); if (no_bits == 32) return false; int32_t max = (1 << (no_bits - 1)) - 1; @@ -230,6 +228,10 @@ class Target_arm : public Sized_target<3 do_is_defined_by_abi(Symbol* sym) const { return strcmp(sym->name(), "__tls_get_addr") == 0; } + // Return output section name. + const char* + do_output_section_name(const char* name, size_t* plen); + // Return the size of the GOT section. section_size_type got_size() @@ -449,9 +451,32 @@ const Target::Target_info Target_arm +const char* +Target_arm::do_output_section_name(const char *name, size_t *plen) +{ + const char*const arm_prefix = ".ARM."; + + // All special ARM sections have names of the form .ARM.xxx. + // So just transform .ARM.xxx[.yyy] to .ARM.xxx. + if (!strncmp(name, arm_prefix, strlen(arm_prefix))) + { + const char *cp = strchr(name + strlen(arm_prefix), '.'); + if (cp != NULL) + *plen = cp - name; + return name; + } + // Anything else is not handled. Tell caller to fall back on default. + return NULL; +} + // Arm relocate functions class // Index: gold/i386.cc =================================================================== RCS file: /cvs/src/src/gold/i386.cc,v retrieving revision 1.86 diff -u -u -p -r1.86 i386.cc --- gold/i386.cc 24 Mar 2009 00:31:28 -0000 1.86 +++ gold/i386.cc 3 Jun 2009 21:42:44 -0000 @@ -431,7 +431,8 @@ const Target::Target_info Target_i386::i "/usr/lib/libc.so.1", // dynamic_linker 0x08048000, // default_text_segment_address 0x1000, // abi_pagesize (overridable by -z max-page-size) - 0x1000 // common_pagesize (overridable by -z common-page-size) + 0x1000, // common_pagesize (overridable by -z common-page-size) + false // has_output_section_name }; // Get the GOT section, creating it if necessary. Index: gold/layout.cc =================================================================== RCS file: /cvs/src/src/gold/layout.cc,v retrieving revision 1.123 diff -u -u -p -r1.123 layout.cc --- gold/layout.cc 24 Apr 2009 15:44:02 -0000 1.123 +++ gold/layout.cc 3 Jun 2009 21:42:44 -0000 @@ -436,8 +436,25 @@ Layout::choose_output_section(const Relo if (is_input_section && !this->script_options_->saw_sections_clause() && !parameters->options().relocatable()) - name = Layout::output_section_name(name, &len); + { + // Give target a chance to override the output section name. + if (relobj->target()->has_output_section_name()) + { + const char* saved_name = name; + size_t saved_len = len; + name = relobj->target()->output_section_name(name, &len); + // Target does not want to override. + if (name == NULL) + { + len = saved_len; + name = Layout::output_section_name(saved_name, &len); + } + } + else + name = Layout::output_section_name(name, &len); + } + Stringpool::Key name_key; name = this->namepool_.add_with_length(name, len, true, &name_key); Index: gold/powerpc.cc =================================================================== RCS file: /cvs/src/src/gold/powerpc.cc,v retrieving revision 1.12 diff -u -u -p -r1.12 powerpc.cc --- gold/powerpc.cc 27 Mar 2009 18:19:09 -0000 1.12 +++ gold/powerpc.cc 3 Jun 2009 21:42:44 -0000 @@ -352,7 +352,8 @@ Target::Target_info Target_powerpc<32, t "/usr/lib/ld.so.1", // dynamic_linker 0x10000000, // default_text_segment_address 64 * 1024, // abi_pagesize (overridable by -z max-page-size) - 4 * 1024 // common_pagesize (overridable by -z common-page-size) + 4 * 1024, // common_pagesize (overridable by -z common-page-size) + false // has_output_section_name }; template<> @@ -369,7 +370,8 @@ Target::Target_info Target_powerpc<32, f "/usr/lib/ld.so.1", // dynamic_linker 0x10000000, // default_text_segment_address 64 * 1024, // abi_pagesize (overridable by -z max-page-size) - 4 * 1024 // common_pagesize (overridable by -z common-page-size) + 4 * 1024, // common_pagesize (overridable by -z common-page-size) + false // has_output_section_name }; template<> @@ -386,7 +388,8 @@ Target::Target_info Target_powerpc<64, t "/usr/lib/ld.so.1", // dynamic_linker 0x10000000, // default_text_segment_address 64 * 1024, // abi_pagesize (overridable by -z max-page-size) - 8 * 1024 // common_pagesize (overridable by -z common-page-size) + 8 * 1024, // common_pagesize (overridable by -z common-page-size) + false // has_output_section_name }; template<> @@ -403,7 +406,8 @@ Target::Target_info Target_powerpc<64, f "/usr/lib/ld.so.1", // dynamic_linker 0x10000000, // default_text_segment_address 64 * 1024, // abi_pagesize (overridable by -z max-page-size) - 8 * 1024 // common_pagesize (overridable by -z common-page-size) + 8 * 1024, // common_pagesize (overridable by -z common-page-size) + false // has_output_section_name }; template Index: gold/sparc.cc =================================================================== RCS file: /cvs/src/src/gold/sparc.cc,v retrieving revision 1.16 diff -u -u -p -r1.16 sparc.cc --- gold/sparc.cc 27 Mar 2009 18:19:09 -0000 1.16 +++ gold/sparc.cc 3 Jun 2009 21:42:44 -0000 @@ -371,7 +371,8 @@ Target::Target_info Target_sparc<32, tru "/usr/lib/ld.so.1", // dynamic_linker 0x00010000, // default_text_segment_address 64 * 1024, // abi_pagesize (overridable by -z max-page-size) - 8 * 1024 // common_pagesize (overridable by -z common-page-size) + 8 * 1024, // common_pagesize (overridable by -z common-page-size) + false // has_output_section_name }; template<> @@ -388,7 +389,8 @@ Target::Target_info Target_sparc<64, tru "/usr/lib/sparcv9/ld.so.1", // dynamic_linker 0x100000, // default_text_segment_address 64 * 1024, // abi_pagesize (overridable by -z max-page-size) - 8 * 1024 // common_pagesize (overridable by -z common-page-size) + 8 * 1024, // common_pagesize (overridable by -z common-page-size) + false // has_output_section_name }; // We have to take care here, even when operating in little-endian Index: gold/target.h =================================================================== RCS file: /cvs/src/src/gold/target.h,v retrieving revision 1.32 diff -u -u -p -r1.32 target.h --- gold/target.h 24 Mar 2009 00:31:29 -0000 1.32 +++ gold/target.h 3 Jun 2009 21:42:44 -0000 @@ -92,6 +92,11 @@ class Target has_code_fill() const { return this->pti_->has_code_fill; } + // Whether this target has a specific output section name function. + bool + has_output_section_name() const + { return this->pti_->has_output_section_name; } + // Return the default name of the dynamic linker. const char* dynamic_linker() const @@ -167,6 +172,15 @@ class Target is_defined_by_abi(const Symbol* sym) const { return this->do_is_defined_by_abi(sym); } + // This is called to return an output section name derived from + // an input section name. If the target returns NULL, caller needs + // to fall back to the default. + const char* + output_section_name(const char* name, size_t* plen) + { + return this->do_output_section_name(name, plen); + } + // Adjust the output file header before it is written out. VIEW // points to the header in external form. LEN is the length. void @@ -204,6 +218,8 @@ class Target uint64_t abi_pagesize; // The common page size used by actual implementations. uint64_t common_pagesize; + // Whether this target has a specific output section name function. + bool has_output_section_name; }; Target(const Target_info* pti) @@ -231,6 +247,11 @@ class Target do_is_defined_by_abi(const Symbol*) const { return false; } + // Virtual function which may be implemented by the child class. + virtual const char* + do_output_section_name(const char*, size_t*) + { gold_unreachable(); } + // Adjust the output file header before it is written out. VIEW // points to the header in external form. LEN is the length, and // will be one of the values of elfcpp::Elf_sizes::ehdr_size. Index: gold/x86_64.cc =================================================================== RCS file: /cvs/src/src/gold/x86_64.cc,v retrieving revision 1.82 diff -u -u -p -r1.82 x86_64.cc --- gold/x86_64.cc 27 Apr 2009 16:23:57 -0000 1.82 +++ gold/x86_64.cc 3 Jun 2009 21:42:44 -0000 @@ -438,7 +438,8 @@ const Target::Target_info Target_x86_64: "/lib/ld64.so.1", // program interpreter 0x400000, // default_text_segment_address 0x1000, // abi_pagesize (overridable by -z max-page-size) - 0x1000 // common_pagesize (overridable by -z common-page-size) + 0x1000, // common_pagesize (overridable by -z common-page-size) + false // has_output_section_name }; // Get the GOT section, creating it if necessary. Index: gold/testsuite/testfile.cc =================================================================== RCS file: /cvs/src/src/gold/testsuite/testfile.cc,v retrieving revision 1.14 diff -u -u -p -r1.14 testfile.cc --- gold/testsuite/testfile.cc 28 Jan 2009 02:25:33 -0000 1.14 +++ gold/testsuite/testfile.cc 3 Jun 2009 21:42:44 -0000 @@ -99,7 +99,8 @@ const Target::Target_info Target_test