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.
+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.
 
            return (*p)->output_section();
        }
     }
-  gold_unreachable();
+  return NULL;
 }
 
 // Return the number of Output_sections in an 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();
   }
 
 
          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: