delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/03/22/02:42:56

Sender: bill AT taniwha DOT tssc DOT co DOT nz
Message-ID: <3514BFA5.DA9A1E70@taniwha.tssc.co.nz>
Date: Sun, 22 Mar 1998 19:37:09 +1200
From: Bill Currie <bill AT taniwha DOT tssc DOT co DOT nz>
MIME-Version: 1.0
To: Nate Eldredge <eldredge AT ap DOT net>
CC: Charles Sandmann <sandmann AT clio DOT rice DOT edu>, cssl AT geocities DOT com,
djgpp-workers AT delorie DOT com
Subject: Re: Can the text section be made read-only?
References: <199803220136 DOT RAA16736 AT adit DOT ap DOT net>

This is a multi-part message in MIME format.
--------------360F17D9372DD3A41A70F58B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Nate Eldredge wrote:
> Is that as simple as just adding `.data' before them and `.text' after? It
> looks like it is (the code that locks them doesn't seem to care where they
> are), but I'm not sure.

As to the locking issue, now that my ASM_OUTPUT_SECTION_NAME patch to
go32.h is in mainstream gcc (2.8.1 definitely, don't know about 2.8.0),
can I suggest using .ltext and .ldata sections (and supporting them in
mainstream DJGPP) as originally suggestion by Alaric Williams?  Support
in DJGPP is as simple as a couple of additional lines to the linker
scripts (this MAY cause problems with Roberts efforts with binutils) as
per the attached patch.

Then all that would be needed is some startup code that locks the locked
text and data sections automaticly. eg:

---8<---------locksect.c---
#include <dpmi.h>

extern char sltext[] asm ("sltext");
extern char eltext[] asm ("eltext");
extern char sldata[] asm ("sldata");
extern char eldata[] asm ("eldata");

void __djgpp_lock_sections(void)
{
        _go32_dpmi_lock_code(sltext,eltext-sltext);
        _go32_dpmi_lock_data(sldata,eldata-sldata);
}
---8<----------------------

Thus really simplifying the code/data locking process.  Just use:

int variable __attribute__((section(".ldata"),nocommon));
void __attribute__((section(".ltext"))) function()
{
	variable++;
}

Hmmm or would that be
int __attribute__((section(".ldata"),nocommon)) variable;
?

Bill
-- 
Leave others their otherness.
--------------360F17D9372DD3A41A70F58B
Content-Type: text/plain; charset=us-ascii; name="djgpp.pat"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="djgpp.pat"

*** lib/djgpp.djl	Mon Sep  9 02:40:06 1996
--- /home/bill/src/serio/djgpp.djl	Fri Mar 14 13:30:48 1997
***************
*** 5,10 ****
--- 5,13 ----
    .text  0x1000+SIZEOF_HEADERS : {
      *(.text)
      etext  =  . ; _etext = .;
+     sltext = . ;
+     *(.ltext)
+     eltext = . ;
      . = ALIGN(0x200);
    }
    .data  ALIGN(0x200) : {
***************
*** 16,21 ****
--- 19,27 ----
      djgpp_last_dtor = . ;
      *(.data)
       edata  =  . ; _edata = .;
+     sldata = . ;
+     *(.ldata)
+     eldata = . ;
       . = ALIGN(0x200);
    }
    .bss  SIZEOF(.data) + ADDR(.data) :

--------------360F17D9372DD3A41A70F58B--

- Raw text -


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