xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-devtools/elfutils/files/0003-fixheadercheck.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunFrom 7e1f91c42ef5b0bf10afefec10dd08588df3ab1f Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Hongxu Jia <hongxu.jia@windriver.com>
3*4882a593SmuzhiyunDate: Tue, 15 Aug 2017 17:17:20 +0800
4*4882a593SmuzhiyunSubject: [PATCH] fixheadercheck
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunFor some binaries we can get a invalid section alignment, for example if
7*4882a593Smuzhiyunsh_align = 1 and sh_addralign is 0. In the case of a zero size section
8*4882a593Smuzhiyunlike
9*4882a593Smuzhiyun".note.GNU-stack", this is irrelavent as far as I can tell and we
10*4882a593Smuzhiyunshouldn't
11*4882a593Smuzhiyunerror in this case.
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunRP 2014/6/11
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunUpstream-Status: Pending
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunRebase to 0.170
18*4882a593SmuzhiyunSigned-off-by: Hongxu Jia <hongxu.jia@windriver.com>
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun---
21*4882a593Smuzhiyun libelf/elf32_updatenull.c | 4 ++--
22*4882a593Smuzhiyun 1 file changed, 2 insertions(+), 2 deletions(-)
23*4882a593Smuzhiyun
24*4882a593Smuzhiyundiff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
25*4882a593Smuzhiyunindex d0d4d1e..4ecf5a5 100644
26*4882a593Smuzhiyun--- a/libelf/elf32_updatenull.c
27*4882a593Smuzhiyun+++ b/libelf/elf32_updatenull.c
28*4882a593Smuzhiyun@@ -354,8 +354,8 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
29*4882a593Smuzhiyun 		     we test for the alignment of the section being large
30*4882a593Smuzhiyun 		     enough for the largest alignment required by a data
31*4882a593Smuzhiyun 		     block.  */
32*4882a593Smuzhiyun-		  if (unlikely (! powerof2 (shdr->sh_addralign))
33*4882a593Smuzhiyun-		      || unlikely ((shdr->sh_addralign ?: 1) < sh_align))
34*4882a593Smuzhiyun+		  if (shdr->sh_size && (unlikely (! powerof2 (shdr->sh_addralign))
35*4882a593Smuzhiyun+		      || unlikely ((shdr->sh_addralign ?: 1) < sh_align)))
36*4882a593Smuzhiyun 		    {
37*4882a593Smuzhiyun 		      __libelf_seterrno (ELF_E_INVALID_ALIGN);
38*4882a593Smuzhiyun 		      return -1;
39