ANDROID: modpost: Don't complain about empty non-allocatable ELF sections

Depending upon the toolchain, empty ELF sections in the object files
of a hypervisor module can be emitted with unusual flags such as
"Writeable, non-allocatable" which modpost gets grumpy about:

  | WARNING: modpost: drivers/misc/pkvm-pl011/pkvm_pl011.o (.hyp.rodata): unexpected non-allocatable section.

Since these sections are empty, whether or not they are allocatable is
not of any concern to the module loader, so adjust the check in modpost
to quietly tolerate this insanity.

Bug: 357781595
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 269245057
Change-Id: I6bf0ccdb1c0440b0a117ea0a0949aff47f7ccadb
This commit is contained in:
Will Deacon
2023-02-16 19:08:26 +00:00
committed by Keir Fraser
parent a451f5def6
commit 8903638740
+1
View File
@@ -758,6 +758,7 @@ static void check_section(const char *modname, struct elf_info *elf,
const char *sec = sech_name(elf, sechdr);
if (sechdr->sh_type == SHT_PROGBITS &&
sechdr->sh_size > 0 &&
!(sechdr->sh_flags & SHF_ALLOC) &&
!match(sec, section_white_list)) {
warn("%s (%s): unexpected non-allocatable section.\n"