🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #8868

Some RS6000 Fixes

#8868
From: Vincent Del Vecchio
Date: Thu, 09 Jul 1992 21:54
352 lines
13818 bytes
In compiling gdb on the RS6000 with gcc, I found a couple of things that
were the result of sloppy coding, and a couple of things that were
just plain wrong.  Of note:

In the b.out stuff, the IS_CALLNAME and IS_BALNAME macros (include/bout.h)
rely on the argument being either signed or an unsigned int.  If the
argument is an unsigned char or unsigned short, casting to an int
will still leave it > 0, and the comparison will always fail.  On the
RS6000, chars are unsigned and IS_CALLNAME is called on a char in bout.c.
I wasn't sure of the best way to handle this (especially since the
use of chars vs. shorts vs. ints for some of these types seems somewhat
arbitrary) so I left it unchanged--I don't expect to ever need to debug
b.out code.  Nevertheless, it should, of course, be fixed.

In the RS6K stuff, there is a similar problem relating to the RS6K
storage class definitions > 128.  The problem is that the definitions
are used for comparing with both ints and with the signed char n_sclass
in the internal structure.  So if we have int i = 0xFF and
signed char j = 0xFF, one of (X == i) and (X == j) is going to fail
regardless of whether X is (signed char)0xFF or just 0xFF.  It seemed to
me that the easiest solution was to make n_sclass a short.  This
seems to work for the RS6K, but it seems quite possible that it will
break for other machines.  I conditionalized it on compiling on an RS6K,
which is probably not a good idea.  Again, I'm not completely sure what
to do.

Other changes are mostly missing casts.


-------------CUT HERE-------------
diff -rc gdb.orig/gdb-4.5/bfd/rs6000-core.c gdb-4.5/bfd/rs6000-core.c
*** gdb.orig/gdb-4.5/bfd/rs6000-core.c	Mon Mar  2 01:38:43 1992
--- gdb-4.5/bfd/rs6000-core.c	Fri Jul 10 00:56:14 1992
***************
*** 102,109 ****
  
    close (fd);
  
!   if (coredata.c_tab < (sizeof (coredata.c_u) + (int)&coredata.c_u - (int)&coredata.c_signo) ||
!       coredata.c_tab >= statbuf.st_size ||
        (long)coredata.c_stack <= (long)coredata.c_tab ) {
      return NULL;
    }
--- 102,109 ----
  
    close (fd);
  
!   if ((int)coredata.c_tab < (sizeof (coredata.c_u) + (int)&coredata.c_u - (int)&coredata.c_signo) ||
!       (int)coredata.c_tab >= statbuf.st_size ||
        (long)coredata.c_stack <= (long)coredata.c_tab ) {
      return NULL;
    }
***************
*** 128,134 ****
    core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD;
    core_stacksec (abfd)->_raw_size = coredata.c_size;
    core_stacksec (abfd)->vma = STACK_END_ADDR - coredata.c_size;
