From b20dcadf1c55f5c84d527024290f303e3f63918f Mon Sep 17 00:00:00 2001 From: Evgeny Karpov Date: Thu, 18 Jul 2024 13:03:28 +0200 Subject: [PATCH] Refactor changes for excluding GOT Add a workaround for __main reference in mingw --- gcc/config/aarch64/aarch64.cc | 5 ++++- gcc/config/aarch64/cygming.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 416697e4004..30e3209e9a9 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -20870,6 +20870,9 @@ aarch64_tlsdesc_abi_id () static bool aarch64_symbol_binds_local_p (const_rtx x) { + if (TARGET_PECOFF) + return true; + return (SYMBOL_REF_DECL (x) ? targetm.binds_local_p (SYMBOL_REF_DECL (x)) : SYMBOL_REF_LOCAL_P (x)); @@ -20997,7 +21000,7 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset) if ((flag_pic || SYMBOL_REF_WEAK (x)) && !aarch64_symbol_binds_local_p (x)) return aarch64_cmodel == AARCH64_CMODEL_SMALL_SPIC - ? SYMBOL_SMALL_ABSOLUTE : SYMBOL_SMALL_ABSOLUTE; + ? SYMBOL_SMALL_GOT_28K : SYMBOL_SMALL_GOT_4G; /* Same reasoning as the tiny code model, but the offset cap here is 1MB, allowing +/-3.9GB for the offset to the symbol. */ diff --git a/gcc/config/aarch64/cygming.h b/gcc/config/aarch64/cygming.h index 274432b731f..87ca2ddbac5 100644 --- a/gcc/config/aarch64/cygming.h +++ b/gcc/config/aarch64/cygming.h @@ -295,7 +295,7 @@ do { \ #undef ASM_DECLARE_FUNCTION_NAME #define ASM_DECLARE_FUNCTION_NAME(STR, NAME, DECL) \ - mingw_pe_declare_function_type (STR, NAME, TREE_PUBLIC (DECL)); \ + mingw_pe_declare_function_type (STR, NAME, !strcmp((NAME), "__main") || TREE_PUBLIC (DECL)); \ aarch64_declare_function_name (STR, NAME, DECL)