Bug 1852781 - Compiling with -flto and -g removes CET support
Summary: Compiling with -flto and -g removes CET support
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gcc
Version: 8.3
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Marek Polacek
QA Contact: Alexandra Petlanová Hájková
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-01 09:59 UTC by Nick Clifton
Modified: 2023-07-18 14:19 UTC (History)
7 users (show)

Fixed In Version: gcc-8.4.1-1.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 13:28:00 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Nick Clifton 2020-07-01 09:59:01 UTC
Description of problem:

  It appears that compiling with -flto enabled disables CET support.

Version-Release number of selected component (if applicable):


How reproducible:

  100% using current RHEL-8.3 latest nightly compose.

Steps to Reproduce:

1. cat delme.c

  int main (void) { return 0; }

2. gcc -fcf-protection delme.c -o delme.exe

3. readelf --wide --notes delme.exe | grep IBT

     GNU    0x00000010	NT_GNU_PROPERTY_TYPE_0	      
     Properties: x86 feature: IBT, SHSTK

4. gcc -fcf-protection -flto delme.c -o delme.lto.exe

5. readelf --wide --notes delme.lto.exe | grep IBT

     GNU    0x00000010	NT_GNU_PROPERTY_TYPE_0	      
     Properties: x86 feature: IBT, SHSTK

6. gcc -fcf-protection -g delme.c -o delme.g.exe

7. readelf --wide --notes delme.g.exe | grep IBT

    GNU    0x00000010	NT_GNU_PROPERTY_TYPE_0	      
     Properties: x86 feature: IBT, SHSTK

8. gcc -fcf-protection -flto -g delme.c -o delme.g.lto.exe

9. readelf --wide --notes delme.g.lto.exe | grep IBT

  <no output>


Expected results:


Additional info:

  Adding -Wl,-Map,delme.g.lto.map to the gcc command line and then looking
  in the map file shows:

    Removed property 0xc0000000 to merge 0x55edf35fc4f0B (not found) and 0x55edf3650e10B (0x0)
    Removed property 0xc0000001 to merge 0x55edf35fc4f0B (not found) and 0x55edf3650e10B (0x0)
    Removed property 0xc0000002 to merge 0x55edf35fc4f0B (0x3) and 0x55edf3822920B (not found)
    Removed property 0xc0000002 to merge 0x55edf35fc4f0B (not found) and 0x55edf3822d30B (0x3)

  For the failing case (-g -flto) but for other cases:

    Removed property 0xc0000000 to merge 0x5640400bf4f0B (not found) and 
0x56404013ff10B (0x0)
    Removed property 0xc0000001 to merge 0x5640400bf4f0B (not found) and 0x56404013ff10B (0x0)

The versions of the tools involved:

  gcc-8.3.1-5.1.el8.x86_64
  binutils-2.30-75.el8.x86_64

Note - This may well be a linker bug, but the fact that it is triggered by adding -g to the gcc command line makes me suspect that gcc, or the LTO plugin, is having problems, rather than ld.

Comment 1 Nick Clifton 2020-07-01 13:31:06 UTC
After talking with H.J. it appears that this problem might be due to this bug:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93966

Comment 13 errata-xmlrpc 2021-05-18 13:28:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (gcc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1571


Note You need to log in before you can comment on or make changes to this bug.