From 5a1393b3cb8e73b0ed89291284699719fd19ccef Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 6 Mar 2018 11:14:08 +0000 Subject: [PATCH] Move function_asm_name() into annobin.cc and have it cope with asterisk prefixed assembler names --- plugin/annobin.cc | 27 +++++++++++++++++++++++++++ plugin/annobin.h | 12 ------------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/plugin/annobin.cc b/plugin/annobin.cc index 41709cb..5a25dfc 100644 --- a/plugin/annobin.cc +++ b/plugin/annobin.cc @@ -615,6 +615,33 @@ record_cf_protection_note (const char * start, const char * end, int type) } #endif +static const char * +function_asm_name (void) +{ + if (! current_function_decl) + return NULL; + + tree name = DECL_ASSEMBLER_NAME (current_function_decl); + + if (name == NULL) + return NULL; + + const char * id = IDENTIFIER_POINTER (name); + + if (id == NULL) + return NULL; + + /* Functions annotated with the asm() function attribute will have + an asterisk prefix. Skip it, so that we do not generate invalid + assembler symbol names. */ + if (*id == '*') + id ++; + + if (*id == '0') + return NULL; + + return id; +} static void annobin_create_function_notes (void * gcc_data, void * user_data) diff --git a/plugin/annobin.h b/plugin/annobin.h index eaf315b..6d2898c 100644 --- a/plugin/annobin.h +++ b/plugin/annobin.h @@ -110,15 +110,3 @@ extern bool annobin_is_64bit; extern bool annobin_enable_stack_size_notes; extern unsigned long annobin_total_static_stack_usage; extern unsigned long annobin_max_stack_size; - -inline const char * -function_asm_name (void) -{ - if (current_function_decl) - { - tree name = DECL_ASSEMBLER_NAME (current_function_decl); - if (name) - return IDENTIFIER_POINTER (name); - } - return NULL; -} -- 2.43.5