[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libdfp-patches] [PATCH] Fix issue with printf_dfp and issues with asm ENTRY macro causing .size expression errors.



Fixed the issues regarding __printf_dfp and printf-hooks mentioned in
Jakub Jelinek's email to libc-alpha

http://sourceware.org/ml/libc-alpha/2011-02/msg00043.html

Also fixed an issue with a newer version of GNU AS which complains with
the following error when building libdfp:

sysdeps/powerpc/powerpc32/power6/fpu/adddd3.S:33: Error: .size
expression does not evaluate to a constant

I discovered that the new version of binutils requires that for:

.size __dpd_adddd3,-__dpd_adddd3 to be defined it must be in the same
module as the label __dpd_adddd3:

This pointed at the libdfp ENTRY() asm macro being incorrect because the
following was generated:

 .globl ___dpd_addsd3; .type ___dpd_addsd3,@function; .align 2;
___dpd_addsd3: .cfi_startproc;

Notice the extra underscore in ___dpd_addsd3.  The ENTRY() macro uses
C_LABEL() which was prepending an additional underscore.

I cleaned up the macros and removed unnecessary elements.

Ryan S. Arnold
Libdfp Maintainer

I checked in the following patch:

Index: README.maintainer
===================================================================
--- README.maintainer	(revision 12799)
+++ README.maintainer	(revision 13157)
@@ -29,3 +29,9 @@
 	9.  Contributions
 	10. Commit Access
 
+
+---------------------------------------------------------------------------
+10.  Commit Access
+
+commit-access@xxxxxxxxxx
+
Index: include/libdfp-symbols.h
===================================================================
--- include/libdfp-symbols.h	(revision 12799)
+++ include/libdfp-symbols.h	(revision 13157)
@@ -1,6 +1,6 @@
 /* Support macros for making weak and strong aliases for symbols.
 
-   Copyright (C) 1995-1998, 2000-2006, 2008, 2009
+   Copyright (C) 1995-1998, 2000-2006, 2008, 2009, 2011
    Free Software Foundation, Inc.
 
    This file is part of the Decimal Floating Point C Library.
@@ -26,32 +26,11 @@
 #ifndef _LIBDFP_SYMBOLS_H
 #define _LIBDFP_SYMBOLS_H	1
 
-/* Adapted for libdfp from glibc's include/libc-symbols.h in 2009.  */
+/* Define a macro we can use to construct the asm name for a C symbol.  */
+#ifndef LABEL
+# define LABEL(name) name##:
+#endif /* LABEL  */
 
-#ifndef __SYMBOL_PREFIX
-# ifdef NO_UNDERSCORES
-#  define __SYMBOL_PREFIX
-# else
-#  define __SYMBOL_PREFIX "_"
-# endif
-#endif
-
-
-
-#ifndef C_SYMBOL_NAME
-# ifdef NO_UNDERSCORES
-#  define C_SYMBOL_NAME(name) name
-# else
-#  define C_SYMBOL_NAME(name) _##name
-# endif
-#endif
-
-#ifndef ASM_LINE_SEP
-# define ASM_LINE_SEP ;
-#endif
-
-
-
 #define	MIN(a,b) (((a)<(b))?(a):(b))
 
 /* Define ALIASNAME as a strong alias for NAME.  */
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 12799)
+++ ChangeLog	(revision 13157)
@@ -1,3 +1,32 @@
+2011-03-15  Ryan S. Arnold  <rsa@xxxxxxxxxx>
+
+	* printf_dfp.c (__printf_dfp): Finished cleaning up 'decimal'.
+	* sysdeps/powerpc/sysdep.h: Updated copyright year.
+
+2011-03-15  Ryan S. Arnold  <rsa@xxxxxxxxxx>
+
+	* README.maintainer: Updated.
+	* sysdeps/powerpc/powerpc32/power6/fpu/fixunstdsi.S (END): Fix
+	erroneous __dpd_fixunstssi to __dpd_fixunstdsi.
+	* sysdeps/powerpc/powerpc32/sysdep.h (PROF): Removed PROF macros.
+	(CALL_MCOUNT): Removed CALL_MCOUNT.
+	(ENTRY): Removed CALL_MCOUNT and C_SYMBOL_NAME from macro body.
+	Replaced C_LABEL with LABEL.
+	(C_TEXT): Removed macro as unnecessary.
+	* sysdeps/powerpc/sysdep.h (C_LABEL): Removed macro.
+	* include/libdfp-symbols.h (LABEL): New macro which replaces C_LABEL
+	by removing preceding underscore.
+	* printf_dfp.c (__dfp_ais): Return -1 if info->user doesn't match any of
+	the DFP mod_[H|D|DD] identifiers.
+	(__printf_dfp): Started cleaning up 'decimal' per Jakub Jelinek's
+	suggestion.  Fixed bug found by Jakub Jelinek where random garbage is
+	printed if the modifier is not H/D/DD.  The default was dropping into
+	the _Decimal32 case when it should have been returning -2.
+
+2010-02-08  Ryan S. Arnold  <rsa@xxxxxxxxxx>
+
+	* README.maintainer: Added todo for "Commit Access"
+
 2011-02-08  Ryan S. Arnold  <rsa@xxxxxxxxxx>
 
 	* README.maintainer: New file.
