GAS has acquired layers of code over time. The original GAS only supported the a.out object file format, with three sections. Support for multiple sections has been added in two different ways.
The preferred approach is to use the version of GAS created when the symbol
BFD_ASSEMBLER
is defined. The other versions of GAS are documented for
historical purposes, and to help anybody who has to debug code written for
them.
The type segT
is used to represent a section in code which must work
with all versions of GAS.
The original GAS only supported the a.out object file format with three
sections: `.text', `.data', and `.bss'. This is the version of
GAS that is compiled if neither BFD_ASSEMBLER
nor MANY_SEGMENTS
is defined. This version of GAS is still used for the m68k-aout target, and
perhaps others.
This version of GAS should not be used for any new development.
There is still code that is specific to this version of GAS, notably in
`write.c'. There is no way for this code to loop through all the
sections; it simply looks at global variables like text_frag_root
and
data_frag_root
.
The type segT
is an enum.
The MANY_SEGMENTS
version of gas is only used for COFF. It uses the BFD
library, but it writes out all the data itself using bfd_write
. This
version of gas supports up to 40 normal sections. The section names are stored
in the seg_name
array. Other information is stored in the
segment_info
array.
The type segT
is an enum. Code that wants to examine all the sections
can use a segT
variable as loop index from SEG_E0
up to but not
including SEG_UNKNOWN
.
Most of the code specific to this version of GAS is in the file
`config/obj-coff.c', in the portion of that file that is compiled when
BFD_ASSEMBLER
is not defined.
This version of GAS is still used for several COFF targets.
The preferred version of GAS is the BFD_ASSEMBLER
version. In this
version of GAS, the output file is a normal BFD, and the BFD routines are used
to generate the output.
BFD_ASSEMBLER
will automatically be used for certain targets, including
those that use the ELF, ECOFF, and SOM object file formats, and also all Alpha,
MIPS, PowerPC, and SPARC targets. You can force the use of
BFD_ASSEMBLER
for other targets with the configure option
`--enable-bfd-assembler'; however, it has not been tested for many
targets, and can not be assumed to work.
Go to the first, previous, next, last section, table of contents.