Bug 26878 - elflint reports error on SHT_X86_64_UNWIND .eh_frame section
Summary: elflint reports error on SHT_X86_64_UNWIND .eh_frame section
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-11-13 14:58 UTC by Timm Bäder
Modified: 2020-11-18 11:38 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
elfstrmerge.o compiled with clang (18.64 KB, application/x-object)
2020-11-13 14:58 UTC, Timm Bäder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timm Bäder 2020-11-13 14:58:41 UTC
Created attachment 12953 [details]
elfstrmerge.o compiled with clang

gold and clang seem to emit .eh_frame sections of type SHT_X86_64_UNWIND.

If they are used to compile elfutils itself, the testsuite will use one of the .o files in tests/ and run elflint against it and check the output. elflint will then complain:

elflint /home/tbaeder/elfutils/build-clang/tests/elfstrmerge.o
section [19] '.rela.eh_frame': invalid destination section type

Attached is the tests/elfstrmerge.o of an elfutils build with clang, which exhibits this problem.
Comment 1 Mark Wielaard 2020-11-17 13:45:39 UTC
(In reply to Timm Bäder from comment #0)
> Created attachment 12953 [details]
> elfstrmerge.o compiled with clang
> 
> gold and clang seem to emit .eh_frame sections of type SHT_X86_64_UNWIND.

And we already handle gold, which (normally) outputs .eh_frame (and .eh_frame_hdr) without any relocations (because that is what a linker does, resolve the relocations :). So for non-ET_REL files we already seem to handle SHT_X86_64_UNWIND see:

commit 22ec8efc1dd87cdc7892523457eb55990b967224
Author: Mark Wielaard <mark@klomp.org>
Date:   Sat Nov 10 23:33:03 2018 +0100

    elflint: Allow PT_GNU_EH_FRAME segment to match SHT_X86_64_UNWIND section.
    
    The gold linker might generate an .eh_frame_hdr with a SHT_X86_64_UNWIND
    type instead of a SHT_PROGBITS type.
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>

commit 4b0342b85b5b1a3d3636e06e3b5320954828dfb1
Author: Mark Wielaard <mark@klomp.org>
Date:   Tue Nov 6 12:01:25 2018 +0100

    backends: Add x86_64 section_type_name for SHT_X86_64_UNWIND.
    
    Makes sure that eu-readelf and eu-elflint recognize and show the
    x86_64 specific section type correctly.
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>
    Tested-by: Milian Wolff <milian.wolff@kdab.com>

And I see that Navin just posted a fix for eblcheckreloctargettype:
https://sourceware.org/pipermail/elfutils-devel/2020q4/003127.html
Comment 2 Mark Wielaard 2020-11-18 11:38:18 UTC
commit 00a25cf38d56bacae6b82c79cf226c22d12295a5
Author: Mark Wielaard <mark@klomp.org>
Date:   Tue Nov 17 15:08:05 2020 +0100

    backends: Handle SHT_X86_64_UNWIND as valid relocation target type.
    
    The x86_64 abi defines a special section type for .eh_frame[_hdr],
    SHT_X86_64_UNWIND, which is a valid relocation target type.
    
    https://sourceware.org/bugzilla/show_bug.cgi?id=26878
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>