aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-06-22 06:51:53 +0000
committerIan Lance Taylor <ian@airs.com>2009-06-22 06:51:53 +0000
commit8a5e3e08a6faa0fdba3daa1fa4295b02c7ebe1eb (patch)
tree01736b6b47e8048239544872455cc12eb3d5bcc6 /gold/symtab.h
parent1998a8e0333f8ebc40a5387532d74f90f510591d (diff)
downloadbinutils-8a5e3e08a6faa0fdba3daa1fa4295b02c7ebe1eb.zip
binutils-8a5e3e08a6faa0fdba3daa1fa4295b02c7ebe1eb.tar.gz
binutils-8a5e3e08a6faa0fdba3daa1fa4295b02c7ebe1eb.tar.bz2
* layout.cc (Layout::make_output_section): Call
Target::new_output_section. (Layout::attach_allocated_section_to_segment): Put large section sections in a separate load segment with the large segment flag set. (Layout::segment_precedes): Sort large data segments after other load segments. (align_file_offset): New static function. (Layout::set_segment_offsets): Use align_file_offset. * output.h (class Output_section): Add is_small_section_ and is_large_section_ fields. (Output_section::is_small_section): New function. (Output_section::set_is_small_section): New function. (Output_section::is_large_section): New function. (Output_section::set_is_large_section): New function. (Output_section::is_large_data_section): New function. (class Output_segment): Add is_large_data_segment_ field. (Output_segment::is_large_data_segment): New function. (Output_segment::set_is_large_data_segment): New function. * output.cc (Output_section::Output_section): Initialize new fields. (Output_segment::Output_segment): Likewise. (Output_segment::add_output_section): Add assertion that large data sections always go in large data segments. Force small data sections to the end of the list of data sections. Force small BSS sections to the start of the list of BSS sections. For large BSS sections to the end of the list of BSS sections. * symtab.h (class Symbol): Declare is_common_shndx. (Symbol::is_defined): Check Symbol::is_common_shndx. (Symbol::is_common): Likewise. (class Symbol_table): Define enum Commons_section_type. Update declarations. Add small_commons_ and large_commons_ fields. * symtab.cc (Symbol::is_common_shndx): New function. (Symbol_table::Symbol_table): Initialize new fields. (Symbol_table::add_from_object): Put small and large common symbols in the right list. (Symbol_table::sized_finalized_symbol): Check Symbol::is_common_shndx. (Symbol_table::sized_write_globals): Likewise. * common.cc (Symbol_table::do_allocate_commons): Allocate new common symbol lists. Don't call do_allocate_commons_list if the list is empty. (Symbol_table::do_allocate_commons_list): Remove is_tls parameter. Add comons_section_type parameter. Change all callers. Handle small and large common symbols. * object.cc (Sized_relobj::do_finalize_local_symbols): Check Symbol::is_common_shndx. * resolve.cc (symbol_to_bits): Likewise. * target.h (Target::small_common_shndx): New function. (Target::small_common_section_flags): New function. (Target::large_common_shndx): New function. (Target::large_common_section_flags): New function. (Target::new_output_section): New function. (Target::Target_info): Add small_common_shndx, large_common_shndx, small_common_section_flags, and large_common_section_flags fields. (Target::do_new_output_section): New virtual function. * arm.cc (Target_arm::arm_info): Initialize new fields. * i386.cc (Target_i386::i386_info): Likewise. * powerpc.cc (Target_powerpc::powerpc_info) [all versions]: Likewise. * sparc.c (Target_sparc::sparc_info) [all versions]: Likewise. * x86_64.cc (Target_x86_64::x86_64_info): Likewise. (Target_x86_64::do_new_output_section): New function. * configure.ac: Define conditional MCMODEL_MEDIUM. * testsuite/Makefile.am (check_PROGRAMS): Add large. (large_SOURCES, large_CFLAGS, large_DEPENDENCIES): Define. (large_LDFLAGS): Define. * testsuite/large.c: New file. * testsuite/testfile.cc (Target_test::test_target_info): Initialize new fields. * configure, testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/symtab.h')
-rw-r--r--gold/symtab.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/gold/symtab.h b/gold/symtab.h
index 660fc4d..be6bc12 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -411,6 +411,11 @@ class Symbol
bool
final_value_is_known() const;
+ // Return true if SHNDX represents a common symbol. This depends on
+ // the target.
+ static bool
+ is_common_shndx(unsigned int shndx);
+
// Return whether this is a defined symbol (not undefined or
// common).
bool
@@ -422,7 +427,7 @@ class Symbol
unsigned int shndx = this->shndx(&is_ordinary);
return (is_ordinary
? shndx != elfcpp::SHN_UNDEF
- : shndx != elfcpp::SHN_COMMON);
+ : !Symbol::is_common_shndx(shndx));
}
// Return true if this symbol is from a dynamic object.
@@ -463,11 +468,13 @@ class Symbol
bool
is_common() const
{
+ if (this->type_ == elfcpp::STT_COMMON)
+ return true;
+ if (this->source_ != FROM_OBJECT)
+ return false;
bool is_ordinary;
- return (this->source_ == FROM_OBJECT
- && ((this->shndx(&is_ordinary) == elfcpp::SHN_COMMON
- && !is_ordinary)
- || this->type_ == elfcpp::STT_COMMON));
+ unsigned int shndx = this->shndx(&is_ordinary);
+ return !is_ordinary && Symbol::is_common_shndx(shndx);
}
// Return whether this symbol can be seen outside this object.
@@ -1505,6 +1512,16 @@ class Symbol_table
void
do_add_undefined_symbols_from_command_line();
+ // Types of common symbols.
+
+ enum Commons_section_type
+ {
+ COMMONS_NORMAL,
+ COMMONS_TLS,
+ COMMONS_SMALL,
+ COMMONS_LARGE
+ };
+
// Allocate the common symbols, sized version.
template<int size>
void
@@ -1513,7 +1530,8 @@ class Symbol_table
// Allocate the common symbols from one list.
template<int size>
void
- do_allocate_commons_list(Layout*, bool is_tls, Commons_type*, Mapfile*);
+ do_allocate_commons_list(Layout*, Commons_section_type, Commons_type*,
+ Mapfile*);
// Implement detect_odr_violations.
template<int size, bool big_endian>
@@ -1630,6 +1648,10 @@ class Symbol_table
// This is like the commons_ field, except that it holds TLS common
// symbols.
Commons_type tls_commons_;
+ // This is for small common symbols.
+ Commons_type small_commons_;
+ // This is for large common symbols.
+ Commons_type large_commons_;
// A list of symbols which have been forced to be local. We don't
// expect there to be very many of them, so we keep a list of them
// rather than walking the whole table to find them.