Make linker-created symbols relocatable where appropriate.
authorCary Coutant <ccoutant@gmail.com>
Thu, 22 Dec 2016 00:21:23 +0000 (16:21 -0800)
committerCary Coutant <ccoutant@gmail.com>
Thu, 22 Dec 2016 00:21:23 +0000 (16:21 -0800)
Linker-created symbols like __ehdr_start, __etext, __edata, and end
should be relocatable, not absolute.

gold/
* output.cc (Output_segment::first_section): Return NULL if there are
no sections in the segment.
* output.h (Output_segment::first_section_load_address): Assert that
first section is not NULL.
* symtab.cc (Symbol_table::sized_write_globals): Attach linker-created
segment-relative symbols to first section of the segment.

gold/ChangeLog
gold/output.cc
gold/output.h
gold/symtab.cc

index c9530316989de61430a9e474f8d1940c8e9d206f..ba7454506c998e97d7ed36592b2e14fc84146a47 100644 (file)
@@ -1,3 +1,12 @@
+2016-12-21  Cary Coutant  <ccoutant@gmail.com>
+
+       * output.cc (Output_segment::first_section): Return NULL if there are
+       no sections in the segment.
+       * output.h (Output_segment::first_section_load_address): Assert that
+       first section is not NULL.
+       * symtab.cc (Symbol_table::sized_write_globals): Attach linker-created
+       segment-relative symbols to first section of the segment.
+
 2016-12-21  Alan Modra  <amodra@gmail.com>
 
        * arm.cc: Fix comment chars with high bit set.
index cf934fb61a33b2a5b14a16af3c88ff9721540e76..64df3e8e2c64218a0b0aa0ee061f36fa936408e8 100644 (file)
@@ -4801,7 +4801,7 @@ Output_segment::first_section() const
            return (*p)->output_section();
        }
     }
-  gold_unreachable();
+  return NULL;
 }
 
 // Return the number of Output_sections in an Output_segment.
index 9083b5ac74d98d6916debe8e8cfafd3b8631e474..2b8f0c8ff0c8410076d6d9596491a9f810197f16 100644 (file)
@@ -4741,6 +4741,7 @@ class Output_segment
   first_section_load_address() const
   {
     const Output_section* os = this->first_section();
+    gold_assert(os != NULL);
     return os->has_load_address() ? os->load_address() : os->address();
   }
 
index 6865190f880d3e4ce027c6b025d281ab5402788a..35989f0e636c56c11ac1c468aee131d39425dc21 100644 (file)
@@ -3120,7 +3120,14 @@ Symbol_table::sized_write_globals(const Stringpool* sympool,
          break;
 
        case Symbol::IN_OUTPUT_SEGMENT:
-         shndx = elfcpp::SHN_ABS;
+         {
+           Output_segment* oseg = sym->output_segment();
+           Output_section* osect = oseg->first_section();
+           if (osect == NULL)
+             shndx = elfcpp::SHN_ABS;
+           else
+             shndx = osect->out_shndx();
+         }
          break;
 
        case Symbol::IS_CONSTANT:
This page took 0.029981 seconds and 4 git commands to generate.