2009-12-05 Doug Kwan <dougkwan@google.com>
authorDoug Kwan <dougkwan@google.com>
Sun, 6 Dec 2009 02:49:46 +0000 (02:49 +0000)
committerDoug Kwan <dougkwan@google.com>
Sun, 6 Dec 2009 02:49:46 +0000 (02:49 +0000)
elfcpp/ChangeLog:

* arm.h: Define enums for Tag_CPU_arch EABI attribute.

gold/ChangeLog:
* arm.cc (Target_arm::arm_info): Initialize new fields
attributes_section and attributes_vendor.
* i386.cc (Target_i386::i386_info): Same.
* object.cc (Sized_relobj::do_layout): Skip attribute section.
* gold/powerpc.cc (Target_powerpc::powerpc_info): Initialize new
fields attributes_section and attributes_vendor.
  * sparc.cc (Target_sparc::sparc_info): Same.
* target.h (Target::attributes_section, Target::attributes_vendor,
Target::is_attributes_section, Target::attribute_arg_type,
Target::attributes_order): New method definitions.
(Target::Target_info::attributes_section,
Target::Target_info::attributes_vendor): New fields.
(Target::do_attribute_arg_type, Target::do_attributes_order): New
virtual method definitions.
* x86_64.cc (Target_x86_64::x86_64_info): Initialize new fields
attributes_section and attributes_vendor.
* testsuite/testfile.cc (Target_test::test_target_info): Same.

elfcpp/ChangeLog
elfcpp/arm.h
gold/ChangeLog
gold/arm.cc
gold/i386.cc
gold/object.cc
gold/powerpc.cc
gold/sparc.cc
gold/target.h
gold/testsuite/testfile.cc
gold/x86_64.cc

index 508b2cac67feb46ddd015a79c528956a0bff8eea..653a863c5cbbbb7fb71a71919f1a827112f567f2 100644 (file)
@@ -1,3 +1,7 @@
+2009-12-05  Doug Kwan  <dougkwan@google.com>
+
+       * arm.h: Define enums for Tag_CPU_arch EABI attribute.
+
 2009-11-24  Rafael Avila de Espindola  <espindola@google.com>
 
        * elfcpp_file.h: Include elfcpp.h.
index 027cf3422476c0245ceabff275d24e8aa01a8730..52b80c5a7cd918cfc8601170c26a9f88ebbfbe55 100644 (file)
@@ -222,6 +222,29 @@ inline Elf_Word
 arm_eabi_version(Elf_Word flags)
 { return flags & EF_ARM_EABIMASK; }
 
+// Values for the Tag_CPU_arch EABI attribute.
+enum
+{
+  TAG_CPU_ARCH_PRE_V4,
+  TAG_CPU_ARCH_V4,
+  TAG_CPU_ARCH_V4T,
+  TAG_CPU_ARCH_V5T,
+  TAG_CPU_ARCH_V5TE,
+  TAG_CPU_ARCH_V5TEJ,
+  TAG_CPU_ARCH_V6,
+  TAG_CPU_ARCH_V6KZ,
+  TAG_CPU_ARCH_V6T2,
+  TAG_CPU_ARCH_V6K,
+  TAG_CPU_ARCH_V7,
+  TAG_CPU_ARCH_V6_M,
+  TAG_CPU_ARCH_V6S_M,
+  TAG_CPU_ARCH_V7E_M,
+  MAX_TAG_CPU_ARCH = TAG_CPU_ARCH_V7E_M,
+  // Pseudo-architecture to allow objects to be compatible with the subset of
+  // armv4t and armv6-m.  This value should never be stored in object files.
+  TAG_CPU_ARCH_V4T_PLUS_V6_M = (MAX_TAG_CPU_ARCH + 1)
+};
+
 } // End namespace elfcpp.
 
 #endif // !defined(ELFCPP_ARM_H)
