Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From 565d5935abf5b58773f9c8385c00189221980d98 Mon Sep 17 00:00:00 2001 |
| 2 | From: Hongxu Jia <hongxu.jia@windriver.com> |
| 3 | Date: Tue, 15 Aug 2017 17:17:20 +0800 |
| 4 | Subject: [PATCH 3/7] fixheadercheck |
| 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> |
| 19 | --- |
| 20 | libelf/elf32_updatenull.c | 4 ++-- |
| 21 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 22 | |
| 23 | diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c |
| 24 | index d83c0b3..a51bf70 100644 |
| 25 | --- a/libelf/elf32_updatenull.c |
| 26 | +++ b/libelf/elf32_updatenull.c |
| 27 | @@ -339,8 +339,8 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum) |
| 28 | we test for the alignment of the section being large |
| 29 | enough for the largest alignment required by a data |
| 30 | block. */ |
| 31 | - if (unlikely (! powerof2 (shdr->sh_addralign)) |
| 32 | - || unlikely ((shdr->sh_addralign ?: 1) < sh_align)) |
| 33 | + if (shdr->sh_size && (unlikely (! powerof2 (shdr->sh_addralign)) |
| 34 | + || unlikely ((shdr->sh_addralign ?: 1) < sh_align))) |
| 35 | { |
| 36 | __libelf_seterrno (ELF_E_INVALID_ALIGN); |
| 37 | return -1; |
| 38 | -- |
| 39 | 1.8.3.1 |
| 40 | |