blob: 212b358dc22e214e0577d0a5928270d0939cbf5e [file] [log] [blame]
Andrew Geissler90fd73c2021-03-05 15:25:55 -06001From 7e1f91c42ef5b0bf10afefec10dd08588df3ab1f Mon Sep 17 00:00:00 2001
Brad Bishopd7bf8c12018-02-25 22:55:05 -05002From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Tue, 15 Aug 2017 17:17:20 +0800
Brad Bishop19323692019-04-05 15:28:33 -04004Subject: [PATCH] fixheadercheck
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005
6For some binaries we can get a invalid section alignment, for example if
7sh_align = 1 and sh_addralign is 0. In the case of a zero size section
8like
9".note.GNU-stack", this is irrelavent as far as I can tell and we
10shouldn't
11error in this case.
12
13RP 2014/6/11
14
15Upstream-Status: Pending
16
17Rebase to 0.170
18Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Brad Bishop19323692019-04-05 15:28:33 -040019
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020---
21 libelf/elf32_updatenull.c | 4 ++--
22 1 file changed, 2 insertions(+), 2 deletions(-)
23
24diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
Andrew Geissler90fd73c2021-03-05 15:25:55 -060025index d0d4d1e..4ecf5a5 100644
Brad Bishopd7bf8c12018-02-25 22:55:05 -050026--- a/libelf/elf32_updatenull.c
27+++ b/libelf/elf32_updatenull.c
Andrew Geissler90fd73c2021-03-05 15:25:55 -060028@@ -354,8 +354,8 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050029 we test for the alignment of the section being large
30 enough for the largest alignment required by a data
31 block. */
32- if (unlikely (! powerof2 (shdr->sh_addralign))
33- || unlikely ((shdr->sh_addralign ?: 1) < sh_align))
34+ if (shdr->sh_size && (unlikely (! powerof2 (shdr->sh_addralign))
35+ || unlikely ((shdr->sh_addralign ?: 1) < sh_align)))
36 {
37 __libelf_seterrno (ELF_E_INVALID_ALIGN);
38 return -1;