Fix internal error with -z relro when .tbss is last relro section.
authorCary Coutant <ccoutant@gmail.com>
Sun, 22 Mar 2015 05:30:44 +0000 (22:30 -0700)
committerCary Coutant <ccoutant@gmail.com>
Sun, 22 Mar 2015 05:30:44 +0000 (22:30 -0700)
When calculating the padding necessary to align the end of the relro
segment to a page boundary, gold erroneously ignores the .tdata section
when checking to see if there are any relro sections (so if .tdata
is the only relro section, we fail to align the segment properly),
and erroneously pads the cumulative size of the segment based on
the alignment of .tbss. If there are no relro sections following .tbss,
it then fails to note the padding needed at the end of .tdata.

This patch fixes both problems. is_first_section_relro() will return
true when it sees a .tdata section, and we do not align the cumulative
size until after checking for the .tbss section.

gold/
PR gold/14217
* output.cc (Output_segment::is_first_section_relro): Don't ignore
.tdata section.
(Output_segment::set_section_addresses): Don't align size of relro
segment for .tbss.

gold/ChangeLog
gold/output.cc

index cc0aed32ef1c165b74b851c96843bb2582ca878c..7d281a9f23f73f0bb8cf7aa8daf67e9466e00b87 100644 (file)
@@ -1,3 +1,11 @@
+2015-03-21  Cary Coutant  <cary@google.com>
+
+       PR gold/14217
+       * output.cc (Output_segment::is_first_section_relro): Don't ignore
+       .tdata section.
+       (Output_segment::set_section_addresses): Don't align size of relro
+       segment for .tbss.
+
 2015-03-21  Cary Coutant  <cary@google.com>
 
        PR gold/18010
index 8faa0403dbb0a8b5d063481a3358c5e4efeec1f6..516e01daff1e8de30a737b01be218168f5d4da6a 100644 (file)
@@ -4176,8 +4176,7 @@ Output_segment::is_first_section_relro() const
 {
   for (int i = 0; i < static_cast<int>(ORDER_MAX); ++i)
     {
-      if (i == static_cast<int>(ORDER_TLS_DATA)
-         || i == static_cast<int>(ORDER_TLS_BSS))
+      if (i == static_cast<int>(ORDER_TLS_BSS))
        continue;
       const Output_data_list* pdl = &this->output_lists_[i];
       if (!pdl->empty())
@@ -4305,11 +4304,11 @@ Output_segment::set_section_addresses(const Target* target,
                  align = max_align;
                  in_tls = false;
                }
-             relro_size = align_address(relro_size, align);
              // Ignore the size of the .tbss section.
              if ((*p)->is_section_flag_set(elfcpp::SHF_TLS)
                  && (*p)->is_section_type(elfcpp::SHT_NOBITS))
                continue;
+             relro_size = align_address(relro_size, align);
              if ((*p)->is_address_valid())
                relro_size += (*p)->data_size();
              else
This page took 0.036049 seconds and 4 git commands to generate.