61 lines
2.0 KiB
Diff
61 lines
2.0 KiB
Diff
--- annobin.orig/plugin/annobin.cc 2017-12-11 10:25:28.034276686 +0000
|
|
+++ annobin-2.5.1/plugin/annobin.cc 2017-12-11 10:26:40.964423113 +0000
|
|
@@ -179,6 +179,9 @@ annobin_output_note (const void * name,
|
|
{
|
|
unsigned i;
|
|
|
|
+ if (asm_out_file == NULL)
|
|
+ return;
|
|
+
|
|
if (type == NT_GNU_BUILD_ATTRIBUTE_FUNC
|
|
|| type == NT_GNU_BUILD_ATTRIBUTE_OPEN)
|
|
{
|
|
@@ -512,6 +515,9 @@ annobin_create_function_notes (void * gc
|
|
if (! annobin_enable_static_notes)
|
|
return;
|
|
|
|
+ if (asm_out_file == NULL)
|
|
+ return;
|
|
+
|
|
annobin_target_specific_function_notes ();
|
|
|
|
if (global_stack_prot_option != flag_stack_protect)
|
|
@@ -592,7 +598,18 @@ annobin_create_global_notes (void * gcc_
|
|
|
|
if (! annobin_enable_static_notes)
|
|
return;
|
|
-
|
|
+
|
|
+ if (asm_out_file == NULL)
|
|
+ {
|
|
+ /* This happens during LTO compilation. Compilation is triggered
|
|
+ before any output file has been opened. Since we do not have
|
|
+ the file handle we cannot emit any notes. On the other hand,
|
|
+ the recompilation process will repeat later on with a real
|
|
+ output file and so the notes can be generated then. */
|
|
+ annobin_inform (1, "Output file not available - unable to generate notes");
|
|
+ return;
|
|
+ }
|
|
+
|
|
/* Record global information.
|
|
Note - we do this here, rather than in plugin_init() as some
|
|
information, PIC status or POINTER_SIZE, may not be initialised
|
|
@@ -629,6 +646,7 @@ annobin_create_global_notes (void * gcc_
|
|
/* We need a filename, so invent one. */
|
|
annobin_current_filename = (char *) "unknown_source";
|
|
}
|
|
+
|
|
if (global_file_name_symbols)
|
|
fprintf (asm_out_file, ".global %s\n", annobin_current_filename);
|
|
fprintf (asm_out_file, ".type %s STT_OBJECT\n", annobin_current_filename);
|
|
@@ -718,6 +736,9 @@ annobin_create_loader_notes (void * gcc_
|
|
if (! annobin_enable_dynamic_notes)
|
|
return;
|
|
|
|
+ if (asm_out_file == NULL)
|
|
+ return;
|
|
+
|
|
if (annobin_enable_stack_size_notes && annobin_total_static_stack_usage)
|
|
{
|
|
annobin_inform (1, "Recording total static usage of %ld", annobin_total_static_stack_usage);
|