]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
elflint: Allow zero p_memsz for PT_RISCV_ATTRIBUTES
authorAndreas Schwab <schwab@suse.de>
Tue, 9 Aug 2022 08:29:53 +0000 (10:29 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 9 Aug 2022 17:08:34 +0000 (19:08 +0200)
The RISCV_ATTRIBUTES segment is not meant to be loaded.

Signed-off-by: Andreas Schwab <schwab@suse.de>
src/ChangeLog
src/elflint.c

index 42ce66401a2984172b1dbf9c773bbc6d69c21171..fbcef29e3e73ea8c2b615249da505cbc877d7031 100644 (file)
@@ -1,3 +1,8 @@
+2022-08-09  Andreas Schwab  <schwab@suse.de>
+
+       * elflint.c (check_program_header): Don't complain about p_filesz
+       > p_memsz if p_memsz is zero and p_type is PT_RISCV_ATTRIBUTES.
+
 2022-08-01  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (handle_dynamic): Pass start of buffer to memrchr.
index d919936fcec184323682d55e819d950847b2c790..b0e5415ef485ad0dbd461cbcd3833b3f744ebda9 100644 (file)
@@ -4731,7 +4731,10 @@ section [%2zu] '%s' must not be executable\n"),
        }
 
       if (phdr->p_filesz > phdr->p_memsz
-         && (phdr->p_memsz != 0 || phdr->p_type != PT_NOTE))
+         && (phdr->p_memsz != 0
+             || (phdr->p_type != PT_NOTE
+                 && !(ehdr->e_machine == EM_RISCV
+                      && phdr->p_type == PT_RISCV_ATTRIBUTES))))
        ERROR (_("\
 program header entry %d: file size greater than memory size\n"),
               cnt);