Skip to content
Snippets Groups Projects
  • Rodrigo Rebello's avatar
    fccd35a0
    configure: use appropriate code fragment for -fstack-protector checks · fccd35a0
    Rodrigo Rebello authored
    
    The check for stack-protector support consisted in compiling and linking
    the test program below (output by function write_c_skeleton()) with the
    compiler flag -fstack-protector-strong first and then with
    -fstack-protector-all if the first one failed to work:
    
      int main(void) { return 0; }
    
    This caused false positives when using certain toolchains in which the
    compiler accepted -fstack-protector-strong but no support was provided
    by the C library, since for this stack-protector variant the compiler
    emits canary code only for functions that meet specific conditions
    (local arrays, memory references to local variables, etc.) and the code
    fragment under test included none of them (hence no stack protection
    code generated, no link failure).
    
    This fix changes the test program used for -fstack-protector checks to
    include a function that meets conditions which cause the compiler to
    generate canary code in all variants.
    
    Signed-off-by: default avatarRodrigo Rebello <rprebello@gmail.com>
    Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
    fccd35a0
    History
    configure: use appropriate code fragment for -fstack-protector checks
    Rodrigo Rebello authored
    
    The check for stack-protector support consisted in compiling and linking
    the test program below (output by function write_c_skeleton()) with the
    compiler flag -fstack-protector-strong first and then with
    -fstack-protector-all if the first one failed to work:
    
      int main(void) { return 0; }
    
    This caused false positives when using certain toolchains in which the
    compiler accepted -fstack-protector-strong but no support was provided
    by the C library, since for this stack-protector variant the compiler
    emits canary code only for functions that meet specific conditions
    (local arrays, memory references to local variables, etc.) and the code
    fragment under test included none of them (hence no stack protection
    code generated, no link failure).
    
    This fix changes the test program used for -fstack-protector checks to
    include a function that meets conditions which cause the compiler to
    generate canary code in all variants.
    
    Signed-off-by: default avatarRodrigo Rebello <rprebello@gmail.com>
    Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>