The form of the
gnatlink command is
$ gnatlink [ switches ] mainprog [.ali] [ non-Ada objects ] [ linker options ]
The arguments of
gnatlink (switches, main
or linker options) may be in any order, provided that no non-Ada object may
be mistaken for a main
Any file name
F without the
extension will be taken as the main
ALI file if a file exists
whose name is the concatenation of
mainprog.ali references the ALI file of the main program.
.ali extension of this file can be omitted. From this
gnatlink locates the corresponding binder file
b~mainprog.adb and, using the information in this file along
with the list of non-Ada objects and linker options, constructs a
linker command file to create the executable.
The arguments other than the
gnatlink switches and the main
ALI file are passed to the linker uninterpreted.
They typically include the names of
object files for units written in other languages than Ada and any library
references required to resolve references in any of these foreign language
units, or in
Import pragmas in any Ada units.
linker options is an optional list of linker specific
The default linker called by gnatlink is
gcc which in
turn calls the appropriate system linker.
One useful option for the linker is
-s: it reduces the size of the
executable by removing all symbol table and relocation information from the
Standard options for the linker such as
-Ldir can be added as is.
For options that are not recognized by
gcc as linker options, use the
Refer to the GCC documentation for details.
Here is an example showing how to generate a linker map:
$ gnatlink my_prog -Wl,-Map,MAPFILE
linker options it is possible to set the program stack and
See Setting Stack Size from gnatlink and
Setting Heap Size from gnatlink.
gnatlink determines the list of objects required by the Ada
program and prepends them to the list of objects passed to the linker.
gnatlink also gathers any arguments set by the use of
pragma Linker_Options and adds them to the list of arguments
presented to the linker.