This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fix for call-ar-st.exp failure on x86


When GDB calls a function it incorrectly pads the arguments - that is,
GDB's behavior differs from GCC and also from the x86 ABI at
http://www.sco.com/developer/devspecs

Here is a fix:

Index: ChangeLog
===================================================================
RCS file: /cvs/gdb/gdb/gdb/ChangeLog,v
retrieving revision 1.1.1.26
diff -u -r1.1.1.26 ChangeLog
--- ChangeLog	1999/09/28 21:51:51	1.1.1.26
+++ ChangeLog	1999/10/04 21:30:10
@@ -1,3 +1,8 @@
+1999-10-04  Jim Kingdon  <http://developer.redhat.com>
+
+	* valops.c (value_push): Pad to PARM_BOUNDARY.
+	* config/i386/tm-i386.h: Define PARM_BOUNDARY.
+
 Tue Sep 28 11:08:34 1999  Jeffrey A Law  (law@cygnus.com)
 
 	* hppa-tdep.c (hppa_fix_call_dummy): Ignore IMPORT_SHLIB stubs
Index: valops.c
===================================================================
RCS file: /cvs/gdb/gdb/gdb/valops.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 valops.c
--- valops.c	1999/09/22 03:25:12	1.1.1.7
+++ valops.c	1999/10/04 21:30:14
@@ -1061,7 +1061,8 @@
   return sp;
 }
 
-/* Push onto the stack the specified value VALUE.  */
+/* Push onto the stack the specified value VALUE.  Pad it correctly for
+   it to be an argument to a function.  */
 
 static CORE_ADDR
 value_push (sp, arg)
@@ -1069,6 +1070,11 @@
      value_ptr arg;
 {
   register int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
+
+#ifdef PARM_BOUNDARY
+  len = (len + PARM_BOUNDARY / TARGET_CHAR_BIT - 1)
+    & ~(PARM_BOUNDARY / TARGET_CHAR_BIT - 1);
+#endif
 
   if (INNER_THAN (1, 2))
     {
Index: config/i386/tm-i386.h
===================================================================
RCS file: /cvs/gdb/gdb/gdb/config/i386/tm-i386.h,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 tm-i386.h
--- tm-i386.h	1999/08/31 01:07:07	1.1.1.6
+++ tm-i386.h	1999/10/04 21:30:14
@@ -250,6 +250,11 @@
 
 /* Things needed for making the inferior call functions.  */
 
+/* "An argument's size is increased, if necessary, to make it a
+   multiple of [32 bit] words.  This may require tail padding,
+   depending on the size of the argument" - from the x86 ABI.  */
+#define PARM_BOUNDARY 32
+
 /* Push an empty stack frame, to record the current PC, etc.  */
 
 #define PUSH_DUMMY_FRAME { i386_push_dummy_frame (); }
Index: doc/ChangeLog
===================================================================
RCS file: /cvs/gdb/gdb/gdb/doc/ChangeLog,v
retrieving revision 1.1.1.16
diff -u -r1.1.1.16 ChangeLog
--- ChangeLog	1999/09/22 03:25:15	1.1.1.16
+++ ChangeLog	1999/10/04 21:30:18
@@ -1,3 +1,7 @@
+1999-10-04  Jim Kingdon  <http://developer.redhat.com>
+
+	* gdbint.texinfo (Target Architecture Definition): Add PARM_BOUNDARY.
+
 1999-09-14  Michael Snyder  <msnyder@cleaver.cygnus.com>
 
 	* gdbint.texinfo: Fix typo, add the word "have".
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/gdb/gdb/gdb/doc/gdbint.texinfo,v
retrieving revision 1.1.1.17
diff -u -r1.1.1.17 gdbint.texinfo
--- gdbint.texinfo	1999/09/22 03:25:17	1.1.1.17
+++ gdbint.texinfo	1999/10/04 21:30:22
@@ -1539,6 +1539,10 @@
 The number of the ``next next program counter'' register, if defined.
 Currently, this is only defined for the Motorola 88K.
 
+@item PARM_BOUNDARY
+Round arguments to a boundary of this many bits before pushing them on
+the stack.
+
 @item PRINT_REGISTER_HOOK (regno)
 If defined, this must be a function that prints the contents of the
 given register to standard output.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]