OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.5 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../musl/pkg/gcc/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch
  5. # Copyright (C) 2020 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From d2865d0a184ef59be8893dd34edf5037c4bf48f7 Mon Sep 17 00:00:00 2001
  17. From: Ariadne Conill <ariadne@dereferenced.org>
  18. Date: Fri, 21 Aug 2020 06:46:22 +0000
  19. Subject: [PATCH 04/30] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++,
  20. ObjC, ObjC++, if the optimization level is > 0
  21. ---
  22. gcc/c-family/c-cppbuiltin.c | 4 ++++
  23. gcc/doc/invoke.texi | 6 ++++++
  24. 2 files changed, 10 insertions(+)
  25. diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
  26. index db91a36794a..ed976c71404 100644
  27. --- a/gcc/c-family/c-cppbuiltin.c
  28. +++ b/gcc/c-family/c-cppbuiltin.c
  29. @@ -1385,6 +1385,10 @@ c_cpp_builtins (cpp_reader *pfile)
  30. builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
  31. builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
  32. + /* Fortify Source enabled by default for optimization levels > 0 */
  33. + if (optimize)
  34. + builtin_define_with_int_value ("_FORTIFY_SOURCE", 2);
  35. +
  36. /* Misc. */
  37. if (flag_gnu89_inline)
  38. cpp_define (pfile, "__GNUC_GNU_INLINE__");
  39. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
  40. index ca56d52cb05..f5d5a1d1542 100644
  41. --- a/gcc/doc/invoke.texi
  42. +++ b/gcc/doc/invoke.texi
  43. @@ -9228,6 +9228,12 @@ also turns on the following optimization flags:
  44. Please note the warning under @option{-fgcse} about
  45. invoking @option{-O2} on programs that use computed gotos.
  46. +NOTE: In Alpine Linux, @option{-D_FORTIFY_SOURCE=2} is
  47. +set by default, and is activated when @option{-O} is set to 2 or higher.
  48. +This enables additional compile-time and run-time checks for several libc
  49. +functions. To disable, specify either @option{-U_FORTIFY_SOURCE} or
  50. +@option{-D_FORTIFY_SOURCE=0}.
  51. +
  52. @item -O3
  53. @opindex O3
  54. Optimize yet more. @option{-O3} turns on all optimizations specified
  55. --
  56. 2.27.0