[GOLD] Fix spurious "plugin needed to handle lto object" warnings
authorAlan Modra <amodra@gmail.com>
Fri, 20 Sep 2019 05:22:54 +0000 (14:52 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 20 Sep 2019 06:07:11 +0000 (15:37 +0930)
lto_slim_object_ was unitialized.  I also thought it worth adding
a sanity check on the .gnu.lto_.lto.* section size, and made some
other tidies.

PR 24768
* layout.cc (Layout::Layout): Init lto_slim_object_.
* object.cc (Sized_relobj_file::do_layout): Wrap overlong line.
Don't use C cast.  Validate section size.  Don't copy contents.

gold/ChangeLog
gold/layout.cc
gold/object.cc

index 8ec7014b2a984975f5c18d6030abc57a23549c97..37643cca01b1c3c16fe8e51e35d8cc1c2487a565 100644 (file)
@@ -1,3 +1,10 @@
+2019-09-20  Alan Modra  <amodra@gmail.com>
+
+       PR 24768
+       * layout.cc (Layout::Layout): Init lto_slim_object_.
+       * object.cc (Sized_relobj_file::do_layout): Wrap overlong line.
+       Don't use C cast.  Validate section size.  Don't copy contents.
+
 2019-09-20  Alan Modra  <amodra@gmail.com>
 
        * powerpc.cc (Target_powerpc::Scan::check_non_pic): Move REL24
index fc7cdf8b8bbef679fbb3a664887d839cbc7e7cad..194d088c2a19a4cce1f22ce53f87db77e983ca99 100644 (file)
@@ -466,6 +466,7 @@ Layout::Layout(int number_of_input_files, Script_options* script_options)
     unique_segment_for_sections_specified_(false),
     incremental_inputs_(NULL),
     record_output_section_data_from_script_(false),
+    lto_slim_object_(false),
     script_output_section_data_list_(),
     segment_states_(NULL),
     relaxation_debug_check_(NULL),
index d505ce4752002b2bb2966f3ec1f94a7df4ec65e1..2fca7eb22788257b19de00ddfa5f357957475cfb 100644 (file)
@@ -1884,10 +1884,15 @@ Sized_relobj_file<size, big_endian>::do_layout(Symbol_table* symtab,
       if (strncmp (name, lto_section_name, strlen (lto_section_name)) == 0)
        {
          section_size_type contents_len;
-         const unsigned char* pcontents = this->section_contents(i, &contents_len, false);
-         struct lto_section lsection = *(const lto_section*)pcontents;
-         if (lsection.slim_object)
-           layout->set_lto_slim_object ();
+         const unsigned char* pcontents
+           = this->section_contents(i, &contents_len, false);
+         if (contents_len >= sizeof(lto_section))
+           {
+             const lto_section* lsection
+               = reinterpret_cast<const lto_section*>(pcontents);
+             if (lsection->slim_object)
+               layout->set_lto_slim_object();
+           }
        }
     }
 
This page took 0.029492 seconds and 4 git commands to generate.