public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Subject: [PATCH] elf: Copy p_align of PT_GNU_STACK for stack alignment
Date: Tue,  5 Jul 2022 12:50:22 -0700	[thread overview]
Message-ID: <20220705195022.346635-1-hjl.tools@gmail.com> (raw)

commit 74e315dbfe5200c473b226e937935fb8ce391489
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Dec 13 19:46:04 2021 -0800

    elf: Set p_align to the minimum page size if possible

may ignore p_align of PT_GNU_STACK when copying ELF program header if
the maximum page size is larger than p_align of PT_LOAD segments.  Copy
p_align of PT_GNU_STACK since p_align of PT_GNU_STACK describes stack
alignment, not page size,

	PR binutils/29319
	* elf.c (copy_elf_program_header): Copy p_align of PT_GNU_STACK
	for stack alignment.
---
 bfd/elf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bfd/elf.c b/bfd/elf.c
index 468d37f5028..89484ceb233 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7685,7 +7685,9 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
       map->p_paddr = segment->p_paddr;
       map->p_paddr_valid = p_paddr_valid;
       map->p_align = segment->p_align;
-      map->p_align_valid = p_palign_valid;
+      /* Keep p_align of PT_GNU_STACK for stack alignment.  */
+      map->p_align_valid = (map->p_type == PT_GNU_STACK
+			    || p_palign_valid);
       map->p_vaddr_offset = 0;
 
       if (map->p_type == PT_GNU_RELRO
-- 
2.36.1


             reply	other threads:[~2022-07-05 19:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 19:50 H.J. Lu [this message]
2022-07-06  6:20 ` Jan Beulich

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=20220705195022.346635-1-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@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).