From: H.J. Lu Date: Tue, 5 Jul 2022 19:45:23 +0000 (-0700) Subject: elf: Copy p_align of PT_GNU_STACK for stack alignment X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fb5a4a581d4fbd02ae41e034439872a169e43f0b;p=binutils-gdb.git elf: Copy p_align of PT_GNU_STACK for stack alignment commit 74e315dbfe5200c473b226e937935fb8ce391489 Author: H.J. Lu 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. --- 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