Documentation of __stack_chk_guard

@deftypefn {Target Hook} tree TARGET_STACK_PROTECT_GUARD (void)
This hook returns a @code{DECL} node for the external variable to use
for the stack protection guard.  This variable is initialized by the
runtime to some random value and is used to initialize the guard value
that is placed at the top of the local stack frame.  The type of this
variable must be @code{ptr_type_node}.

The default version of this hook creates a variable called
@samp{__stack_chk_guard}, which is normally defined in @file{libgcc2.c}.
@end deftypefn

was added by

commit 7d69de618e732d343228a07d797a30e39a6363f4
Author:     Richard Henderson <[email protected]>
AuthorDate: Mon Jun 27 00:41:16 2005 -0700
Commit:     Jakub Jelinek <[email protected]>
CommitDate: Mon Jun 27 09:41:16 2005 +0200

    c-cppbuiltin.c (c_cpp_builtins): Add __SSP_ALL__ and __SSP__.

__stack_chk_guard was moved to libssp later by

commit 77008252819720c987f11b3dade670e2b3ba09b8
Author:     Jakub Jelinek <[email protected]>
AuthorDate: Sat Jul 2 10:52:21 2005 +0200
Commit:     Jakub Jelinek <[email protected]>
CommitDate: Sat Jul 2 10:52:21 2005 +0200

    Makefile.def (target_modules): Add libssp.

Its documentation became stale.  Update __stack_chk_guard type to
uintptr_t if it is a global symbol and its normal location to libssp.

PR libgcc/125190
* target.def (stack_protect_guard): __stack_chk_guard type is
uintptr_t if it is a global symbol.  It is normally defined in
libssp.
(stack_protect_guard_symbol_p): It is in libssp.
* doc/tm.texi: Regenerated.


-- 
H.J.
From 2cb9e1da33dbc251b36ef8c01bf46b53717c5d83 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <[email protected]>
Date: Wed, 6 May 2026 06:16:35 +0800
Subject: [PATCH] Update __stack_chk_guard documentation

Documentation of __stack_chk_guard

@deftypefn {Target Hook} tree TARGET_STACK_PROTECT_GUARD (void)
This hook returns a @code{DECL} node for the external variable to use
for the stack protection guard.  This variable is initialized by the
runtime to some random value and is used to initialize the guard value
that is placed at the top of the local stack frame.  The type of this
variable must be @code{ptr_type_node}.

The default version of this hook creates a variable called
@samp{__stack_chk_guard}, which is normally defined in @file{libgcc2.c}.
@end deftypefn

was added by

commit 7d69de618e732d343228a07d797a30e39a6363f4
Author:     Richard Henderson <[email protected]>
AuthorDate: Mon Jun 27 00:41:16 2005 -0700
Commit:     Jakub Jelinek <[email protected]>
CommitDate: Mon Jun 27 09:41:16 2005 +0200

    c-cppbuiltin.c (c_cpp_builtins): Add __SSP_ALL__ and __SSP__.

__stack_chk_guard was moved to libssp later by

commit 77008252819720c987f11b3dade670e2b3ba09b8
Author:     Jakub Jelinek <[email protected]>
AuthorDate: Sat Jul 2 10:52:21 2005 +0200
Commit:     Jakub Jelinek <[email protected]>
CommitDate: Sat Jul 2 10:52:21 2005 +0200

    Makefile.def (target_modules): Add libssp.

Its documentation became stale.  Update __stack_chk_guard type to
uintptr_t if it is a global symbol and its normal location to libssp.

	PR libgcc/125190
	* target.def (stack_protect_guard): __stack_chk_guard type is
	uintptr_t if it is a global symbol.  It is normally defined in
	libssp.
	(stack_protect_guard_symbol_p): It is in libssp.
	* doc/tm.texi: Regenerated.

Signed-off-by: H.J. Lu <[email protected]>
---
 gcc/doc/tm.texi | 8 +++++---
 gcc/target.def  | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 2a8670b46c1..b63b99ecffa 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5426,15 +5426,17 @@ This hook returns a @code{DECL} node for the external variable to use
 for the stack protection guard.  This variable is initialized by the
 runtime to some random value and is used to initialize the guard value
 that is placed at the top of the local stack frame.  The type of this
-variable must be @code{ptr_type_node}.
+variable must be @code{uintptr_t} if it is defined as a global symbol.
+Otherwise, its type must be @code{ptr_type_node}.
 
 The default version of this hook creates a variable called
-@samp{__stack_chk_guard}, which is normally defined in @file{libgcc2.c}.
+@samp{__stack_chk_guard}, which is normally defined in @file{libssp}
+as a global symbol.
 @end deftypefn
 
 @deftypefn {Target Hook} bool TARGET_STACK_PROTECT_GUARD_SYMBOL_P (void)
 Usually, the compiler uses an external variable @samp{__stack_chk_guard}
-defined in @file{libgcc2.c} as the stack protection guard symbol.  Define
+defined in @file{libssp} as the stack protection guard symbol.  Define
 this hook to return true if a user provided definition of
 @samp{__stack_chk_guard} with the @code{uintptr_t} type is used.
 @end deftypefn
diff --git a/gcc/target.def b/gcc/target.def
index a52205ffba2..e677baaddb8 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4647,10 +4647,12 @@ DEFHOOK
 for the stack protection guard.  This variable is initialized by the\n\
 runtime to some random value and is used to initialize the guard value\n\
 that is placed at the top of the local stack frame.  The type of this\n\
-variable must be @code{ptr_type_node}.\n\
+variable must be @code{uintptr_t} if it is defined as a global symbol.\n\
+Otherwise, its type must be @code{ptr_type_node}.\n\
 \n\
 The default version of this hook creates a variable called\n\
-@samp{__stack_chk_guard}, which is normally defined in @file{libgcc2.c}.",
+@samp{__stack_chk_guard}, which is normally defined in @file{libssp}\n\
+as a global symbol.",
  tree, (void),
  default_stack_protect_guard)
 
@@ -4659,7 +4661,7 @@ The default version of this hook creates a variable called\n\
 DEFHOOK
 (stack_protect_guard_symbol_p,
  "Usually, the compiler uses an external variable @samp{__stack_chk_guard}\n\
-defined in @file{libgcc2.c} as the stack protection guard symbol.  Define\n\
+defined in @file{libssp} as the stack protection guard symbol.  Define\n\
 this hook to return true if a user provided definition of\n\
 @samp{__stack_chk_guard} with the @code{uintptr_t} type is used.",
  bool, (void),
-- 
2.54.0

Reply via email to