[PATCH] elflint: Allow SHF_EXCLUDE as generic section flag when --gnu is given.

Mark Wielaard mark@klomp.org
Thu Apr 16 16:53:41 GMT 2020


Strictly speaking SHF_EXCLUDE is a processor specific section flag,
but it is used generically in the GNU toolchain. For example when
adding .gnu.lto_ sections.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog | 5 +++++
 src/elflint.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index e11fe79a..dc345a04 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-16  Mark Wielaard  <mark@klomp.org>
+
+	* elflint.c (check_sections): Mask out SHF_EXCLUDE from processor
+	specific section flags when --gnu is given.
+
 2020-02-08  Mark Wielaard  <mark@klomp.org>
 
 	* elflint.c (check_program_header): Handle PT_GNU_PROPERTY.
diff --git a/src/elflint.c b/src/elflint.c
index 480d84ba..0ef43236 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -3921,6 +3921,11 @@ section [%2zu] '%s': size not multiple of entry size\n"),
 	  GElf_Xword sh_flags = shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS;
 	  if (sh_flags & SHF_MASKPROC)
 	    {
+	      /* Strictly speaking SHF_EXCLUDE is a processor specific
+		 section flag, but it is used generically in the GNU
+		 toolchain.  */
+	      if (gnuld)
+		sh_flags &= ~(GElf_Xword) SHF_EXCLUDE;
 	      if (!ebl_machine_section_flag_check (ebl,
 						   sh_flags & SHF_MASKPROC))
 		ERROR (gettext ("section [%2zu] '%s'"
-- 
2.18.2



More information about the Elfutils-devel mailing list