delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/04/20:26:30

Date: Thu, 4 Dec 1997 17:25:13 -0800 (PST)
Message-Id: <199712050125.RAA26265@adit.ap.net>
Mime-Version: 1.0
To: djgpp-workers AT delorie DOT com, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Minor libc bug: brk() writes into text section

I found a small bug in brk() (src/libc/crt0/crt0.S). The variable
__what_size_app_thinks_it_is is placed in the text section, I presume by
mistake. This is not an actual problem under normal conditions, but if one
should want to write-protect the text section, this will be a problem. Patch
follows at end of message.

Btw, does anyone know what should happen when you touch mprotect()ed memory,
assuming a DPMI server that supports it? In different circumstances, using
CWSDPMI r3, I get SIGSEGV's, page faults from the DPMI server, or even an
endless stream of SIGSEGV's! (I think this may be the exception handler
touching the memory and triggering another exception, but that's just a guess.)

*** src/libc/crt0/crt0.s~	Sun Oct  6 00:19:30 1996
--- src/libc/crt0/crt0.s	Wed Dec  3 20:43:42 1997
***************
*** 342,349 ****
--- 342,351 ----
  /*------------------------------------------------------------------------
-----*/
  
  /*	.lcomm	__what_size_app_thinks_it_is, 4 */
+ .data
  __what_size_app_thinks_it_is:
  	.long	end
+ .text
  	.lcomm	__what_we_return_to_app_as_old_size, 4
  	.lcomm	__what_size_dpmi_thinks_we_are, 4
  

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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