public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@dabbelt.com>
To: gingold@adacore.com
To: binutils@sourceware.org
Cc: Andrew Waterman <andrew@sifive.com>
Subject: [PATCH] Fix segfault when .plt section does not exist
Date: Wed, 08 Feb 2017 02:14:00 -0000	[thread overview]
Message-ID: <20170208021416.834-2-palmer@dabbelt.com> (raw)
In-Reply-To: <20170208021416.834-1-palmer@dabbelt.com>

From: Andrew Waterman <andrew@sifive.com>

bfd/ChangeLog

2017-02-07  Andrew Waterman  <andrew@sifive.com>

	* elfnn-riscv.c (riscv_elf_finish_dynamic_sections): Only write PLT
	entry size if PLT header is written.
---
 bfd/ChangeLog     | 5 +++++
 bfd/elfnn-riscv.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 244d190..6c21e77 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-07  Andrew Waterman  <andrew@sifive.com>
+
+	* elfnn-riscv.c (riscv_elf_finish_dynamic_sections): Only write PLT
+	entry size if PLT header is written.
+
 2017-02-03  Alan Modra  <amodra@gmail.com>
 
 	* elf32-hppa.c (ensure_undef_weak_dynamic): New function.
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index f414429..210007d 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2502,10 +2502,10 @@ riscv_elf_finish_dynamic_sections (bfd *output_bfd,
 
 	  for (i = 0; i < PLT_HEADER_INSNS; i++)
 	    bfd_put_32 (output_bfd, plt_header[i], splt->contents + 4*i);
-	}
 
-      elf_section_data (splt->output_section)->this_hdr.sh_entsize
-	= PLT_ENTRY_SIZE;
+	  elf_section_data (splt->output_section)->this_hdr.sh_entsize
+	    = PLT_ENTRY_SIZE;
+	}
     }
 
   if (htab->elf.sgotplt)
-- 
2.10.2

  reply	other threads:[~2017-02-08  2:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08  2:14 binutils-2_28-branch: " Palmer Dabbelt
2017-02-08  2:14 ` Palmer Dabbelt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-01-24 20:36 Palmer Dabbelt
2017-01-24 20:36 ` [PATCH] " Palmer Dabbelt
2017-01-24 22:06   ` Maciej W. Rozycki
2017-02-03 21:12     ` Palmer Dabbelt
2017-02-03 21:12       ` [PATCH] " Palmer Dabbelt
2017-02-08  2:06         ` Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170208021416.834-2-palmer@dabbelt.com \
    --to=palmer@dabbelt.com \
    --cc=andrew@sifive.com \
    --cc=gingold@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).