LCOV - code coverage report
Current view: top level - gcc/config/i386 - gnu-property.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 90.4 % 52 47
Test Date: 2024-04-13 14:00:49 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Functions for x86 GNU property.
       2                 :             :    Copyright (C) 2017-2024 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify
       7                 :             : it under the terms of the GNU General Public License as published by
       8                 :             : the Free Software Foundation; either version 3, or (at your option)
       9                 :             : any later version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful,
      12                 :             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :             : GNU General Public License for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : #include "config.h"
      21                 :             : #include "system.h"
      22                 :             : #include "coretypes.h"
      23                 :             : #include "tm.h"
      24                 :             : #include "output.h"
      25                 :             : #include "linux-common.h"
      26                 :             : #include "i386-protos.h"
      27                 :             : 
      28                 :             : static void
      29                 :       18142 : emit_gnu_property (unsigned int type, unsigned int data)
      30                 :             : {
      31                 :       18142 :   int p2align = ptr_mode == SImode ? 2 : 3;
      32                 :             : 
      33                 :       18142 :   switch_to_section (get_section (".note.gnu.property",
      34                 :             :                                   SECTION_NOTYPE, NULL));
      35                 :             : 
      36                 :       18142 :   ASM_OUTPUT_ALIGN (asm_out_file, p2align);
      37                 :             :   /* name length.  */
      38                 :       18142 :   fprintf (asm_out_file, ASM_LONG "1f - 0f\n");
      39                 :             :   /* data length.  */
      40                 :       18142 :   fprintf (asm_out_file, ASM_LONG "4f - 1f\n");
      41                 :             :   /* note type: NT_GNU_PROPERTY_TYPE_0.  */
      42                 :       18142 :   fprintf (asm_out_file, ASM_LONG "5\n");
      43                 :       18142 :   fprintf (asm_out_file, "0:\n");
      44                 :             :   /* vendor name: "GNU".  */
      45                 :       18142 :   fprintf (asm_out_file, STRING_ASM_OP "\"GNU\"\n");
      46                 :       18142 :   fprintf (asm_out_file, "1:\n");
      47                 :       18142 :   ASM_OUTPUT_ALIGN (asm_out_file, p2align);
      48                 :             :   /* pr_type.  */
      49                 :       18142 :   fprintf (asm_out_file, ASM_LONG "0x%x\n", type);
      50                 :             :   /* pr_datasz.  */
      51                 :       18142 :   fprintf (asm_out_file, ASM_LONG "3f - 2f\n");
      52                 :       18142 :   fprintf (asm_out_file, "2:\n");
      53                 :       18142 :   fprintf (asm_out_file, ASM_LONG "0x%x\n", data);
      54                 :       18142 :   fprintf (asm_out_file, "3:\n");
      55                 :       18142 :   ASM_OUTPUT_ALIGN (asm_out_file, p2align);
      56                 :       18142 :   fprintf (asm_out_file, "4:\n");
      57                 :       18142 : }
      58                 :             : 
      59                 :             : void
      60                 :      237835 : file_end_indicate_exec_stack_and_gnu_property (void)
      61                 :             : {
      62                 :      237835 :   file_end_indicate_exec_stack ();
      63                 :             : 
      64                 :      237835 :   if (flag_cf_protection == CF_NONE
      65                 :      219716 :       && !ix86_needed
      66                 :      219716 :       && !ix86_has_no_direct_extern_access)
      67                 :             :     return;
      68                 :             : 
      69                 :       18143 :   unsigned int feature_1 = 0;
      70                 :             : 
      71                 :       18143 :   if (flag_cf_protection & CF_BRANCH)
      72                 :             :     /* GNU_PROPERTY_X86_FEATURE_1_IBT.  */
      73                 :       18105 :     feature_1 |= 0x1;
      74                 :             : 
      75                 :       18143 :   if (flag_cf_protection & CF_RETURN)
      76                 :             :     /* GNU_PROPERTY_X86_FEATURE_1_SHSTK.  */
      77                 :       18088 :     feature_1 |= 0x2;
      78                 :             : 
      79                 :             :   /* Generate GNU_PROPERTY_X86_FEATURE_1_AND.  */
      80                 :       18143 :   if (feature_1)
      81                 :       18117 :     emit_gnu_property (0xc0000002, feature_1);
      82                 :             : 
      83                 :       18143 :   unsigned int isa_1 = 0;
      84                 :       18143 :   if (ix86_needed)
      85                 :             :     {
      86                 :             :       /* GNU_PROPERTY_X86_ISA_1_BASELINE.  */
      87                 :           1 :       if (TARGET_64BIT
      88                 :           1 :           || TARGET_FXSR
      89                 :           0 :           || TARGET_80387
      90                 :             :           || TARGET_MMX
      91                 :             :           || TARGET_SSE
      92                 :           0 :           || TARGET_SSE2)
      93                 :           1 :         isa_1 |= 1 << 0;
      94                 :             : 
      95                 :             :       /* GNU_PROPERTY_X86_ISA_1_V2.  */
      96                 :           1 :       if (TARGET_CMPXCHG16B
      97                 :           1 :           || (TARGET_64BIT && TARGET_SAHF)
      98                 :             :           || TARGET_POPCNT
      99                 :             :           || TARGET_SSE3
     100                 :             :           || TARGET_SSSE3
     101                 :             :           || TARGET_SSE4_1
     102                 :           1 :           || TARGET_SSE4_2)
     103                 :           0 :         isa_1 |= 1 << 1;
     104                 :             : 
     105                 :             :       /* GNU_PROPERTY_X86_ISA_1_V3.  */
     106                 :           1 :       if (TARGET_AVX
     107                 :             :           || TARGET_AVX2
     108                 :             :           || TARGET_F16C
     109                 :             :           || TARGET_FMA
     110                 :             :           || TARGET_LZCNT
     111                 :           1 :           || TARGET_MOVBE
     112                 :           1 :           || TARGET_XSAVE)
     113                 :           0 :         isa_1 |= 1 << 2;
     114                 :             : 
     115                 :             :       /* GNU_PROPERTY_X86_ISA_1_V4.  */
     116                 :           1 :       if (TARGET_AVX512F
     117                 :             :           || TARGET_AVX512BW
     118                 :             :           || TARGET_AVX512CD
     119                 :             :           || TARGET_AVX512DQ
     120                 :             :           || TARGET_AVX512VL)
     121                 :           0 :         isa_1 |= 1 << 3;
     122                 :             :     }
     123                 :             : 
     124                 :             :   /* Generate GNU_PROPERTY_X86_ISA_1_NEEDED.  */
     125                 :           1 :   if (isa_1)
     126                 :           1 :     emit_gnu_property (0xc0008002, isa_1);
     127                 :             : 
     128                 :       18143 :   if (ix86_has_no_direct_extern_access)
     129                 :             :     /* Emite a GNU_PROPERTY_1_NEEDED note with
     130                 :             :        GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS.  */
     131                 :          24 :     emit_gnu_property (0xb0008000, (1U << 0));
     132                 :             : }
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.