This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gold commit] Fix internal error in gold when -Map and --compress-debug-sections are used together


When -Map is used, we print the map before compressing the debug sections,
so section sizes are not yet finalized, and we hit an internal assertion
when we try to get the size of a to-be-compressed section. This patch prints
the offsets and sizes before compression, and also fixes a related bug
where the map was showing the compressed sizes of input sections instead of
their uncompressed sizes.

-cary


2014-12-16  Cary Coutant  <ccoutant@google.com>

gold/
        * mapfile.cc (Mapfile::print_input_section): Print uncompressed sizes.
        (Mapfile::print_output_data): Use current_data_size() to avoid
        assert for sections requiring postprocessing; if address is not valid,
        print 0.
        (Mapfile::print_output_section): Use current_data_size(); print note
        that addresses and sizes are before compression.


diff --git a/gold/mapfile.cc b/gold/mapfile.cc
index dc995e9..c6d7ed2 100644
--- a/gold/mapfile.cc
+++ b/gold/mapfile.cc
@@ -258,8 +258,11 @@ Mapfile::print_input_section(Relobj* relobj,
unsigned int shndx)
     }

   char sizebuf[50];
+  section_size_type size;
+  if (!relobj->section_is_compressed(shndx, &size))
+    size = relobj->section_size(shndx);
   snprintf(sizebuf, sizeof sizebuf, "0x%llx",
-          static_cast<unsigned long long>(relobj->section_size(shndx)));
+          static_cast<unsigned long long>(size));

   fprintf(this->map_file_, "0x%0*llx %10s %s\n",
          parameters->target().get_size() / 4,
@@ -328,11 +331,13 @@ Mapfile::print_output_data(const Output_data*
od, const char* name)

   char sizebuf[50];
   snprintf(sizebuf, sizeof sizebuf, "0x%llx",
-          static_cast<unsigned long long>(od->data_size()));
+          static_cast<unsigned long long>(od->current_data_size()));

   fprintf(this->map_file_, "0x%0*llx %10s\n",
          parameters->target().get_size() / 4,
-         static_cast<unsigned long long>(od->address()),
+         (od->is_address_valid()
+          ? static_cast<unsigned long long>(od->address())
+          : 0),
          sizebuf);
 }

@@ -387,7 +392,7 @@ Mapfile::print_output_section(const Output_section* os)

   char sizebuf[50];
   snprintf(sizebuf, sizeof sizebuf, "0x%llx",
-          static_cast<unsigned long long>(os->data_size()));
+          static_cast<unsigned long long>(os->current_data_size()));

   fprintf(this->map_file_, "0x%0*llx %10s",
          parameters->target().get_size() / 4,
@@ -398,6 +403,9 @@ Mapfile::print_output_section(const Output_section* os)
            parameters->target().get_size() / 4,
            static_cast<unsigned long long>(os->load_address()));

+  if (os->requires_postprocessing())
+    fprintf(this->map_file_, " (before compression)");
+
   putc('\n', this->map_file_);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]