Index: sysdeps/powerpc/powerpc32/power6/fpu/fixunstdsi.S
===================================================================
--- sysdeps/powerpc/powerpc32/power6/fpu/fixunstdsi.S	(revision 12799)
+++ sysdeps/powerpc/powerpc32/power6/fpu/fixunstdsi.S	(revision 13157)
@@ -1,6 +1,6 @@
 /* Decimal Floating Point convert 128-bit to unsigned int.
 
-   Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2008, 2009, 2011 Free Software Foundation, Inc.
 
    This file is part of the Decimal Floating Point C Library.
 
@@ -25,7 +25,6 @@
 
 #include <sysdep.h>
 
-
 	.machine	"power6"
 /* unsigned int __dpd_fixunstdsi (_Decimal128 x)   */
 /* unsigned long __dpd_fixunstdsi (_Decimal128 x)  */
@@ -54,5 +53,4 @@
 L(done):
 	addi	r1,r1,16
 	blr
-	END (__dpd_fixunsddsi)
-
+	END (__dpd_fixunstdsi)
Index: sysdeps/powerpc/powerpc32/sysdep.h
===================================================================
--- sysdeps/powerpc/powerpc32/sysdep.h	(revision 12799)
+++ sysdeps/powerpc/powerpc32/sysdep.h	(revision 13157)
@@ -1,6 +1,6 @@
 /* Assembly macros for 32-bit PowerPC.
 
-   Copyright (C) 1999, 2001, 2002, 2003, 2006, 2009
+   Copyright (C) 1999, 2001, 2002, 2003, 2006, 2009, 2011
    Free Software Foundation, Inc.
 
    This file is part of the Decimal Floating Point C Library.
@@ -23,34 +23,18 @@
 
 #include <sysdeps/powerpc/sysdep.h>
 
-/* Taken from GLIBC in 2009.  */
-
+/* Derived from GLIBC  */
 #ifdef __ASSEMBLER__
 
 #ifdef __ELF__
 
-/* If compiled for profiling, call `_mcount' at the start of each
-   function.  */
-#ifdef	PROF
-/* The mcount code relies on a the return address being on the stack
-   to locate our caller and so it can restore it; so store one just
-   for its benefit.  */
-# define CALL_MCOUNT							      \
-  mflr  r0;								      \
-  stw   r0,4(r1);							      \
-  cfi_offset (lr, 4);	       						      \
-  bl    JUMPTARGET(_mcount);
-#else  /* PROF */
-# define CALL_MCOUNT		/* Do nothing.  */
-#endif /* PROF */
-
+#undef ENTRY
 #define	ENTRY(name)							      \
-  ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);				      \
-  ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)			      \
+  ASM_GLOBAL_DIRECTIVE name;						      \
+  ASM_TYPE_DIRECTIVE (name,@function)					      \
   .align ALIGNARG(2);							      \
-  C_LABEL(name)								      \
-  cfi_startproc;							      \
-  CALL_MCOUNT
+  LABEL(name)								      \
+  cfi_startproc;
 
 #define EALIGN_W_0  /* No words to insert.  */
 #define EALIGN_W_1  nop
@@ -61,37 +45,24 @@
 #define EALIGN_W_6  EALIGN_W_5;nop
 #define EALIGN_W_7  EALIGN_W_6;nop
 
+#undef EALIGN
 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
    past a 2^align boundary.  */
