From a11e44bf67580b34b29ce76dee6fb9cafaf36de1 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 30 Nov 2017 18:53:24 +0100 Subject: [PATCH] Use DECL_ASSEMBLER_NAME for symbol references (#1519165) --- annobin.spec | 7 ++- funname.patch | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 funname.patch diff --git a/annobin.spec b/annobin.spec index 3691828..07dce4a 100644 --- a/annobin.spec +++ b/annobin.spec @@ -1,7 +1,7 @@ Name: annobin Summary: Binary annotation plugin for GCC Version: 2.5.1 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv3+ URL: https://fedoraproject.org/wiki/Toolchain/Watermark @@ -12,6 +12,8 @@ URL: https://fedoraproject.org/wiki/Toolchain/Watermark #--------------------------------------------------------------------------------- Source: https://nickc.fedorapeople.org/annobin-%{version}.tar.xz +Patch1: funname.patch + # This is a gcc plugin, hence gcc is required. Requires: gcc @@ -69,6 +71,9 @@ make check #--------------------------------------------------------------------------------- %changelog +* Thu Nov 30 2017 Florian Weimer - 2.5.1-3 +- Use DECL_ASSEMBLER_NAME for symbol references (#1519165) + * Tue Oct 03 2017 Igor Gnatenko - 2.5.1-2 - Cleanups in spec diff --git a/funname.patch b/funname.patch new file mode 100644 index 0000000..948453e --- /dev/null +++ b/funname.patch @@ -0,0 +1,169 @@ +diff --git a/plugin/aarch64.annobin.cc b/plugin/aarch64.annobin.cc +index ce06b1c..b88ea59 100644 +--- a/plugin/aarch64.annobin.cc ++++ b/plugin/aarch64.annobin.cc +@@ -45,9 +45,11 @@ annobin_target_specific_function_notes (void) + annobin_inform (1, "TLS dialect has changed from %d to %d for %s", + saved_tls_dialect, aarch64_tls_dialect, current_function_name ()); + +- annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_ABI, aarch64_tls_dialect, +- "numeric: ABI: TLS dialect", current_function_name (), +- NT_GNU_BUILD_ATTRIBUTE_FUNC); ++ const char *name = function_asm_name (); ++ if (name != NULL) ++ annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_ABI, aarch64_tls_dialect, ++ "numeric: ABI: TLS dialect", name, ++ NT_GNU_BUILD_ATTRIBUTE_FUNC); + } + + typedef struct +diff --git a/plugin/annobin.cc b/plugin/annobin.cc +index 8e73b24..bb4282f 100644 +--- a/plugin/annobin.cc ++++ b/plugin/annobin.cc +@@ -484,9 +484,11 @@ record_GOW_settings (unsigned int gow, bool local) + if (local) + { + annobin_inform (1, "Record a change in -g/-O/-Wall status for %s", current_function_name ()); +- annobin_output_note (buffer, i + 1, false, "numeric: -g/-O/-Wall", +- current_function_name (), annobin_is_64bit ? 8 : 4, true, +- NT_GNU_BUILD_ATTRIBUTE_FUNC); ++ const char *name = function_asm_name (); ++ if (name != NULL) ++ annobin_output_note (buffer, i + 1, false, "numeric: -g/-O/-Wall", ++ name, annobin_is_64bit ? 8 : 4, true, ++ NT_GNU_BUILD_ATTRIBUTE_FUNC); + } + else + { +@@ -509,17 +511,21 @@ annobin_create_function_notes (void * gcc_data, void * user_data) + annobin_inform (1, "Recording change in stack protection status for %s (from %d to %d)", + current_function_name (), global_stack_prot_option, flag_stack_protect); + +- annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_STACK_PROT, flag_stack_protect, +- "numeric: -fstack-protector status", +- current_function_name (), NT_GNU_BUILD_ATTRIBUTE_FUNC); ++ const char *name = function_asm_name (); ++ if (name != NULL) ++ annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_STACK_PROT, flag_stack_protect, ++ "numeric: -fstack-protector status", ++ name, NT_GNU_BUILD_ATTRIBUTE_FUNC); + } + + if (global_pic_option != compute_pic_option ()) + { + annobin_inform (1, "Recording change in PIC status for %s", current_function_name ()); +- annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_PIC, compute_pic_option (), +- "numeric: pic type", current_function_name (), +- NT_GNU_BUILD_ATTRIBUTE_FUNC); ++ const char *name = function_asm_name (); ++ if (name != NULL) ++ annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_PIC, compute_pic_option (), ++ "numeric: pic type", name, ++ NT_GNU_BUILD_ATTRIBUTE_FUNC); + } + + if (global_GOWall_options != compute_GOWall_options ()) +@@ -528,9 +534,11 @@ annobin_create_function_notes (void * gcc_data, void * user_data) + if (global_short_enums != flag_short_enums) + { + annobin_inform (1, "Recording change in enum size for %s", current_function_name ()); +- annobin_output_bool_note (GNU_BUILD_ATTRIBUTE_SHORT_ENUM, flag_short_enums, +- flag_short_enums ? "bool: short-enums: on" : "bool: short-enums: off", +- current_function_name (), NT_GNU_BUILD_ATTRIBUTE_FUNC); ++ const char *name = function_asm_name (); ++ if (name != NULL) ++ annobin_output_bool_note (GNU_BUILD_ATTRIBUTE_SHORT_ENUM, flag_short_enums, ++ flag_short_enums ? "bool: short-enums: on" : "bool: short-enums: off", ++ name, NT_GNU_BUILD_ATTRIBUTE_FUNC); + } + + +@@ -541,9 +549,11 @@ annobin_create_function_notes (void * gcc_data, void * user_data) + annobin_inform (1, "Recording stack usage of %lu for %s", + current_function_static_stack_size, current_function_name ()); + +- annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_STACK_SIZE, current_function_static_stack_size, +- "numeric: stack-size", current_function_name (), +- NT_GNU_BUILD_ATTRIBUTE_FUNC); ++ const char *name = function_asm_name (); ++ if (name != NULL) ++ annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_STACK_SIZE, current_function_static_stack_size, ++ "numeric: stack-size", name, ++ NT_GNU_BUILD_ATTRIBUTE_FUNC); + } + + annobin_total_static_stack_usage += current_function_static_stack_size; +diff --git a/plugin/annobin.h b/plugin/annobin.h +index 5f8bd64..1957c94 100644 +--- a/plugin/annobin.h ++++ b/plugin/annobin.h +@@ -35,6 +35,7 @@ extern struct plugin_gcc_version gcc_version ATTRIBUTE_UNUSED; + #include + #include + #include ++#include + + #include + +@@ -97,3 +98,15 @@ 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; ++} +diff --git a/plugin/powerpc.annobin.cc b/plugin/powerpc.annobin.cc +index ba85d2d..0057920 100644 +--- a/plugin/powerpc.annobin.cc ++++ b/plugin/powerpc.annobin.cc +@@ -41,11 +41,15 @@ annobin_target_specific_function_notes (void) + if (saved_tls_size == rs6000_tls_size) + return; + ++ const char *name = function_asm_name (); ++ if (name == NULL) ++ return; ++ + annobin_inform (1, "TLS size has changed from %d to %d for %s", +- saved_tls_size, rs6000_tls_size, current_function_name ()); ++ saved_tls_size, rs6000_tls_size, name); + + annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_ABI, rs6000_tls_size, +- "numeric: ABI: TLS size", current_function_name (), ++ "numeric: ABI: TLS size", name, + NT_GNU_BUILD_ATTRIBUTE_FUNC); + } + +diff --git a/plugin/x86_64.annobin.cc b/plugin/x86_64.annobin.cc +index f9c5b03..a03fe94 100644 +--- a/plugin/x86_64.annobin.cc ++++ b/plugin/x86_64.annobin.cc +@@ -63,13 +63,16 @@ annobin_record_global_target_notes (void) + void + annobin_target_specific_function_notes (void) + { ++ const char *name = function_asm_name (); ++ if (name == NULL) ++ return; + if ((unsigned long) ix86_isa_flags != global_x86_isa) + { + annobin_inform (1, "ISA value has changed from %lx to %lx for %s", +- global_x86_isa, ix86_isa_flags, current_function_name ()); ++ global_x86_isa, ix86_isa_flags, name); + + annobin_output_numeric_note (GNU_BUILD_ATTRIBUTE_ABI, ix86_isa_flags, +- "numeric: ABI", current_function_name (), ++ "numeric: ABI", name, + NT_GNU_BUILD_ATTRIBUTE_FUNC); + + if ((unsigned long) ix86_isa_flags < min_x86_isa)