This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

variations of .section directives - how to config?



We're working on a GCC-related project, that makes use of named sections
internally to segregate data shared across processes:
http://www.intrepid.com/upc

I'm trying to consolidate the support for various common flavors of
assembler .section directives. At present, for each target machine
and OS, the appropriate section op has to be defined, and this is
tedious. It'd be nice if there was a method of configuring these
directives in a more automatic way for a collection of commonly
occurring OS's and toolsets.

This page summarizes the .section support
(for COFF/ELF) in the GNU assembler,
http://physics.usask.ca/~angie/ep414/labmanual/GNUdoc/gas/as_7.html#SEC128
which would yield the following syntactic examples:

(COFF)        .section  section_name,"dw"
(ELF)         .section  section_name,"aw",@progbits
(ELF Solaris) .section  "section_name",#alloc,#write

I notice however in older GCC config files (iris6.h in gcc 2.95.3 for
example) there is a different form of section directive described as
follows:

/* The IRIX 6 assembler .section directive takes four additional args:
   section type, flags, entry size, and alignment.  The alignment of the
   .ctors and .dtors sections needs to be the same as the size of a pointer
   so that the linker doesn't add padding between elements.  */

which is documented further here:

http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=bks&srch
=&fname=/SGI_Developer/MProAsLg_PG/sgi_html/ch08.html

section name [, section type, section flags, section entry size, section
alignment]
Instructs the assembler to create a section with the given name and optional
attributes.

Legal section type values are denoted by variables prefixed by SHT_ in
<elf.h>.

Legal section flags values are denoted by variables prefixed by SHF_ in
<elf.h>.

The section entry size specifies the size of each entry in the section. For
example, it is 4 for .text sections.

The section alignment specifies the byte boundary requirement for the
section. For example, it is 16 for .text sections.

---

The Irix assembler syntax seems to also be used by the native Cray/Unicosmk
assembler.

---

All of the background, leads to a couple of questions:

What is a reasonable way to parameterize these variations in named section
syntax? Something like the following?

    <system V native assembler> | <gas coff> | <gas elf> | <gas elf
(Solaris)>

Are there sufficient config flags set by the config. target machine
and target OS config header files to be able to determine the proper
syntax of the named section directive (for a large class of commonly
occurring 32 and 64 bit targets), or will it be necessary to fill in
a <target-os><object format><assembler> specific file for each desired
target system?

(note: the desired named sections are separate from the commonly
agreed up .text/.data/.bss/.comm sections)

Thanks.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]