aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-09-20 14:52:54 +0930
committerAlan Modra <amodra@gmail.com>2019-09-20 17:38:01 +0930
commit0a9fdbbfd319c09e48ac176fd6386b445534cf42 (patch)
tree34bbb979d8d83fe52a9fbf43893cb7eed6b53f7f
parentAutomatic date update in version.in (diff)
downloadbinutils-gdb-0a9fdbbfd319c09e48ac176fd6386b445534cf42.tar.gz
binutils-gdb-0a9fdbbfd319c09e48ac176fd6386b445534cf42.tar.bz2
binutils-gdb-0a9fdbbfd319c09e48ac176fd6386b445534cf42.zip
[GOLD] Fix spurious "plugin needed to handle lto object" warnings
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. (cherry picked from commit 4c51dacacf8a97194a1241ad5e1cbf7be00a59a3)
-rw-r--r--gold/ChangeLog7
-rw-r--r--gold/layout.cc1
-rw-r--r--gold/object.cc13
3 files changed, 17 insertions, 4 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 77a72e3742b..d49a37ce87a 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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-09 Phil Blundell <pb@pbcl.net>
binutils 2.33 branch created.
diff --git a/gold/layout.cc b/gold/layout.cc
index fc7cdf8b8bb..194d088c2a1 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -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),
diff --git a/gold/object.cc b/gold/object.cc
index d505ce47520..2fca7eb2278 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -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();
+ }
}
}