index 9d5883f5aa6f431c31fc30f8ee7ddeec0b80fbc4..9de7ff2705e6b2d7a22b41b7764ea700ec5e8a3f 100644 (file)
@@ -1,3 +1,23 @@
+2009-12-05  Doug Kwan  <dougkwan@google.com>
+
+       * arm.cc (Target_arm::arm_info): Initialize new fields
+       attributes_section and attributes_vendor.
+       * i386.cc (Target_i386::i386_info): Same.
+       * object.cc (Sized_relobj::do_layout): Skip attribute section.
+       * gold/powerpc.cc (Target_powerpc::powerpc_info): Initialize new
+       fields attributes_section and attributes_vendor.
+       * sparc.cc (Target_sparc::sparc_info): Same.
+       * target.h (Target::attributes_section, Target::attributes_vendor,
+       Target::is_attributes_section, Target::attribute_arg_type,
+       Target::attributes_order): New method definitions.
+       (Target::Target_info::attributes_section,
+       Target::Target_info::attributes_vendor): New fields.
+       (Target::do_attribute_arg_type, Target::do_attributes_order): New
+       virtual method definitions.
+       * x86_64.cc (Target_x86_64::x86_64_info): Initialize new fields
+       attributes_section and attributes_vendor.
+       * testsuite/testfile.cc (Target_test::test_target_info): Same.
+
 2009-12-05  Doug Kwan  <dougkwan@google.com>
 
        * arm.cc: Update comments about interworking and stub generation.
index aa5ec8cd2cde99a925428bf9f96503710e32f069..85c4cafa0e71f23a7bf53fa2aed96e3bc74c050f 100644 (file)
@@ -1665,7 +1665,9 @@ const Target::Target_info Target_arm<big_endian>::arm_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_UNDEF,   // large_common_shndx
   0,                   // small_common_section_flags
-  0                    // large_common_section_flags
+  0,                   // large_common_section_flags
+  ".ARM.attributes",   // attributes_section
+  "aeabi"              // attributes_vendor
 };
 
 // Arm relocate functions class
index eabf8e0724f1ea1f6c1b4889f4554070822ee9f1..f61e168f9a8ea75f0f33733881e017f0d87f334d 100644 (file)
@@ -441,7 +441,9 @@ const Target::Target_info Target_i386::i386_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_UNDEF,   // large_common_shndx
   0,                   // small_common_section_flags
-  0                    // large_common_section_flags
+  0,                   // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 // Get the GOT section, creating it if necessary.
index eeacdaa6e7f6a826035886fe1cd3a18638941f0f..798e42d808d124398b40232a9e7a9e34b5767522 100644 (file)
@@ -1138,6 +1138,12 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
                omit[i] = true;
            }
 
+         // Skip attributes section.
+         if (parameters->target().is_attributes_section(name))
+           {
+             omit[i] = true;
+           }
+
           bool discard = omit[i];
           if (!discard)
             {
index 36b5790d3035a447a9c58c46eedc437a849bb509..bd5571cbf587baebaaa9073c5c9cc738482de632 100644 (file)
@@ -342,7 +342,9 @@ Target::Target_info Target_powerpc<32, true>::powerpc_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_UNDEF,   // large_common_shndx
   0,                   // small_common_section_flags
-  0                    // large_common_section_flags
+  0,                   // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 template<>
@@ -363,7 +365,9 @@ Target::Target_info Target_powerpc<32, false>::powerpc_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_UNDEF,   // large_common_shndx
   0,                   // small_common_section_flags
-  0                    // large_common_section_flags
+  0,                   // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 template<>
@@ -384,7 +388,9 @@ Target::Target_info Target_powerpc<64, true>::powerpc_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_UNDEF,   // large_common_shndx
   0,                   // small_common_section_flags
-  0                    // large_common_section_flags
+  0,                   // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 template<>
@@ -405,7 +411,9 @@ Target::Target_info Target_powerpc<64, false>::powerpc_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_UNDEF,   // large_common_shndx
   0,                   // small_common_section_flags
-  0                    // large_common_section_flags
+  0,                   // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 template<int size, bool big_endian>
index acf5ba617431ea3922ef56153bb9cabc31079273..8047a11536ff4ed16c77b362ae31b5dcaeeda3fb 100644 (file)
@@ -361,7 +361,9 @@ Target::Target_info Target_sparc<32, true>::sparc_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_UNDEF,   // large_common_shndx
   0,                   // small_common_section_flags
-  0                    // large_common_section_flags
+  0,                   // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 template<>
@@ -382,7 +384,9 @@ Target::Target_info Target_sparc<64, true>::sparc_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_UNDEF,   // large_common_shndx
   0,                   // small_common_section_flags
-  0                    // large_common_section_flags
+  0,                   // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 // We have to take care here, even when operating in little-endian
index 729b4c796d7ca9d514c1788605a1d2e91ec49341..c1c58a4e3eda70f066a4966ea85926f23b1af4da 100644 (file)
@@ -282,6 +282,39 @@ class Target
     return this->do_relax(pass, input_objects, symtab, layout);
   } 
 