-#ifdef PROF
-# define EALIGN(name, alignt, words)					      \
-  ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);				      \
-  ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)			      \
-  .align ALIGNARG(2);							      \
-  C_LABEL(name)								      \
-  cfi_startproc;							      \
-  CALL_MCOUNT								      \
-  b 0f;									      \
-  .align ALIGNARG(alignt);						      \
-  EALIGN_W_##words;							      \
-  0:
-#else /* PROF */
-# define EALIGN(name, alignt, words)					      \
-  ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);				      \
-  ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)			      \
-  .align ALIGNARG(alignt);						      \
-  EALIGN_W_##words;							      \
-  C_LABEL(name)								      \
-  cfi_startproc;
-#endif
+#define EALIGN(name, alignt, words)					      \
+ ASM_GLOBAL_DIRECTIVE name;						      \
+ ASM_TYPE_DIRECTIVE (name,@function)					      \
+ .align ALIGNARG(alignt);						      \
+ EALIGN_W_##words;							      \
+ LABEL(name)								      \
+ cfi_startproc;
 
 #undef	END
 #define END(name)							      \
   cfi_endproc;								      \
   ASM_SIZE_DIRECTIVE(name)
 
-#define DO_CALL(syscall)				      		      \
-    li 0,syscall;						              \
+#define DO_CALL(syscall)						      \
+    li 0,syscall;							      \
     sc
 
 #undef JUMPTARGET
@@ -151,9 +122,6 @@
 #undef L
 #define L(x) .L##x
 
-/* Label in text section.  */
-#define C_TEXT(name) name
-
 #endif /* __ELF__ */
 
 #endif	/* __ASSEMBLER__ */
Index: sysdeps/powerpc/sysdep.h
===================================================================
--- sysdeps/powerpc/sysdep.h	(revision 12799)
+++ sysdeps/powerpc/sysdep.h	(revision 13157)
@@ -1,6 +1,7 @@
 /* Constructs needed by libdfp PowerPC asm files.
 
-   Copyright (C) 1999, 2001, 2002, 2006, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002, 2006, 2009,
+   2011 Free Software Foundation, Inc.
 
    This file is part of the Decimal Floating Point C Library.
 
@@ -22,20 +23,6 @@
 
    Please see libdfp/COPYING.txt for more information.  */
 
-/* Adapted from GLIBC's powerpc/sysdep.h in 2009. */
-
-#ifndef C_LABEL
-/* Define a macro we can use to construct the asm name for a C symbol.  */
-
-#ifdef	__STDC__
-#define C_LABEL(name)		_##name##:
-#else
-#define C_LABEL(name)		_/**/name/**/:
-#endif
-
-#endif /* C_LABEL  */
-
-
 /* 
  * Powerpc Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP). 
  * This entry is copied to _dl_hwcap or rtld_global._dl_hwcap during startup.
Index: printf_dfp.c
===================================================================
--- printf_dfp.c	(revision 12799)
+++ printf_dfp.c	(revision 13157)
@@ -1,6 +1,6 @@
 /* Function definition to convert DFP values to strings
 
-   Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
 
    This file is part of the Decimal Floating Point C Library.
 
@@ -319,7 +319,7 @@
       return 1;
     }
 
-  return 0;
+  return -1;
 }
 strong_alias(__dfp_ais, dfp_ais)
 hidden_def(__dfp_ais)
@@ -340,15 +340,11 @@
 	      const struct printf_info *info,
 	      const void *const *args)
 {
-	int wide = info->wide;
-	/* Counter for number of written characters.	*/
-	int done = 0;
+  int wide = info->wide;
+  /* Counter for number of written characters.  */
+  int done = 0;
 
-  /* Locale-dependent representation of decimal point.	*/
-
-#ifndef OPTION_EGLIBC_LOCALE_CODE
-  char decimald;
-#endif
+  /* Locale-dependent representation of decimal point.  */
   const char *decimal;
 
   union { const char *mb; unsigned int wc; } decimalwc;
@@ -383,12 +379,10 @@
   assert (decimalwc.wc != L'\0');
 #else
   /* Hard-code values from 'C' locale.  */
-  decimald = ".";
-  decimal = &decimald;
+  decimal = ".";
   decimalwc.wc = L'.';
 #endif
 
-
 #ifdef OPTION_EGLIBC_LOCALE_CODE
   if (info->group)
     {
@@ -476,7 +470,7 @@
       __get_digits_d128 (d128, digits+1, &exp, &is_neg, &is_nan, &is_inf);
       mw = __DEC128_MANT_DIG__ + 1;
     }
-  else
+  else if (info->user & mod_H)
     {
        _Decimal32 d32 = **(_Decimal32**)args[0];
        if (d32 == 0) is_zero = 1;
@@ -484,6 +478,8 @@
        __get_digits_d32 (d32, digits+1, &exp, &is_neg, &is_nan, &is_inf);
        mw = __DEC32_MANT_DIG__ + 1;
     }
+  else /* We shouldn't get here, but it is possible.  */
+    return -2;
 
   /* The first digit is always a zero to allow rounding.  */
   n = 0;