Do not generate notes when there is no output file.

Resolves: #1523875
This commit is contained in:
Nick Clifton 2017-12-11 10:36:08 +00:00
parent 3dfaaa0ec2
commit ecf7069f1b
3 changed files with 71 additions and 3 deletions

View File

@ -11,7 +11,7 @@ diff -rup annobin.orig/plugin/annobin.cc annobin-2.5.1/plugin/annobin.cc
+ {
+ /* The name can be empty if we are receiving the source code
+ from a pipe. In this case, we invent our own name. */
+ name = "piped_input";
+ name = (char *) "piped_input";
+ }
+
if (global_file_name_symbols)

View File

@ -0,0 +1,60 @@
--- 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);

View File

@ -1,7 +1,7 @@
Name: annobin
Summary: Binary annotation plugin for GCC
Version: 2.5.1
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3+
URL: https://fedoraproject.org/wiki/Toolchain/Watermark
@ -23,6 +23,11 @@ Patch1: funname.patch
# Lifetime: Fixed in 2.5.2
Patch2: annobin-empty-input-filename.patch
# Purpose: Fixes a bug where compiling with LTO enabled would result in the
# plugin being called with no output file handle available.
# Lifetime: Fixed in 2.5.2
Patch3: annobin-lto-filename.patch
# This is a gcc plugin, hence gcc is required.
Requires: gcc
@ -81,7 +86,10 @@ make check
#---------------------------------------------------------------------------------
%changelog
* Fri Dec 08 2017 Florian Weimer <fweimer@redhat.com> - 2.5.1-4
* Mon Dec 11 2017 Nick Clifton <nickc@redhat.com> - 2.5.1-5
- Do not generate notes when there is no output file. (#1523875)
* Fri Dec 08 2017 Nick Clifton <nickc@redhat.com> - 2.5.1-4
- Invent an input filename when reading from a pipe. (#1523401)
* Thu Nov 30 2017 Florian Weimer <fweimer@redhat.com> - 2.5.1-3