From mboxrd@z Thu Jan 1 00:00:00 1970 From: "H . J . Lu" To: gdb@sources.redhat.com Subject: Re: The problem with stabs and sign extension Date: Wed, 08 Aug 2001 16:14:00 -0000 Message-id: <20010808161421.A3360@lucon.org> References: <20010808141207.A31287@nevyn.them.org> X-SW-Source: 2001-08/msg00079.html On Wed, Aug 08, 2001 at 02:12:07PM -0700, Daniel Jacobowitz wrote: > The problem seems, to my inexperienced eye, to be in stabsread.c: > > #define INTERNALIZE_SYMBOL(intern, extern, abfd) \ > { \ > (intern).n_type = bfd_h_get_8 (abfd, (extern)->e_type); \ > (intern).n_strx = bfd_h_get_32 (abfd, (extern)->e_strx); \ > (intern).n_desc = bfd_h_get_16 (abfd, (extern)->e_desc); \ > (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value); \ > } > > n_value is a CORE_ADDR. bfd_h_get_32 returns a bfd_vma, without doing sign > extension. For MIPS, we want sign extension to have happened here. Right? > It does if we're reading mdebug in (because ECOFF_SIGNED_32 is defined in > BFD). > > On the other hand, I'm sure other targets don't want sign extension here. > How should we handle this? You can do #define INTERNALIZE_SYMBOL(intern, extern, abfd) \ { \ (intern).n_type = bfd_h_get_8 (abfd, (extern)->e_type); \ (intern).n_strx = bfd_h_get_32 (abfd, (extern)->e_strx); \ (intern).n_desc = bfd_h_get_16 (abfd, (extern)->e_desc); \ if (bfd_get_sign_extend_vma (abfd)) \ (intern).n_value = bfd_h_get_signed_32 (abfd, (extern)->e_value); \ else \ (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value); \ } But I don't think it is the main problem. From what I can see, dbxread.c has no clue whatsoever about the sign extension. I don't know how hard to fix it. H.J.