From 0955937c318a75f1e33bbbb58757d34d019c2554 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 20 Apr 2023 17:20:56 +0100 Subject: [PATCH] 12.06: gcc-plugin: use larger note buffer --- annobin-global.h | 2 +- annocheck/libannocheck.h | 2 +- configure | 2 +- configure.ac | 2 +- gcc-plugin/annobin.cc | 31 ++++++++++++++++++++++++------- gcc-plugin/annobin.h | 2 +- meson.build | 2 +- 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/annobin-global.h b/annobin-global.h index 8b73e3c..2b7bed3 100644 --- a/annobin-global.h +++ b/annobin-global.h @@ -25,7 +25,7 @@ extern "C" { * LIBANNOCHECK_VERSION defined in annocheck/libannocheck.h * 'version' defined in meson.build, * ANNOBIN_VERSION defined in configure.ac. */ -#define ANNOBIN_VERSION 1205 +#define ANNOBIN_VERSION 1206 /* The version of the annotation specification supported. */ #define SPEC_VERSION 4 diff --git a/annocheck/libannocheck.h b/annocheck/libannocheck.h index acac9b4..819b74a 100644 --- a/annocheck/libannocheck.h +++ b/annocheck/libannocheck.h @@ -23,7 +23,7 @@ extern "C" { /* NB/ Keep this value in sync with ANNOBIN_VERSION defined in annobin-global.h. */ -#define LIBANNOCHECK_VERSION 1205 +#define LIBANNOCHECK_VERSION 1206 /* Update this when the libannocheck API changes. v1. Testing. diff --git a/configure b/configure index 757e6e2..57b509d 100755 --- a/configure +++ b/configure @@ -2721,7 +2721,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. -ANNOBIN_VERSION=12.05 +ANNOBIN_VERSION=12.06 # Make sure we can run config.sub. diff --git a/configure.ac b/configure.ac index d836f87..69b2be7 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_INIT([Binary Annotations], 12.0,,[annobin-plugin]) AC_CONFIG_AUX_DIR([config]) AC_CONFIG_SRCDIR([annobin-global.h]) -ANNOBIN_VERSION=12.05 +ANNOBIN_VERSION=12.06 AC_SUBST(ANNOBIN_VERSION) AC_CANONICAL_SYSTEM diff --git a/gcc-plugin/annobin.cc b/gcc-plugin/annobin.cc index 1c98a4b..658c85d 100644 --- a/gcc-plugin/annobin.cc +++ b/gcc-plugin/annobin.cc @@ -160,7 +160,7 @@ static int global_stack_clash_option = -1; static int global_cf_option = -1; #endif -char annobin_note_buffer[128]; +char annobin_note_buffer[2048]; static struct plugin_info annobin_info = { @@ -521,25 +521,42 @@ annobin_gen_string_note (annobin_function_info * info, const char * format, ...) { + char * dst = annobin_note_buffer; va_list args; va_start (args, format); - vsprintf (annobin_note_buffer, format, args); + vsprintf (dst, format, args); va_end (args); if (use_extended_string) { - strcat (annobin_note_buffer, " "); - strcat (annobin_note_buffer, annobin_input_filename); + size_t len = strlen (annobin_note_buffer) + 1 + strlen (annobin_input_filename); if (! is_global (info)) + len += strlen (get_func_name (info)) + 1; + + // Check for extra long file paths/function names. + if (len >= sizeof annobin_note_buffer) { - strcat (annobin_note_buffer, ":"); - strcat (annobin_note_buffer, get_func_name (info)); + dst = (char *) xmalloc (len + 1); + strcpy (dst, annobin_note_buffer); + } + + strcat (dst, " "); + strcat (dst, annobin_input_filename); + + if (! is_global (info)) + { + strcat (dst, ":"); + strcat (dst, get_func_name (info)); } } - annobin_output_string_note (annobin_note_buffer); + annobin_output_string_note (dst); + + if (dst != annobin_note_buffer) + free (dst); // FIXME: It would probably be faster to cache this + // pointer rather than reallocate it each time this function is called. } static void diff --git a/gcc-plugin/annobin.h b/gcc-plugin/annobin.h index 74e9437..6412e4c 100644 --- a/gcc-plugin/annobin.h +++ b/gcc-plugin/annobin.h @@ -164,7 +164,7 @@ extern void ice (const char *); The INFO strcuture also contains the fully qualified note section name. */ -extern char annobin_note_buffer[128]; +extern char annobin_note_buffer[2048]; extern void annobin_output_note (const char * NAME, unsigned NAME_LENGTH, diff --git a/meson.build b/meson.build index 458b0b9..8ff0981 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,7 @@ project( 'annobin', ['c', 'cpp'], - version: '12.05', + version: '12.06', meson_version: '>=0.59' ) -- 2.43.5