* layout.cc (Layout::set_segment_offsets): Don't realign text
authorCary Coutant <ccoutant@google.com>
Mon, 1 Aug 2011 18:25:22 +0000 (18:25 +0000)
committerCary Coutant <ccoutant@google.com>
Mon, 1 Aug 2011 18:25:22 +0000 (18:25 +0000)
segment if -Ttext was specified.
* object.cc (Sized_relobj_file::Sized_relobj_file): Store the ELF
file type.
* object.h (Sized_relobj_file::e_type): New function.
(Sized_relobj_file::e_type_): New data member.
* symtab.cc (Symbol_table::add_from_relobj): Don't add section
base address for ET_EXEC files.
* target.cc (Target::do_make_elf_object_implementation): Allow
ET_EXEC files with --just-symbols option.

gold/ChangeLog
gold/layout.cc
gold/object.cc
gold/object.h
gold/symtab.cc
gold/target.cc

index 08fd41f93e863759ee313151def8fd9562fb76c1..75afbca093987c786afe2a6880d951e46cf55eeb 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-01  Cary Coutant  <ccoutant@google.com>
+
+       * layout.cc (Layout::set_segment_offsets): Don't realign text
+       segment if -Ttext was specified.
+       * object.cc (Sized_relobj_file::Sized_relobj_file): Store the ELF
+       file type.
+       * object.h (Sized_relobj_file::e_type): New function.
+       (Sized_relobj_file::e_type_): New data member.
+       * symtab.cc (Symbol_table::add_from_relobj): Don't add section
+       base address for ET_EXEC files.
+       * target.cc (Target::do_make_elf_object_implementation): Allow
+       ET_EXEC files with --just-symbols option.
+
 2011-07-28  Cary Coutant  <ccoutant@google.com>
 
        * workqueue-internal.h (Workqueue_threader::should_cancel_thread):
index 2a8d3b49c01f1c182671c40fd7fe58344552f9f6..44c2e183e826691dbb8f3e1553e30991916e0c05 100644 (file)
@@ -3039,6 +3039,11 @@ Layout::set_segment_offsets(const Target* target, Output_segment* load_seg,
              // the physical address.
              addr = (*p)->paddr();
            }
+         else if (parameters->options().user_set_Ttext()
+                  && ((*p)->flags() & elfcpp::PF_W) == 0)
+           {
+             are_addresses_set = true;
+           }
          else if (parameters->options().user_set_Tdata()
                   && ((*p)->flags() & elfcpp::PF_W) != 0
                   && (!parameters->options().user_set_Tbss()
index 6f68ed321e9d8fc369d6577564fb6e8c9faf3a57..4b69696b3fb9388462fafb88c3fb2652da0d51f0 100644 (file)
@@ -421,6 +421,7 @@ Sized_relobj_file<size, big_endian>::Sized_relobj_file(
     deferred_layout_relocs_(),
     compressed_sections_()
 {
+  this->e_type_ = ehdr.get_e_type();
 }
 
 template<int size, bool big_endian>
index 9c363cd6f72b03660795290a568f9e074250d779..a389c54a1fb0d14b0936f307da0545da0809a940 100644 (file)
@@ -1912,6 +1912,11 @@ class Sized_relobj_file : public Sized_relobj<size, big_endian>
   sized_relobj() const
   { return this; }
 
+  // Return the ELF file type.
+  int
+  e_type() const
+  { return this->e_type_; }
+
   // Return the number of symbols.  This is only valid after
   // Object::add_symbols has been called.
   unsigned int
@@ -2504,6 +2509,9 @@ class Sized_relobj_file : public Sized_relobj<size, big_endian>
 
   // General access to the ELF file.
   elfcpp::Elf_file<size, big_endian, Object> elf_file_;
+  // Type of ELF file (ET_REL or ET_EXEC).  ET_EXEC files are allowed
+  // as input files only for the --just-symbols option.
+  int e_type_;
   // Index of SHT_SYMTAB section.
   unsigned int symtab_shndx_;
   // The number of local symbols.
index e289f796c59f4eaea360ad49c3dd5e90c16be9f0..ff6ff846492da8fd310ee001883f8a8ae7e96f52 100644 (file)
@@ -1192,12 +1192,14 @@ Symbol_table::add_from_relobj(
        {
          memcpy(symbuf, p, sym_size);
          elfcpp::Sym_write<size, big_endian> sw(symbuf);
-         if (orig_st_shndx != elfcpp::SHN_UNDEF && is_ordinary)
+         if (orig_st_shndx != elfcpp::SHN_UNDEF
+             && is_ordinary
+             && relobj->e_type() == elfcpp::ET_REL)
            {
-             // Symbol values in object files are section relative.
-             // This is normally what we want, but since here we are
-             // converting the symbol to absolute we need to add the
-             // section address.  The section address in an object
+             // Symbol values in relocatable object files are section
+             // relative.  This is normally what we want, but since here
+             // we are converting the symbol to absolute we need to add
+             // the section address.  The section address in an object
              // file is normally zero, but people can use a linker
              // script to change it.
              sw.put_st_value(sym.get_st_value()
index 4a7af83c161735db77b20a63378387c2fab5daf4..091f9d34cd5521ee08ef1e17722570deba5122b3 100644 (file)
@@ -72,7 +72,10 @@ Target::do_make_elf_object_implementation(
     const elfcpp::Ehdr<size, big_endian>& ehdr)
 {
   int et = ehdr.get_e_type();
-  if (et == elfcpp::ET_REL)
+  // ET_EXEC files are valid input for --just-symbols/-R,
+  // and we treat them as relocatable objects.
+  if (et == elfcpp::ET_REL
+      || (et == elfcpp::ET_EXEC && input_file->just_symbols()))
     {
       Sized_relobj_file<size, big_endian>* obj =
        new Sized_relobj_file<size, big_endian>(name, input_file, offset, ehdr);
This page took 0.037017 seconds and 4 git commands to generate.