!   core_stacksec (abfd)->filepos = coredata.c_stack;	/*???? */
  
    /* .reg section for GPRs and special registers. */
    if ((core_regsec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
--- 128,134 ----
    core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD;
    core_stacksec (abfd)->_raw_size = coredata.c_size;
    core_stacksec (abfd)->vma = STACK_END_ADDR - coredata.c_size;
!   core_stacksec (abfd)->filepos = (file_ptr) coredata.c_stack;	/*???? */
  
    /* .reg section for GPRs and special registers. */
    if ((core_regsec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
***************
*** 140,146 ****
    core_regsec (abfd)->name = ".reg";
    core_regsec (abfd)->flags = SEC_ALLOC;
    core_regsec (abfd)->_raw_size = (32 + NUM_OF_SPEC_REGS) * 4;
!   core_regsec (abfd)->vma = NULL;			/* not used?? */
    core_regsec (abfd)->filepos = 
    	(char*)&coredata.c_u.u_save - (char*)&coredata;
  
--- 140,146 ----
    core_regsec (abfd)->name = ".reg";
    core_regsec (abfd)->flags = SEC_ALLOC;
    core_regsec (abfd)->_raw_size = (32 + NUM_OF_SPEC_REGS) * 4;
!   core_regsec (abfd)->vma = 0;			/* not used?? */
    core_regsec (abfd)->filepos = 
    	(char*)&coredata.c_u.u_save - (char*)&coredata;
  
***************
*** 154,160 ****
    core_reg2sec (abfd)->name = ".reg2";
    core_reg2sec (abfd)->flags = SEC_ALLOC;
    core_reg2sec (abfd)->_raw_size = 8 * 32;			/* 32 FPRs. */
!   core_reg2sec (abfd)->vma = NULL;			/* not used?? */
    core_reg2sec (abfd)->filepos = 
    	(char*)&coredata.c_u.u_save.fpr[0] - (char*)&coredata;
  
--- 154,160 ----
    core_reg2sec (abfd)->name = ".reg2";
    core_reg2sec (abfd)->flags = SEC_ALLOC;
    core_reg2sec (abfd)->_raw_size = 8 * 32;			/* 32 FPRs. */
!   core_reg2sec (abfd)->vma = 0;			/* not used?? */
    core_reg2sec (abfd)->filepos = 
    	(char*)&coredata.c_u.u_save.fpr[0] - (char*)&coredata;
  
diff -rc gdb.orig/gdb-4.5/gdb/rs6000-tdep.c gdb-4.5/gdb/rs6000-tdep.c
*** gdb.orig/gdb-4.5/gdb/rs6000-tdep.c	Sun Mar 29 17:29:45 1992
--- gdb-4.5/gdb/rs6000-tdep.c	Thu Jul  9 23:48:45 1992
***************
*** 855,861 ****
  /* Indirect function calls use a piece of trampoline code to do context
     switching, i.e. to set the new TOC table. Skip such code if we are on
     its first instruction (as when we have single-stepped to here). 
!    Result is desired PC to step until, or NULL if we are not in
     trampoline code.  */
  
  skip_trampoline_code (pc)
--- 855,861 ----
  /* Indirect function calls use a piece of trampoline code to do context
     switching, i.e. to set the new TOC table. Skip such code if we are on
     its first instruction (as when we have single-stepped to here). 
!    Result is desired PC to step until, or 0 if we are not in
     trampoline code.  */
  
  skip_trampoline_code (pc)
***************
*** 877,883 ****
    for (ii=0; trampoline_code[ii]; ++ii) {
      op  = read_memory_integer (pc + (ii*4), 4);
      if (op != trampoline_code [ii])
!       return NULL;
    }
    ii = read_register (11);		/* r11 holds destination addr	*/
    pc = read_memory_integer (ii, 4);	/* (r11) value			*/
--- 877,883 ----
    for (ii=0; trampoline_code[ii]; ++ii) {
      op  = read_memory_integer (pc + (ii*4), 4);
      if (op != trampoline_code [ii])
!       return 0;
    }
    ii = read_register (11);		/* r11 holds destination addr	*/
    pc = read_memory_integer (ii, 4);	/* (r11) value			*/
diff -rc gdb.orig/gdb-4.5/gdb/rs6000-xdep.c gdb-4.5/gdb/rs6000-xdep.c
*** gdb.orig/gdb-4.5/gdb/rs6000-xdep.c	Thu Apr  9 14:41:20 1992
--- gdb-4.5/gdb/rs6000-xdep.c	Thu Jul  9 23:48:46 1992
***************
*** 495,501 ****
    /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We assume that
       this address will never be executed again by the real code. */
  
!   target_insert_breakpoint (DUMMY_INSN_ADDR, &shadow);
  
    errno = 0;
    ptrace (PT_CONTINUE, inferior_pid, DUMMY_INSN_ADDR, 0, 0);
--- 495,501 ----
    /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We assume that
       this address will never be executed again by the real code. */
  
!   target_insert_breakpoint (DUMMY_INSN_ADDR, (char *) &shadow);
  
    errno = 0;
    ptrace (PT_CONTINUE, inferior_pid, DUMMY_INSN_ADDR, 0, 0);
***************
*** 506,512 ****
      pid = wait (&status);
    } while (pid != inferior_pid);
      
!   target_remove_breakpoint (DUMMY_INSN_ADDR, &shadow);
  }
  
  
--- 506,512 ----
      pid = wait (&status);
    } while (pid != inferior_pid);
      
!   target_remove_breakpoint (DUMMY_INSN_ADDR, (char *) &shadow);
  }
  
  
