--- annobin.orig/tests/fortify-test 2022-01-10 09:50:07.005146672 +0000 +++ annobin-10.45/tests/fortify-test 2022-01-10 10:23:56.827404265 +0000 @@ -37,30 +37,37 @@ fi # Now add in our newly built plugin. OPTS+=" -fplugin=$PLUGIN" +# For debugging purposes, generate a linker map as well. +OPTS+=" -Wl,-Map,fortify-test.map" + start_test -$GCC $OPTS -Wp,-U_FORTIFY_SOURCE -fno-lto $srcdir/main.c -o main.exe +# Use atexit.c rather than main.c as it is bigger. +COMMAND="$GCC $OPTS -Wp,-U_FORTIFY_SOURCE -fno-lto $srcdir/atexit.c -o fortify-test.exe" +$COMMAND if [ $? != 0 ]; then echo " $TEST_NAME: FAIL: unable to compile test file" - echo " $TEST_NAME: compile command: $GCC $OPTS -Wp,-U_FORTIFY_SOURCE -fno-lto $srcdir/main.c -o main.exe" + echo " $TEST_NAME: command: $COMMAND" end_test exit 1 fi # Run annocheck -SKIPS="--skip-cf-protection --skip-property-note --skip-stack-realign --skip-entry --skip-dynamic-tags --skip-lto --skip-warnings --skip-dynamic-tags --skip-not-dynamic-tags --skip-branch-protection --skip-not-branch-protection" -$ANNOCHECK main.exe $SKIPS > main.out -grep -e "Overall: FAIL" main.out +SKIPS="--skip-all --test-fortify" +A_COMMAND="$ANNOCHECK fortify-test.exe $SKIPS" +$A_COMMAND > fortify-test.out +grep -e "Overall: FAIL" fortify-test.out if [ $? != 0 ]; then echo " $TEST_NAME: FAIL: compiling with -D_FORTIFY_SOURCE=2 still produces an executable that passes annocheck" - echo " $TEST_NAME: compile command: $GCC $OPTS -Wp,-U_FORTIFY_SOURCE -fno-lto $srcdir/main.c -o main.exe" - echo " $TEST_NAME: annocheck command: $ANNOCHECK main.exe $SKIPS" + echo " $TEST_NAME: compile command: $COMMAND" + echo " $TEST_NAME: annocheck command: $A_COMMAND" echo " $TEST_NAME: annocheck output (with verbose enabled):" - $ANNOCHECK main.exe $SKIPS --verbose - uuencode main.exe main.exe + $A_COMMAND --verbose + uuencode fortify-test.exe fortify-test.exe + uuencode fortify-test.map fortify-test.map end_test exit 1 fi --- annobin.orig/gcc-plugin/annobin.cc 2022-01-10 09:50:06.991146761 +0000 +++ annobin-10.45/gcc-plugin/annobin.cc 2022-01-10 11:31:49.507826587 +0000 @@ -1,5 +1,5 @@ /* annobin - a gcc plugin for annotating binary files. - Copyright (c) 2017 - 2021 Red Hat. + Copyright (c) 2017 - 2022 Red Hat. Created by Nick Clifton. This is free software; you can redistribute it and/or modify it @@ -2485,6 +2485,7 @@ annobin_emit_end_symbol (const char * su fprintf (asm_out_file, "\t.size %s%s, 0\n", annobin_current_endname, suffix); annobin_inform (INFORM_VERBOSE, "Create symbol %s%s", annobin_current_endname, suffix); +#if 0 /* If there is a bias to the start symbol, we can end up with the case where the start symbol is after the end symbol. (If the section is empty). Catch that and adjust the start symbol. This also pacifies eu-elflint @@ -2509,7 +2510,8 @@ annobin_emit_end_symbol (const char * su annobin_current_endname, suffix); fprintf (asm_out_file, "\t.endif\n"); } - +#endif + fprintf (asm_out_file, "\t.popsection\n"); } @@ -2774,7 +2776,7 @@ plugin_init (struct plugin_name_args * solution is needed. */ annobin_attach_type = group; #if GCCPLUGIN_VERSION_MAJOR >= 11 - if (target_start_sym_bias == 0) + /* if (target_start_sym_bias == 0)*/ annobin_attach_type = link_order; #endif }