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.

Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 269245057
Change-Id: I6bf0ccdb1c0440b0a117ea0a0949aff47f7ccadb
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 44a55ae..2c25cf2 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -902,6 +902,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"