diff -rc gdb.orig/gdb-4.5/gdb/xcoffexec.c gdb-4.5/gdb/xcoffexec.c
*** gdb.orig/gdb-4.5/gdb/xcoffexec.c	Fri Apr  3 15:25:45 1992
--- gdb-4.5/gdb/xcoffexec.c	Thu Jul  9 23:48:46 1992
***************
*** 333,339 ****
    
    vmap_bfd.pbfd = arch;
    vmap_bfd.pvmap = vp;
!   bfd_map_over_sections (bf, sex_to_vmap, &vmap_bfd);
  
    obj = lookup_objfile_bfd (bf);
    if (exec_bfd && !obj) {
--- 333,340 ----
    
    vmap_bfd.pbfd = arch;
    vmap_bfd.pvmap = vp;
!   bfd_map_over_sections (bf, (void (*)(bfd *,sec_ptr,PTR)) sex_to_vmap,
! 			 &vmap_bfd);
  
    obj = lookup_objfile_bfd (bf);
    if (exec_bfd && !obj) {
***************
*** 340,348 ****
      obj = allocate_objfile (bf, 0);
  
  #if 0
!     This is only needed if we want to load shared libraries no matter what.
      Since we provide the choice of incremental loading of shared objects now,
!     we don't have to load them as default anymore.
      
      syms_from_objfile (obj, 0, 0, 0);
  #endif
--- 341,349 ----
      obj = allocate_objfile (bf, 0);
  
  #if 0
!  /* This is only needed if we want to load shared libraries no matter what.
      Since we provide the choice of incremental loading of shared objects now,
!     we don't have to load them as default anymore. */
      
      syms_from_objfile (obj, 0, 0, 0);
  #endif
***************
*** 711,717 ****
  
  	  /* The filenames are not always sufficient to match on. */
  
! 	  if ((name[0] == "/" && !eq(name, vp->name))
  	      	|| (memb[0] && !eq(memb, vp->member)))
  	    continue;
  
--- 712,718 ----
  
  	  /* The filenames are not always sufficient to match on. */
  
! 	  if ((name[0] == '/' && !eq(name, vp->name))
  	      	|| (memb[0] && !eq(memb, vp->member)))
  	    continue;
  
***************
*** 735,743 ****
  	  /* found a corresponding VMAP. remap! */
  	  ostart = vp->tstart;
  
! 	  vp->tstart = ldi->ldinfo_textorg;
  	  vp->tend   = vp->tstart + ldi->ldinfo_textsize;
! 	  vp->dstart = ldi->ldinfo_dataorg;
  	  vp->dend   = vp->dstart + ldi->ldinfo_datasize;
  
  	  if (vp->tadj) {
--- 736,744 ----
  	  /* found a corresponding VMAP. remap! */
  	  ostart = vp->tstart;
  
! 	  vp->tstart = (CORE_ADDR) ldi->ldinfo_textorg;
  	  vp->tend   = vp->tstart + ldi->ldinfo_textsize;
! 	  vp->dstart = (CORE_ADDR) ldi->ldinfo_dataorg;
  	  vp->dend   = vp->dstart + ldi->ldinfo_datasize;
  
  	  if (vp->tadj) {
diff -rc gdb.orig/gdb-4.5/gdb/xcoffread.c gdb-4.5/gdb/xcoffread.c
*** gdb.orig/gdb-4.5/gdb/xcoffread.c	Fri Apr  3 15:25:42 1992
--- gdb-4.5/gdb/xcoffread.c	Thu Jul  9 23:48:46 1992
***************
*** 182,188 ****
  aixcoff_new_init PARAMS ((struct objfile *));
  
  static void
! aixcoff_symfile_read PARAMS ((struct sym_fns *, CORE_ADDR, int));
  
  static void
  aixcoff_symfile_finish PARAMS ((struct objfile *));
--- 182,188 ----
  aixcoff_new_init PARAMS ((struct objfile *));
  
  static void
! aixcoff_symfile_read PARAMS ((struct objfile *, CORE_ADDR, int));
  
  static void
  aixcoff_symfile_finish PARAMS ((struct objfile *));
diff -rc gdb.orig/gdb-4.5/gdb/xcoffsolib.c gdb-4.5/gdb/xcoffsolib.c
*** gdb.orig/gdb-4.5/gdb/xcoffsolib.c	Sun Mar 29 17:30:07 1992
--- gdb-4.5/gdb/xcoffsolib.c	Thu Jul  9 23:48:47 1992
***************
*** 7,12 ****
--- 7,13 ----
  /*#include "libbfd.h"		/* BFD internals (sigh!)  FIXME */
  #include "xcoffsolib.h"
  
+ struct objfile *lookup_objfile_bfd();
  
  extern struct symtab *current_source_symtab;
  extern int	      current_source_line;
diff -rc gdb.orig/gdb-4.5/include/coff/internal.h gdb-4.5/include/coff/internal.h
*** gdb.orig/gdb-4.5/include/coff/internal.h	Mon Jan 27 22:37:20 1992
--- gdb-4.5/include/coff/internal.h	Thu Jul  9 23:48:47 1992
***************
*** 121,141 ****
  #define C_EINCL         109     /* Marks ending of include file */
  
  	/* storage classes for stab symbols for RS/6000 */
! #define C_GSYM          ((signed char)0x80)
! #define C_LSYM          ((signed char)0x81)
! #define C_PSYM          ((signed char)0x82)
! #define C_RSYM          ((signed char)0x83)
! #define C_RPSYM         ((signed char)0x84)
! #define C_STSYM         ((signed char)0x85)
! #define C_TCSYM         ((signed char)0x86)
! #define C_BCOMM         ((signed char)0x87)
! #define C_ECOML         ((signed char)0x88)
! #define C_ECOMM         ((signed char)0x89)
! #define C_DECL          ((signed char)0x8c)
! #define C_ENTRY         ((signed char)0x8d)
! #define C_FUN           ((signed char)0x8e)
! #define C_BSTAT         ((signed char)0x8f)
! #define C_ESTAT         ((signed char)0x90)
  
  /********************** SECTION HEADER **********************/
  struct internal_scnhdr {
--- 121,141 ----
  #define C_EINCL         109     /* Marks ending of include file */
  
  	/* storage classes for stab symbols for RS/6000 */
! #define C_GSYM          (0x80)
! #define C_LSYM          (0x81)
! #define C_PSYM          (0x82)
! #define C_RSYM          (0x83)
! #define C_RPSYM         (0x84)
! #define C_STSYM         (0x85)
! #define C_TCSYM         (0x86)
! #define C_BCOMM         (0x87)
! #define C_ECOML         (0x88)
! #define C_ECOMM         (0x89)
! #define C_DECL          (0x8c)
! #define C_ENTRY         (0x8d)
! #define C_FUN           (0x8e)
! #define C_BSTAT         (0x8f)
! #define C_ESTAT         (0x90)
  
  /********************** SECTION HEADER **********************/
  struct internal_scnhdr {
***************
*** 214,220 ****
--- 214,224 ----
  	short		n_scnum;	/* section number		*/
  	unsigned short	n_flags;	/* copy of flags from filhdr	*/
  	unsigned short	n_type;		/* type and derived type	*/
+ #ifdef _IBMR2  /* Ifdef'd because it's not clear to me what will break. */
+ 	short		n_sclass;
+ #else
  	signed char	n_sclass;	/* storage class		*/
+ #endif
  	char		n_numaux;	/* number of aux. entries	*/
  };
  #define n_name		_n._n_name
Technical Details
Message-ID: <9207100554.AA16063@thor.tjhsst.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!thor.tjhsst.edu!vdelvecc

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,36254352ff8c5058,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1992-07-09 17:51:12 PST
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!thor.tjhsst.edu!vdelvecc
From: vdelvecc@thor.tjhsst.edu (Vincent Del Vecchio)
Subject: Some RS6000 Fixes
Message-ID: <9207100554.AA16063@thor.tjhsst.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 9 Jul 1992 21:54:12 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 353