delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/01/17/16:15:56

Date: Mon, 17 Jan 1994 21:16:21 +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 profiling bug again

sandmann AT clio DOT rice DOT edu wrote:
> The fix is to store DS in the code segment in the init routine, push DS, store 
> DS from the CS: offset in the interrupt routine, do the operations, then pop the
> old DS on exit.  The garbage pointer is caused by adding mcount_histogram to EAX
> ...

I tried to implement this as follows:

a) defining storage space for ds (directly after the iret in mcount_isr,
     thus hopefully in the code segment)

	.align	2
__ds_sav:
	.short	0

b) saving ds

mcount_isr_init:
	movw	__go32_info_block+36, %ax	/* run mode */
	cmp	$1,%ax
	jb	skip_mcount
	cmp	$3,%ax
	ja	skip_mcount

!	movw	%ds,%cs:__ds_sav
	...

c) modifying the interrupt routine

mcount_isr:
	pushl	%eax
	cmpl	$1,mcount_skip
	je	L0
!	pushw	%ds
!	movw	%cs:__ds_sav,%ds
	movl	4(%esp),%eax /* get the PC */
	subl	$0x1020,%eax /* to fit in low..high */
	andl	$0xfffffffc,%eax
	shrl	$1,%eax /* now points to one 4-byte entry */
	addl	mcount_histogram,%eax
	incw	(%eax)
!	popw	%ds

If I link with this modified version of gcrt0.o I get a General Protection
Fault (unsupported INT 0x0d) from the instruction

	movw	%ds,%cs:__ds_sav

during initialization. I don't know much about protected mode, but I
could imagine that the code segment is read-only. If that's the case,
where else could I store the value of DS to make it available to the
interrupt? Or, if the code segment is not read-only, what else is causing
the general protection fault?

Any idea?

Thanks again.

Stefan.
--
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