Make non-virtual.
(Target::can_icf_inline_merge_sections): Likewise.
(Target::section_may_have_icf_unsafe_poineters): Likewise.
(Target::Target_info): Add can_icf_inline_merge_sections field.
(Target::do_can_check_for_function_pointers): New virtual
function.
(Target::do_section_may_have_icf_unsafe_pointers): Likewise.
* arm.cc (Target_arm::do_can_check_for_function_pointers): Rename
from can_check_for_function_pointers, move in file.
(Target_arm::do_section_may_have_icf_unsafe_pointers): Rename from
section_may_have_icf_unsafe_poineters, move in file.
(Target_arm::arm_info): Initialize can_icf_inline_merge_sections.
* i386.cc (Target_i386::do_can_check_for_function_pointers):
Rename from can_check_for_function_pointers, move in file.
(Target_i386::can_icf_inline_merge_sections): Remove.
(Target_i386::i386_info): Initialize
can_icf_inline_merge_sections.
* powerpc.cc (Target_powerpc::powerpc_info) [all versions]:
Initialize can_icf_inline_merge_sections.
* sparc.cc (Target_sparc::sparc_info) [both version]: Likewise.
* x86_64.cc (Target_x86_64::do_can_check_for_function_pointers):
Rename from can_check_for_function_pointers, move in file.
(Target_x86_64::can_icf_inline_merge_sections): Remove.
(Target_x86_64::x86_64_info): Initialize
can_icf_inline_merge_sections.
* testsuite/testfile.cc (Target_test::test_target_info):
Likewise.
* icf.cc (get_section_contents): Correct formatting.
+2011-06-28 Ian Lance Taylor <iant@google.com>
+
+ * target.h (Target::can_check_for_function_pointers): Rewrite.
+ Make non-virtual.
+ (Target::can_icf_inline_merge_sections): Likewise.
+ (Target::section_may_have_icf_unsafe_poineters): Likewise.
+ (Target::Target_info): Add can_icf_inline_merge_sections field.
+ (Target::do_can_check_for_function_pointers): New virtual
+ function.
+ (Target::do_section_may_have_icf_unsafe_pointers): Likewise.
+ * arm.cc (Target_arm::do_can_check_for_function_pointers): Rename
+ from can_check_for_function_pointers, move in file.
+ (Target_arm::do_section_may_have_icf_unsafe_pointers): Rename from
+ section_may_have_icf_unsafe_poineters, move in file.
+ (Target_arm::arm_info): Initialize can_icf_inline_merge_sections.
+ * i386.cc (Target_i386::do_can_check_for_function_pointers):
+ Rename from can_check_for_function_pointers, move in file.
+ (Target_i386::can_icf_inline_merge_sections): Remove.
+ (Target_i386::i386_info): Initialize
+ can_icf_inline_merge_sections.
+ * powerpc.cc (Target_powerpc::powerpc_info) [all versions]:
+ Initialize can_icf_inline_merge_sections.
+ * sparc.cc (Target_sparc::sparc_info) [both version]: Likewise.
+ * x86_64.cc (Target_x86_64::do_can_check_for_function_pointers):
+ Rename from can_check_for_function_pointers, move in file.
+ (Target_x86_64::can_icf_inline_merge_sections): Remove.
+ (Target_x86_64::x86_64_info): Initialize
+ can_icf_inline_merge_sections.
+ * testsuite/testfile.cc (Target_test::test_target_info):
+ Likewise.
+ * icf.cc (get_section_contents): Correct formatting.
+
2011-06-27 Ian Lance Taylor <iant@google.com>
* symtab.cc (Symbol::versioned_name): New function.
// arm.cc -- arm target support for gold.
-// Copyright 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by Doug Kwan <dougkwan@google.com> based on the i386 code
// by Ian Lance Taylor <iant@google.com>.
// This file also contains borrowed and adapted code from
fix_cortex_a8_(false), cortex_a8_relocs_info_()
{ }
- // Virtual function which is set to return true by a target if
- // it can use relocation types to determine if a function's
- // pointer is taken.
- virtual bool
- can_check_for_function_pointers() const
- { return true; }
-
- // Whether a section called SECTION_NAME may have function pointers to
- // sections not eligible for safe ICF folding.
- virtual bool
- section_may_have_icf_unsafe_pointers(const char* section_name) const
- {
- return (!is_prefix_of(".ARM.exidx", section_name)
- && !is_prefix_of(".ARM.extab", section_name)
- && Target::section_may_have_icf_unsafe_pointers(section_name));
- }
-
// Whether we can use BLX.
bool
may_use_blx() const
arm_reloc_property_table = new Arm_reloc_property_table();
}
+ // Virtual function which is set to return true by a target if
+ // it can use relocation types to determine if a function's
+ // pointer is taken.
+ virtual bool
+ do_can_check_for_function_pointers() const
+ { return true; }
+
+ // Whether a section called SECTION_NAME may have function pointers to
+ // sections not eligible for safe ICF folding.
+ virtual bool
+ do_section_may_have_icf_unsafe_pointers(const char* section_name) const
+ {
+ return (!is_prefix_of(".ARM.exidx", section_name)
+ && !is_prefix_of(".ARM.extab", section_name)
+ && Target::do_section_may_have_icf_unsafe_pointers(section_name));
+ }
+
private:
// The class which scans relocations.
class Scan
false, // has_resolve
false, // has_code_fill
true, // is_default_stack_executable
+ false, // can_icf_inline_merge_sections
'\0', // wrap_char
"/usr/lib/libc.so.1", // dynamic_linker
0x8000, // default_text_segment_address
// i386.cc -- i386 target support for gold.
-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
got_mod_index_offset_(-1U), tls_base_symbol_defined_(false)
{ }
- inline bool
- can_check_for_function_pointers() const
- { return true; }
-
- virtual bool
- can_icf_inline_merge_sections () const
- { return true; }
-
// Process the relocations to determine unreferenced sections for
// garbage collection.
void
do_plt_section_for_local(const Relobj*, unsigned int) const
{ return this->plt_section(); }
+ // We can tell whether we take the address of a function.
+ inline bool
+ do_can_check_for_function_pointers() const
+ { return true; }
+
// Return whether SYM is call to a non-split function.
bool
do_is_call_to_non_split(const Symbol* sym, unsigned int) const;
false, // has_resolve
true, // has_code_fill
true, // is_default_stack_executable
+ true, // can_icf_inline_merge_sections
'\0', // wrap_char
"/usr/lib/libc.so.1", // dynamic_linker
0x08048000, // default_text_segment_address
// icf.cc -- Identical Code Folding.
//
-// Copyright 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by Sriraman Tallam <tmsriram@google.com>.
// This file is part of gold.
// This reloc points to a merge section. Hash the
// contents of this section.
if ((secn_flags & elfcpp::SHF_MERGE) != 0
- && parameters->target().can_icf_inline_merge_sections ())
+ && parameters->target().can_icf_inline_merge_sections())
{
uint64_t entsize =
(it_v->first)->section_entsize(it_v->second);
// powerpc.cc -- powerpc target support for gold.
-// Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by David S. Miller <davem@davemloft.net>
// and David Edelsohn <edelsohn@gnu.org>
false, // has_resolve
false, // has_code_fill
true, // is_default_stack_executable
+ false, // can_icf_inline_merge_sections
'\0', // wrap_char
"/usr/lib/ld.so.1", // dynamic_linker
0x10000000, // default_text_segment_address
false, // has_resolve
false, // has_code_fill
true, // is_default_stack_executable
+ false, // can_icf_inline_merge_sections
'\0', // wrap_char
"/usr/lib/ld.so.1", // dynamic_linker
0x10000000, // default_text_segment_address
false, // has_resolve
false, // has_code_fill
true, // is_default_stack_executable
+ false, // can_icf_inline_merge_sections
'\0', // wrap_char
"/usr/lib/ld.so.1", // dynamic_linker
0x10000000, // default_text_segment_address
false, // has_resolve
false, // has_code_fill
true, // is_default_stack_executable
+ false, // can_icf_inline_merge_sections
'\0', // wrap_char
"/usr/lib/ld.so.1", // dynamic_linker
0x10000000, // default_text_segment_address
// sparc.cc -- sparc target support for gold.
-// Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by David S. Miller <davem@davemloft.net>.
// This file is part of gold.
false, // has_resolve
false, // has_code_fill
true, // is_default_stack_executable
+ false, // can_icf_inline_merge_sections
'\0', // wrap_char
"/usr/lib/ld.so.1", // dynamic_linker
0x00010000, // default_text_segment_address
false, // has_resolve
false, // has_code_fill
true, // is_default_stack_executable
+ false, // can_icf_inline_merge_sections
'\0', // wrap_char
"/usr/lib/sparcv9/ld.so.1", // dynamic_linker
0x100000, // default_text_segment_address
// target.h -- target support for gold -*- C++ -*-
-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
virtual ~Target()
{ }
- // Virtual function which is set to return true by a target if
- // it can use relocation types to determine if a function's
- // pointer is taken.
- virtual bool
- can_check_for_function_pointers() const
- { return false; }
-
- // This function is used in ICF (icf.cc). This is set to true by
- // the target if a relocation to a merged section can be processed
- // to retrieve the contents of the merged section.
- virtual bool
- can_icf_inline_merge_sections () const
- { return false; }
-
- // Whether a section called SECTION_NAME may have function pointers to
- // sections not eligible for safe ICF folding.
- virtual bool
- section_may_have_icf_unsafe_pointers(const char* section_name) const
- {
- // We recognize sections for normal vtables, construction vtables and
- // EH frames.
- return (!is_prefix_of(".rodata._ZTV", section_name)
- && !is_prefix_of(".data.rel.ro._ZTV", section_name)
- && !is_prefix_of(".rodata._ZTC", section_name)
- && !is_prefix_of(".data.rel.ro._ZTC", section_name)
- && !is_prefix_of(".eh_frame", section_name));
- }
-
// Return the bit size that this target implements. This should
// return 32 or 64.
int
plt_section_for_local(const Relobj* object, unsigned int symndx) const
{ return this->do_plt_section_for_local(object, symndx); }
+ // Return whether this target can use relocation types to determine
+ // if a function's address is taken.
+ bool
+ can_check_for_function_pointers() const
+ { return this->do_can_check_for_function_pointers(); }
+
+ // Return whether a relocation to a merged section can be processed
+ // to retrieve the contents.
+ bool
+ can_icf_inline_merge_sections () const
+ { return this->pti_->can_icf_inline_merge_sections; }
+
+ // Whether a section called SECTION_NAME may have function pointers to
+ // sections not eligible for safe ICF folding.
+ virtual bool
+ section_may_have_icf_unsafe_pointers(const char* section_name) const
+ { return this->do_section_may_have_icf_unsafe_pointers(section_name); }
+
// Return true if a reference to SYM from a reloc of type R_TYPE
// means that the current function may call an object compiled
// without -fsplit-stack. SYM is known to be defined in an object
// Whether an object file with no .note.GNU-stack sections implies
// that the stack should be executable.
bool is_default_stack_executable;
+ // Whether a relocation to a merged section can be processed to
+ // retrieve the contents.
+ bool can_icf_inline_merge_sections;
// Prefix character to strip when checking for wrapping.
char wrap_char;
// The default dynamic linker name.
do_plt_section_for_local(const Relobj*, unsigned int) const
{ gold_unreachable(); }
+ // Virtual function which may be overriden by the child class.
+ virtual bool
+ do_can_check_for_function_pointers() const
+ { return false; }
+
+ // Virtual function which may be overridden by the child class. We
+ // recognize some default sections for which we don't care whether
+ // they have function pointers.
+ virtual bool
+ do_section_may_have_icf_unsafe_pointers(const char* section_name) const
+ {
+ // We recognize sections for normal vtables, construction vtables and
+ // EH frames.
+ return (!is_prefix_of(".rodata._ZTV", section_name)
+ && !is_prefix_of(".data.rel.ro._ZTV", section_name)
+ && !is_prefix_of(".rodata._ZTC", section_name)
+ && !is_prefix_of(".data.rel.ro._ZTC", section_name)
+ && !is_prefix_of(".eh_frame", section_name));
+ }
+
// Virtual function which may be overridden by the child class. The
// default implementation is that any function not defined by the
// ABI is a call to a non-split function.
// testfile.cc -- Dummy ELF objects for testing purposes.
-// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
false, // has_resolve
false, // has_code_fill
false, // is_default_stack_executable
+ false, // can_icf_inline_merge_sections
'\0', // wrap_char
"/dummy", // dynamic_linker
0x08000000, // default_text_segment_address
// x86_64.cc -- x86_64 target support for gold.
-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
tls_base_symbol_defined_(false)
{ }
- // This function should be defined in targets that can use relocation
- // types to determine (implemented in local_reloc_may_be_function_pointer
- // and global_reloc_may_be_function_pointer)
- // if a function's pointer is taken. ICF uses this in safe mode to only
- // fold those functions whose pointer is defintely not taken. For x86_64
- // pie binaries, safe ICF cannot be done by looking at relocation types.
- inline bool
- can_check_for_function_pointers() const
- { return !parameters->options().pie(); }
-
- virtual bool
- can_icf_inline_merge_sections () const
- { return true; }
-
// Hook for a new output section.
void
do_new_output_section(Output_section*) const;
do_plt_section_for_local(const Relobj*, unsigned int) const
{ return this->plt_section(); }
+ // This function should be defined in targets that can use relocation
+ // types to determine (implemented in local_reloc_may_be_function_pointer
+ // and global_reloc_may_be_function_pointer)
+ // if a function's pointer is taken. ICF uses this in safe mode to only
+ // fold those functions whose pointer is defintely not taken. For x86_64
+ // pie binaries, safe ICF cannot be done by looking at relocation types.
+ bool
+ do_can_check_for_function_pointers() const
+ { return !parameters->options().pie(); }
+
// Adjust -fsplit-stack code which calls non-split-stack code.
void
do_calls_non_split(Relobj* object, unsigned int shndx,
false, // has_resolve
true, // has_code_fill
true, // is_default_stack_executable
+ true, // can_icf_inline_merge_sections
'\0', // wrap_char
"/lib/ld64.so.1", // program interpreter
0x400000, // default_text_segment_address