aboutsummaryrefslogtreecommitdiff
path: root/gold/object.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-10-06 22:58:27 +0000
committerIan Lance Taylor <ian@airs.com>2009-10-06 22:58:27 +0000
commit364c7fa5c98a7e2d75fe33ecb1ec4f7260849731 (patch)
tree2cfca9a55836527ac65fea760844754fe93f01a9 /gold/object.h
parent5aafa1cc49c9a87aeb3e0aeaede8155fdf9f1645 (diff)
downloadgdb-364c7fa5c98a7e2d75fe33ecb1ec4f7260849731.zip
gdb-364c7fa5c98a7e2d75fe33ecb1ec4f7260849731.tar.gz
gdb-364c7fa5c98a7e2d75fe33ecb1ec4f7260849731.tar.bz2
* options.h (class General_options): Define
split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/object.h')
-rw-r--r--gold/object.h73
1 files changed, 72 insertions, 1 deletions
diff --git a/gold/object.h b/gold/object.h
index e7d05c7..bbc1a10 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -195,7 +195,8 @@ class Object
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), xindex_(NULL), no_export_(false)
+ is_dynamic_(is_dynamic), uses_split_stack_(false),
+ has_no_split_stack_(false), xindex_(NULL), no_export_(false)
{ input_file->file().add_object(); }
virtual ~Object()
@@ -216,6 +217,17 @@ class Object
is_dynamic() const
{ return this->is_dynamic_; }
+ // Return whether this object was compiled with -fsplit-stack.
+ bool
+ uses_split_stack() const
+ { return this->uses_split_stack_; }
+
+ // Return whether this object contains any functions compiled with
+ // the no_split_stack attribute.
+ bool
+ has_no_split_stack() const
+ { return this->has_no_split_stack_; }
+
// Returns NULL for Objects that are not plugin objects. This method
// is overridden in the Pluginobj class.
Pluginobj*
@@ -556,6 +568,12 @@ class Object
handle_gnu_warning_section(const char* name, unsigned int shndx,
Symbol_table*);
+ // If NAME is the name of the special section which indicates that
+ // this object was compiled with -fstack-split, mark it accordingly,
+ // and return true. Otherwise return false.
+ bool
+ handle_split_stack_section(const char* name);
+
private:
// This class may not be copied.
Object(const Object&);
@@ -572,6 +590,11 @@ class Object
unsigned int shnum_;
// Whether this is a dynamic object.
bool is_dynamic_;
+ // Whether this object was compiled with -fsplit-stack.
+ bool uses_split_stack_;
+ // Whether this object contains any functions compiled with the
+ // no_split_stack attribute.
+ bool has_no_split_stack_;
// Many sections for objects with more than SHN_LORESERVE sections.
Xindex* xindex_;
// True if exclude this object from automatic symbol export.
@@ -1252,6 +1275,30 @@ class Got_offset_list
Got_offset_list* got_next_;
};
+// This type is used to modify relocations for -fsplit-stack. It is
+// indexed by relocation index, and means that the relocation at that
+// index should use the symbol from the vector, rather than the one
+// indicated by the relocation.
+
+class Reloc_symbol_changes
+{
+ public:
+ Reloc_symbol_changes(size_t count)
+ : vec_(count, NULL)
+ { }
+
+ void
+ set(size_t i, Symbol* sym)
+ { this->vec_[i] = sym; }
+
+ const Symbol*
+ operator[](size_t i) const
+ { return this->vec_[i]; }
+
+ private:
+ std::vector<Symbol*> vec_;
+};
+
// A regular object file. This is size and endian specific.
template<int size, bool big_endian>
@@ -1671,6 +1718,30 @@ class Sized_relobj : public Relobj
unsigned char* reloc_view,
section_size_type reloc_view_size);
+ // A type shared by split_stack_adjust_reltype and find_functions.
+ typedef std::map<section_offset_type, section_size_type> Function_offsets;
+
+ // Check for -fsplit-stack routines calling non-split-stack routines.
+ void
+ split_stack_adjust(const Symbol_table*, const unsigned char* pshdrs,
+ unsigned int sh_type, unsigned int shndx,
+ const unsigned char* prelocs, size_t reloc_count,
+ unsigned char* view, section_size_type view_size,
+ Reloc_symbol_changes** reloc_map);
+
+ template<int sh_type>
+ void
+ split_stack_adjust_reltype(const Symbol_table*, const unsigned char* pshdrs,
+ unsigned int shndx, const unsigned char* prelocs,
+ size_t reloc_count, unsigned char* view,
+ section_size_type view_size,
+ Reloc_symbol_changes** reloc_map);
+
+ // Find all functions in a section.
+ void
+ find_functions(const unsigned char* pshdrs, unsigned int shndx,
+ Function_offsets*);
+
// Initialize input to output maps for section symbols in merged
// sections.
void