public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH RFA: Fix for PR 39383 for generic ELF systems.
@ 2009-04-22 23:16 Anmol P. Paralkar
  0 siblings, 0 replies; only message in thread
From: Anmol P. Paralkar @ 2009-04-22 23:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: algrant, ebotcazou, joseph, aph

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1158 bytes --]

Hello,

  Please find attached, a fix for PR 39383 in the case of generic ELF systems
  and a test-case for inclusion in the test-suite.

  Per Comment #6 in the PR, the .size assembler directive emitted ought to
  contain the "true" size of the object (when the object is of type struct
  containing a flexible array - using the size of the type is going to be
  off). The fix involves changing the definition of the ASM_DECLARE_OBJECT_NAME
  macro to use the size of the variable's initializer instead of the type of
  the variable.

  The fixed GCC was bootstrapped and tested on a PowerBook G4 (7447A altivec
  supported), running Linux 2.6.27.5-117.fc10.ppc (compared post-fix relative
  to pre-fix for each of: gcc, g++, libgomp, libmudflap, objc, gfortran, libffi,
  libjava, libstdc++ - there were no regressions - please let me know in case
  you wish to see the summaries/logs) in native configuration:
  powerpc-unknown-linux-gnu

  This is my zeroeth attempt to contribute to GCC; any advice (especially, if the
  ASM_FINISH_DECLARE_OBJECT macro needs the same change as well) is gratefully
  received.

  Thank you.

Sincerely,
Anmol P. Paralkar

[-- Attachment #2: Type: TEXT/PLAIN, Size: 195 bytes --]

2009-04-22  Anmol P. Paralkar  <anmol@freescale.com>

	PR c/39383
	* config/elfos.h (ASM_DECLARE_OBJECT_NAME): Use the size of the
	variable's initializer instead of the size of its type.


[-- Attachment #3: Type: TEXT/PLAIN, Size: 107 bytes --]

2009-04-22  Anmol P. Paralkar  <anmol@freescale.com>

	PR c/39383
	* gcc.dg/pr39383.c: New testcase.


[-- Attachment #4: Type: TEXT/PLAIN, Size: 1226 bytes --]

Index: gcc/testsuite/gcc.dg/pr39383.c
===================================================================
--- gcc/testsuite/gcc.dg/pr39383.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr39383.c	(revision 0)
@@ -0,0 +1,16 @@
+/* Verify that when a struct has a flexible array member,
+   the size in the emitted .size assembler directive for
+   a statically initialized object (of that type) is based
+   on the actual size of the object (as determined by its
+   initializer) and not on the type of the object. */
+
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct text
+{
+  char len;
+  char txt[];
+} vowels = { 5, { 'a', 'e', 'i', 'o', 'u' } };
+
+/* { dg-final { scan-assembler "\.size\[ \t\]+vowels,\[ \t\]+6" } } */
Index: gcc/config/elfos.h
===================================================================
--- gcc/config/elfos.h	(revision 146140)
+++ gcc/config/elfos.h	(working copy)
@@ -301,7 +301,7 @@
 	  && (DECL) && DECL_SIZE (DECL))			\
 	{							\
 	  size_directive_output = 1;				\
-	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
+	  size = tree_low_cst (DECL_SIZE_UNIT (DECL), 1);	\
 	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
 	}							\
 								\

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-04-22 23:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-22 23:16 PATCH RFA: Fix for PR 39383 for generic ELF systems Anmol P. Paralkar

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).