LCOV - code coverage report
Current view: top level - gcc/config/i386 - cet.c (source / functions) Hit Total Coverage
Test: gcc.info Lines: 25 25 100.0 %
Date: 2020-03-28 11:57:23 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Functions for CET/x86.
       2                 :            :    Copyright (C) 2017-2020 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                 :            : 
      27                 :            : void
      28                 :     171964 : file_end_indicate_exec_stack_and_cet (void)
      29                 :            : {
      30                 :     171964 :   file_end_indicate_exec_stack ();
      31                 :            : 
      32                 :     171964 :   if (flag_cf_protection == CF_NONE)
      33                 :            :     return;
      34                 :            : 
      35                 :        143 :   unsigned int feature_1 = 0;
      36                 :            : 
      37                 :        143 :   if (flag_cf_protection & CF_BRANCH)
      38                 :            :     /* GNU_PROPERTY_X86_FEATURE_1_IBT.  */
      39                 :            :     feature_1 |= 0x1;
      40                 :            : 
      41                 :        143 :   if (flag_cf_protection & CF_RETURN)
      42                 :            :     /* GNU_PROPERTY_X86_FEATURE_1_SHSTK.  */
      43                 :        125 :     feature_1 |= 0x2;
      44                 :            : 
      45                 :        143 :   if (feature_1)
      46                 :            :     {
      47                 :        143 :       int p2align = ptr_mode == SImode ? 2 : 3;
      48                 :            : 
      49                 :            :       /* Generate GNU_PROPERTY_X86_FEATURE_1_XXX.  */
      50                 :        143 :       switch_to_section (get_section (".note.gnu.property",
      51                 :            :                                       SECTION_NOTYPE, NULL));
      52                 :            : 
      53                 :        143 :       ASM_OUTPUT_ALIGN (asm_out_file, p2align);
      54                 :            :       /* name length.  */
      55                 :        143 :       fprintf (asm_out_file, ASM_LONG " 1f - 0f\n");
      56                 :            :       /* data length.  */
      57                 :        143 :       fprintf (asm_out_file, ASM_LONG " 4f - 1f\n");
      58                 :            :       /* note type: NT_GNU_PROPERTY_TYPE_0.  */
      59                 :        143 :       fprintf (asm_out_file, ASM_LONG " 5\n");
      60                 :        143 :       fprintf (asm_out_file, "0:\n");
      61                 :            :       /* vendor name: "GNU".  */
      62                 :        143 :       fprintf (asm_out_file, STRING_ASM_OP " \"GNU\"\n");
      63                 :        143 :       fprintf (asm_out_file, "1:\n");
      64                 :        143 :       ASM_OUTPUT_ALIGN (asm_out_file, p2align);
      65                 :            :       /* pr_type: GNU_PROPERTY_X86_FEATURE_1_AND.  */
      66                 :        143 :       fprintf (asm_out_file, ASM_LONG " 0xc0000002\n");
      67                 :            :       /* pr_datasz.  */\
      68                 :        143 :       fprintf (asm_out_file, ASM_LONG " 3f - 2f\n");
      69                 :        143 :       fprintf (asm_out_file, "2:\n");
      70                 :            :       /* GNU_PROPERTY_X86_FEATURE_1_XXX.  */
      71                 :        143 :       fprintf (asm_out_file, ASM_LONG " 0x%x\n", feature_1);
      72                 :        143 :       fprintf (asm_out_file, "3:\n");
      73                 :        143 :       ASM_OUTPUT_ALIGN (asm_out_file, p2align);
      74                 :        143 :       fprintf (asm_out_file, "4:\n");
      75                 :            :     }
      76                 :            : }

Generated by: LCOV version 1.0

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 --enable-host-shared. GCC test suite is run with the built compiler.