aboutsummaryrefslogtreecommitdiff
path: root/gold/object.cc
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 15:37:11 +0930
commit4c51dacacf8a97194a1241ad5e1cbf7be00a59a3 (patch)
tree6f089a1e722057350343f53e8d96468ff3ca8b95 /gold/object.cc
parente59a1001222d853f0517c7e974bb51589ba86710 (diff)
downloadgdb-4c51dacacf8a97194a1241ad5e1cbf7be00a59a3.zip
gdb-4c51dacacf8a97194a1241ad5e1cbf7be00a59a3.tar.gz
gdb-4c51dacacf8a97194a1241ad5e1cbf7be00a59a3.tar.bz2
[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.
Diffstat (limited to 'gold/object.cc')
-rw-r--r--gold/object.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/gold/object.cc b/gold/object.cc
index d505ce4..2fca7eb 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();
+ }
}
}