public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: elfutils-devel@sourceware.org
Subject: [PATCH] elflint: Allow zero p_memsz for PT_RISCV_ATTRIBUTES
Date: Tue, 09 Aug 2022 10:29:53 +0200	[thread overview]
Message-ID: <mvm1qtplszi.fsf@suse.de> (raw)

The RISCV_ATTRIBUTES segment is not meant to be loaded.

Signed-off-by: Andreas Schwab <schwab@suse.de>
---
 src/ChangeLog | 5 +++++
 src/elflint.c | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 42ce6640..fbcef29e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2022-08-09  Andreas Schwab  <schwab@suse.de>
+
+	* elflint.c (check_program_header): Don't complain about p_filesz
+	> p_memsz if p_memsz is zero and p_type is PT_RISCV_ATTRIBUTES.
+
 2022-08-01  Mark Wielaard  <mark@klomp.org>
 
 	* readelf.c (handle_dynamic): Pass start of buffer to memrchr.
diff --git a/src/elflint.c b/src/elflint.c
index d919936f..b0e5415e 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -4731,7 +4731,10 @@ section [%2zu] '%s' must not be executable\n"),
 	}
 
       if (phdr->p_filesz > phdr->p_memsz
-	  && (phdr->p_memsz != 0 || phdr->p_type != PT_NOTE))
+	  && (phdr->p_memsz != 0
+	      || (phdr->p_type != PT_NOTE
+		  && !(ehdr->e_machine == EM_RISCV
+		       && phdr->p_type == PT_RISCV_ATTRIBUTES))))
 	ERROR (_("\
 program header entry %d: file size greater than memory size\n"),
 	       cnt);
-- 
2.37.1


-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

             reply	other threads:[~2022-08-09  8:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09  8:29 Andreas Schwab [this message]
2022-08-09 17:11 ` Mark Wielaard

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=mvm1qtplszi.fsf@suse.de \
    --to=schwab@suse.de \
    --cc=elfutils-devel@sourceware.org \
    /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).