public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR66805 - #pragma pack affecting gcov_info_type layout
@ 2015-07-08 11:58 Richard Biener
  2015-07-08 12:08 ` Richard Biener
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Richard Biener @ 2015-07-08 11:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek


The following fixes #pragma pack effect leaking to all types built
from the middle-end (so possibly even vector types built by the
vectorizer?).  The PR in question is about gcov_info_type where
layout is affected and inconsistency between that and the libgcov.a
copy causes libgcov to crash.

As the way to communicate #pragma pack to stor-layout.c is already
a hack I couldn't think of a better solution like that below.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Ok?

Thanks,
Richard.

2015-07-08  Richard Biener  <rguenther@suse.de>

	* stor-layout.h (reset_maximum_field_alignment): Declare.
	* stor-layout.c (reset_maximum_field_alignment): New function.
	* toplev.c: Include stor-layout.h.
	(compile_file): Reset maximum_field_alignment after parsing.

Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c	(revision 225534)
+++ gcc/stor-layout.c	(working copy)
@@ -59,6 +59,12 @@ tree sizetype_tab[(int) stk_type_kind_la
    The value is measured in bits.  */
 unsigned int maximum_field_alignment = TARGET_DEFAULT_PACK_STRUCT * BITS_PER_UNIT;
 
+void
+reset_maximum_field_alignment (void)
+{
+  maximum_field_alignment = TARGET_DEFAULT_PACK_STRUCT * BITS_PER_UNIT;
+}
+
 /* Nonzero if all REFERENCE_TYPEs are internal and hence should be allocated
    in the address spaces' address_mode, not pointer_mode.   Set only by
    internal_reference_types called only by a front end.  */
Index: gcc/stor-layout.h
===================================================================
--- gcc/stor-layout.h	(revision 225534)
+++ gcc/stor-layout.h	(working copy)
@@ -118,4 +118,7 @@ extern tree variable_size (tree);
 /* Vector types need to check target flags to determine type.  */
 extern machine_mode vector_type_mode (const_tree);
 
+/* Reset maximum_field_alignment to its default.  */
+extern void reset_maximum_field_alignment (void);
+
 #endif  // GCC_STOR_LAYOUT_H
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	(revision 225534)
+++ gcc/toplev.c	(working copy)
@@ -90,6 +90,7 @@ along with GCC; see the file COPYING3.
 #include "optabs.h"
 #include "tree-chkp.h"
 #include "omp-low.h"
+#include "stor-layout.h"
 
 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
 #include "dbxout.h"
@@ -553,6 +554,11 @@ compile_file (void)
 
   if (flag_syntax_only || flag_wpa)
     return;
+ 
+  /* Reset maximum_field_alignment, it can be adjusted by #pragma pack
+     and this shouldn't influence any types built by the middle-end
+     from now on (like gcov_info_type).  */
+  reset_maximum_field_alignment ();
 
   ggc_protect_identifiers = false;
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-08 12:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-08 11:58 [PATCH] Fix PR66805 - #pragma pack affecting gcov_info_type layout Richard Biener
2015-07-08 12:08 ` Richard Biener
2015-07-08 12:10 ` Jakub Jelinek
2015-07-08 12:40   ` Richard Biener
2015-07-08 12:42     ` Jakub Jelinek
2015-07-08 12:36 ` Alexander Monakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).