asan_emit_stack_protection stores the address of a $LASANPC label in
each instrumented frame. The label is a VAR_DECL emitted in the text
section, but alpha_in_small_data_p treated it as small data and used a
16-bit GP-relative reference, which can't reach .text:
relocation truncated to fit: GPREL16 against `$LASANPC0'
Seen with g++.dg/asan/pr78651.C. asan.cc marks the decl with
DECL_INITIAL equal to itself; never consider such decls small data.
gcc/ChangeLog:
* config/alpha/alpha.cc (alpha_in_small_data_p): Return false
for decls whose DECL_INITIAL is the decl itself.
---
gcc/config/alpha/alpha.cc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc
index d0fb7eee92f..7355f05182c 100644
--- a/gcc/config/alpha/alpha.cc
+++ b/gcc/config/alpha/alpha.cc
@@ -794,6 +794,11 @@ alpha_in_small_data_p (const_tree exp)
if (VAR_P (exp) && DECL_COMMON (exp))
return false;
+ /* The ASan frame's $LASANPC label (DECL_INITIAL == decl, see
+ asan_emit_stack_protection) is in the text section. */
+ if (VAR_P (exp) && DECL_INITIAL (exp) == exp)
+ return false;
+
if (VAR_P (exp) && DECL_SECTION_NAME (exp))
{
const char *section = DECL_SECTION_NAME (exp);
--
2.56.1