Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | From dd7c8c730457def5f62ebd43022b2f06df8c6ed9 Mon Sep 17 00:00:00 2001 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2 | From: Hongxu Jia <hongxu.jia@windriver.com> |
| 3 | Date: Tue, 15 Aug 2017 17:17:20 +0800 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 4 | Subject: [PATCH] fixheadercheck |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5 | |
| 6 | For some binaries we can get a invalid section alignment, for example if |
| 7 | sh_align = 1 and sh_addralign is 0. In the case of a zero size section |
| 8 | like |
| 9 | ".note.GNU-stack", this is irrelavent as far as I can tell and we |
| 10 | shouldn't |
| 11 | error in this case. |
| 12 | |
| 13 | RP 2014/6/11 |
| 14 | |
| 15 | Upstream-Status: Pending |
| 16 | |
| 17 | Rebase to 0.170 |
| 18 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 19 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 20 | --- |
| 21 | libelf/elf32_updatenull.c | 4 ++-- |
| 22 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 23 | |
| 24 | diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 25 | index 3e9ef61..5351518 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 26 | --- a/libelf/elf32_updatenull.c |
| 27 | +++ b/libelf/elf32_updatenull.c |
| 28 | @@ -339,8 +339,8 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum) |
| 29 | 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; |