From 8903638740e1b019f1245fe293bad8e781fd277c Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Thu, 16 Feb 2023 19:08:26 +0000 Subject: [PATCH] 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 Bug: 269245057 Change-Id: I6bf0ccdb1c0440b0a117ea0a0949aff47f7ccadb --- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2dc739add5bb..45a28754d9ab 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -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"