+  // Return the target-specific name of attributes section.  This is
+  // NULL if a target does not use attributes section or if it uses
+  // the default section name ".gnu.attributes".
+  const char*
+  attributes_section() const
+  { return this->pti_->attributes_section; }
+
+  // Return the vendor name of vendor attributes.
+  const char*
+  attributes_vendor() const
+  { return this->pti_->attributes_vendor; }
+
+  // Whether a section called NAME is an attribute section.
+  bool
+  is_attributes_section(const char* name) const
+  {
+    return ((this->pti_->attributes_section != NULL
+            && strcmp(name, this->pti_->attributes_section) == 0)
+           || strcmp(name, ".gnu.attributes") == 0); 
+  }
+
+  // Return a bit mask of argument types for attribute with TAG.
+  int
+  attribute_arg_type(int tag) const
+  { return this->do_attribute_arg_type(tag); }
+
+  // Return the attribute tag of the position NUM in the list of fixed
+  // attributes.  Normally there is no reordering and
+  // attributes_order(NUM) == NUM.
+  int
+  attributes_order(int num) const
+  { return this->do_attributes_order(num); }
+
  protected:
   // This struct holds the constant information for a child class.  We
   // use a struct to avoid the overhead of virtual function calls for
@@ -323,6 +356,10 @@ class Target
     elfcpp::Elf_Xword small_common_section_flags;
     // Section flags for large common section.
     elfcpp::Elf_Xword large_common_section_flags;
+    // Name of attributes section if it is not ".gnu.attributes".
+    const char* attributes_section;
+    // Vendor name of vendor attributes.
+    const char* attributes_vendor;
   };
 
   Target(const Target_info* pti)
@@ -440,6 +477,17 @@ class Target
   set_view_to_nop(unsigned char* view, section_size_type view_size,
                  section_offset_type offset, size_t len) const;
 
+  // This must be overriden by the child class if it has target-specific
+  // attributes subsection in the attribute section. 
+  virtual int
+  do_attribute_arg_type(int) const
+  { gold_unreachable(); }
+
+  // This may be overridden by the child class.
+  virtual int
+  do_attributes_order(int num) const
+  { return num; }
+
  private:
   // The implementations of the four do_make_elf_object virtual functions are
   // almost identical except for their sizes and endianity.  We use a template.
index 88e5b816cb372bc46c7e667252f304232e0728a8..7f53792669f17ada74abe4f395c6bb5aa0cd2a04 100644 (file)
@@ -101,7 +101,9 @@ const Target::Target_info Target_test<size, big_endian>::test_target_info =
   elfcpp::SHN_UNDEF,                   // small_common_shndx
   elfcpp::SHN_UNDEF,                   // large_common_shndx
   0,                                   // small_common_section_flags
-  0                                    // large_common_section_flags
+  0,                                   // large_common_section_flags
+  NULL,                                        // attributes_section
+  NULL                                 // attributes_vendor
 };
 
 // The test targets.
index 2972180d213277c49ff01be849d77de958daabc5..3b37286e60878191fa50195a7ce0d0fb5e714715 100644 (file)
@@ -439,7 +439,9 @@ const Target::Target_info Target_x86_64::x86_64_info =
   elfcpp::SHN_UNDEF,   // small_common_shndx
   elfcpp::SHN_X86_64_LCOMMON,  // large_common_shndx
   0,                   // small_common_section_flags
-  elfcpp::SHF_X86_64_LARGE     // large_common_section_flags
+  elfcpp::SHF_X86_64_LARGE,    // large_common_section_flags
+  NULL,                        // attributes_section
+  NULL                 // attributes_vendor
 };
 
 // This is called when a new output section is created.  This is where