delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/03/14/16:48:11

Message-Id: <m0txKi9-000GOKC@gwar.ardi.com>
Date: Thu, 14 Mar 96 14:37 MST
From: mat AT ardi DOT com (Mat Hostetter)
To: djgpp-workers AT delorie DOT com
Subject: A separate section for locked memory?

It can be a real hassle locking down all variables touched at
interrupt time.  To be truly safe, each C variable being locked
requires a separate DPMI call to lock it down, which is inefficient
and ends up locking down lots of scattered pages here and there.

Would it be possible to add a special magic linker section for
"locked" memory, that gets locked down in crt0.S (or somesuch) with
one DPMI call?

So I could say in gcc:

volatile int timer_ticks __attribute__ ((section ("locked"))) = 0;

and have this variable automatically be in locked memory.  I've
appended the gcc.info information on the section attribute.

-Mat




`section ("section-name")'
     Normally, the compiler places the objects it generates in sections
     like `data' and `bss'.  Sometimes, however, you need additional
     sections, or you need certain particular variables to appear in
     special sections, for example to map to special hardware.  The
     `section' attribute specifies that a variable (or function) lives
     in a particular section.  For example, this small program uses
     several specific section names:

          struct duart a __attribute__ ((section ("DUART_A"))) = { 0 };
          struct duart b __attribute__ ((section ("DUART_B"))) = { 0 };
          char stack[10000] __attribute__ ((section ("STACK"))) = { 0 };
          int init_data_copy __attribute__ ((section ("INITDATACOPY"))) = 0;
          
          main()
          {
            /* Initialize stack pointer */
            init_sp (stack + sizeof (stack));
          
            /* Initialize initialized data */
            memcpy (&init_data_copy, &data, &edata - &data);
          
            /* Turn on the serial ports */
            init_duart (&a);
            init_duart (&b);
          }

     Use the `section' attribute with an *initialized* definition of a
     *global* variable, as shown in the example.  GNU CC issues a
     warning and otherwise ignores the `section' attribute in
     uninitialized variable declarations.

     You may only use the `section' attribute with a fully initialized
     global definition because of the way linkers work.  The linker
     requires each object be defined once, with the exception that
     uninitialized variables tentatively go in the `common' (or `bss')
     section and can be multiply "defined".  You can force a variable
     to be initialized with the `-fno-common' flag or the `nocommon'
     attribute.

     Some file formats do not support arbitrary sections so the
     `section' attribute is not available on all platforms.  If you
     need to map the entire contents of a module to a particular
     section, consider using the facilities of the linker instead.

- Raw text -


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