Multiple Ancillary Objects
When the ancillary object feature is enabled with the
-z ancillary
option, a single
ancillary object is produced. A
mapfile can be used instead, to
specify an arbitrary number of ancillary objects,
and to assign the data from specific sections to
those objects. Typically, a single ancillary object
is sufficient, but multiple objects may be desired
for organizational reasons, or to overcome the
4 Gbyte limit on a single 32-bit ancillary object
when building extremely large objects.
The ANCILLARY
mapfile directive
is used to specify the ancillary objects to create.
When ANCILLARY
is used, the
-z ancillary
option is not
necessary, and can be omitted. The
NULL_SEGMENT
mapfile
directive is then used to direct the data for
non-allocable sections to specific ancillary objects.
Data for non-allocable sections that are not redirected
explicitly is written to the first ancillary object.
The following example demonstrates the creation of
two ancillary objects. The second ancillary object
receives the data for .debug_info
sections, while the data for all other non-allocable
sections are written to the first ancillary object.
$ cat mapfile-anc $mapfile_version 2 ANCILLARY { default; debug_info; }; NULL_SEGMENT extra { ASSIGN_SECTION { IS_NAME = ".debug_info"; OUTPUT_SECTION { ANCILLARY = debug_info }; }; }; $ cc -g -M mapfile-anc hello.c $ file a.out* a.out: ELF 32-bit LSB executable 80386 Version 1 [SSE], dynamically \ linked, not stripped, 2 ancillary objects a.out.anc: ELF 32-bit LSB ancillary 80386 Version 1, \ primary object a.out a.out.debug_info.anc: ELF 32-bit LSB ancillary 80386 Version 1, \ primary object a.out $ elfdump -T SUNW_ancillary a.out Ancillary Section: .SUNW_ancillary index tag value [0] ANC_SUNW_CHECKSUM 0x1324 [1] ANC_SUNW_MEMBER 0x1 a.out [2] ANC_SUNW_CHECKSUM 0x1324 [3] ANC_SUNW_MEMBER 0x7 a.out.anc [4] ANC_SUNW_CHECKSUM 0x9be5 [5] ANC_SUNW_MEMBER 0x11 a.out.debug_info.anc [6] ANC_SUNW_CHECKSUM 0x2e4d [7] ANC_SUNW_NULL 0 $ ./a.out hello world