delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/01/18/15:20:10

Date: Tue, 18 Jan 1994 21:06:41 +0100
From: Stefan Eckart <S_Eckart AT lis DOT e-technik DOT tu-muenchen DOT de>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: -pg bug

Sorry, but it's me again...

The profiling bug seems to be still unsolved. With the suggested modifications
the value of ds is now probably correct, but the segmentation fault won't
go away:

Segmentation violation in pointer 0x1c7d7f0 at d8:1259
eax=1c17d7f0 ebx=00000006 ecx=0000002a edx=e002591f esi=00025a77 edi=0008b55c
ebp=7ffffe10 esp=7ffffda8 cs=d8 ds=48 es=48 fs=48 gs=38 ss=48 cr2=0000d7f0
Call frame traceback EIPs:
  0x00001259   __exit+179
  0x00001a3a   _fread+66
  0x000014e9   _main+97

It's again the incw (%eax) instruction which fails. The only explanation
I have is that perhaps the stack segment is not correct. Furthermore
I saw that mcount_isr doesn't end with iret but with an ljmp mc_chain.
So even if the histogram reference eventually becomes valid the problem
might still be there because I have to restore ds before the ljmp :-(.
Any further advice what I'm doing wrong? Any chance for me as a total
novice to fix this bug? I'm starting to doubt...

I have appended a diff -c2 of the changes I applied to crt0.s.

Thanks,

Stefan.

P.S.: I have checked the object code with the debugger. The segment
      override prefix for cs IS generated by as.

*** lib/crt0.s	Tue Nov 30 02:23:02 1993
--- tmp/lib/crt0.s	Tue Jan 18 20:06:50 1994
***************
*** 142,147 ****
--- 142,149 ----
  	jb	skip_mcount
  	cmp	$3,%ax
  	ja	skip_mcount
+ 
+ 	movw	%ds,__ds_sav
  	
  	movw	$16,%ax
  	movw	%ax,%gs
***************
*** 174,179 ****
--- 176,183 ----
  /* in some spots */
  mcount_isr:
  	pushl	%eax
+ 	pushw	%ds
+ 	movw	%cs:__ds_sav,%ds
  	cmpl	$1,mcount_skip
  	je	L0
  	movl	4(%esp),%eax /* get the PC */
***************
*** 183,191 ****
--- 187,199 ----
  	addl	mcount_histogram,%eax
  	incw	(%eax)
  L0:
+ 	popw	%ds
  	popl	%eax
  	ljmp	mc_chain /* chain to the next timer vector */
  	iret
+ 	.align	2
+ __ds_sav:
+ 	.short	0
  #endif
  
  	.data

-- 
stefan AT lis DOT e-technik DOT tu-muenchen DOT de

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019