Bug 27134 - elfutils-git fails tests against gcc-git (GNU_RETAIN section type)
Summary: elfutils-git fails tests against gcc-git (GNU_RETAIN section type)
Status: RESOLVED FIXED
Alias: None
Product: elfutils
Classification: Unclassified
Component: libelf (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-31 11:51 UTC by Sergei Trofimovich
Modified: 2021-01-15 11:00 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2021-01-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2020-12-31 11:51:23 UTC
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
Comment 1 Sergei Trofimovich 2020-12-31 13:43:55 UTC
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
Comment 2 Mark Wielaard 2021-01-12 10:40:03 UTC
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
Comment 3 Mark Wielaard 2021-01-15 11:00:48 UTC
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>