Example test failures (had to add GNU_RETAIN printer): FAIL: run-strip-strmerge.sh elflint /home/slyfox/dev/git/elfutils/tests/elfstrmerge section [19] '.init_array' has wrong flags: expected WRITE|ALLOC, is WRITE|ALLOC|GNU_RETAIN section [20] '.fini_array' has wrong flags: expected WRITE|ALLOC, is WRITE|ALLOC|GNU_RETAIN FAIL run-strip-strmerge.sh (exit status: 1) FAIL: run-elflint-self.sh FAIL: run-reverse-sections-self.sh
I mis-interpreter the change that caused test failures. elfutils built with gcc-10.2.0 still passes the tests. gcc-11 does not pass tests, probably after https://gcc.gnu.org/PR98146
You are right and thanks to your patches it is clear what is going on. I could replicate it using both binutils and gcc from git. Proposed patch to properly handle SHF_GNU_RETAIN in eu-elflint: https://sourceware.org/pipermail/elfutils-devel/2021q1/003397.html
commit 7024796b63fff42274adb85cd36dbec2c55480c6 Author: Mark Wielaard <mark@klomp.org> Date: Tue Jan 12 11:35:10 2021 +0100 elflint: Recognize SHF_GNU_RETAIN as extra section flag. SHF_GNU_RETAIN is like SHF_LINK_ORDER it can appear on any section and should be ignored by elflint. Add all such flags to a new EXTRA_SHFLAGS and use it consistently in check_sections. https://sourceware.org/bugzilla/show_bug.cgi?id=27134 Signed-off-by: Mark Wielaard <mark@klomp.org>