# Linker scripts

Use linker scripts to provide detailed specifications of how files are
to be linked. The scripts offer greater control over linking than is
available using just the linker command options
([Options](https://docs.qualcomm.com/doc/80-VB419-102/topic/use_the_linker.html#sec-use-the-linker-options)).

Linker scripts control the following properties:

- ELF program header
- Program entry point
- Input and output files and searching paths
- Section memory placement and runtime properties
- Section removal
- Symbol definition

Note

Linker scripts are optional. In most cases, the default
behavior of the linker is sufficient: input sections are merged
according to their section names, and segments are ordered by sections
that share similar permissions

## Use a linker script

A linker script consists of a sequence of commands stored in a text
file. Specify the script file on the command line either with -T or by
indicating the file as an input file. The linker distinguishes between
script files and object files and handles each accordingly.

To generate a map file that shows how a linker script controlled
linking, use the -M option.

Note

Linker scripts are optional. In most cases, the default
behavior of the linker is sufficient.

## Example script file

This linker script demonstrates the scripting features.

Note

The syntax used in linker scripts is similar to the scripts
used with the GNU linker. However, only the features and syntax
described in this document are supported.

ENTRY (main) SEARCH_DIR("./")
    
    PHDRS
    {
       CODE PT_LOAD ; DATA PT_LOAD ;
    }
    
    SECTIONS
    {
       .text.qcldfn (0x2000) : { *(.text.qcldfn*) } : CODE
       . = ALIGN(0x1000);
       PROVIDE( etext = .);
       text_start = . + 0x1000 - 0x1000;
       .text : { EXCLUDE_FILE(*notused.o*) *(.text.*) } : CODE
       .data : { *(.data.*) } : DATA
       .init : { KEEP (*(.init)) }
       . = SEGMENT_START(".bss", 0x80000);
       .bss : { *(.bss.*) }
       bss_start = .;
       bss_end
    }
    = .;
    Copy to clipboard

The following commands specify the link properties:

- The PHDRS command defines two loadable ELF segments.
- The SECTIONS command specifies how input sections are mapped to
output sections, and where output sections are located in memory.
- Wildcard characters in the SECTIONS command indicate that multiple
input sections are mapped to a single output section. A period
indicates the current location counter and is assigned several
different values in the SECTIONS command.

Following are descriptions of the sections in the example script.

- **.text.qcldfn**
    - All input sections whose names begin with .text.qcldfn are mapped to an
output section named .text.qcldfn. This output section is first in the
CODE segment. The merged output section is located at virtual memory
address 0x2000. The location counter then advances to the next 0x1000
address boundary past the end of the .text.qcldfn output section using
the ALIGN directive.

- **etext**
    - Symbol that is defined with the location counter value of any
unresolved symbol references for the symbol using the PROVIDE
command.

- **text\_start**
    - Symbol that is assigned the current location counter value plus any
following arithmetic expression.

- **.text**
    - All input sections whose names begin with .text are mapped to the .text
output section. This output section is put into the CODE segment. The
merged output section is located at the current location counter.

The .text.qcldfn section is not affected by this statement even though
it matches the .text.\* section name wildcard because it is already
merged in the previous link script statement.

- **.data**
    - Current location counter is assigned the base address of the .data
output section with the SEGMENT\_START directive. If undefined, a default
value of 0x50000 is used.

All input sections whose names begin with .data are mapped to the .data
output section. This section is put into the DATA segment. The merged
output section is located at the current location counter as specified
by the preceding statement in the script.

- **.init**
    - All input sections whose names with .init are mapped to the .init output
section. Because no segment is defined, available previous segments are
used instead and the output is put into the DATA segment. The merged
output section is located at the current location counter as specified
by the preceding statement in the script.

- **.bss**
    - The current location counter is assigned the base address of the .bss
output section with the SEGMENT\_START directive. If undefined, a default
value of 0x80000 is used.

All input sections whose names begin with .bss are mapped to the .bss
output section. The merged output section is located at the current
location counter as specified by the preceding statement in the script.
If garbage collection is enabled (with the KEEP directive), none of the
input sections are removed from memory.

The bss\_start and bss\_end symbols are assigned the current location
counter value.

## Basic script syntax

### Symbols

Symbol names must begin with a letter, underscore, or period. They can
include letters, numbers, underscores, hyphens, or periods.

### Comments

Comments can appear in linker scripts:

> 
> 
> `/* comment */`

### Strings

Character strings can be specified as parameters with or without
delimiter characters.

### Expressions

Expressions are similar to C and support all C arithmetic operators.
They are evaluated as type long or unsigned long. For more information,
see [Expressions](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#expressions-1).

### Location counter

A period is used as a symbol to indicate the current location counter.
It is used in the

SECTIONS command only, where it designates locations in the output
section:

. = ALIGN(0x1000);
    . = . + 0x1000;
    Copy to clipboard

Assigning a value to the location counter symbol changes the location
counter to the specified value. The location counter can be moved
forward by arbitrary amounts to create gaps in an output section. It
cannot, however, be moved backwards.

### Symbol assignment

Symbols, including the location counter, can be assigned constants or
expressions:

text_start = . + 0x1000;
    Copy to clipboard

Assignment statements are similar to C, and support all C assignment
operators. Terminate assignment statements with semicolons.

## Script commands

The SECTIONS command must be specified in a linker script. All other
script commands are optional.

For an example linker script (which demonstrates the use of several
commands), see [Example script file](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#example-script-file).

Expressions can be used in several linker script commands. For more
information, see [Expressions](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#expressions-1).

### PHDRS

The PHDRS script command sets information in the program header of an
ELF output file.

PHDRS {
    
    <name type> [FILEHDR][PHDRS][AT (<address>)][FLAGS (<flags>)]
    
    }
    Copy to clipboard

#### Syntax

*&lt;name&gt;*

Specifies the program header in the SECTIONS command
(see [SECTIONS](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#sections)).

*&lt;type&gt;*

Specifies the program header type.

- PT\_LOAD - Loadable segment
- PT\_NULL - Linker does not include section in a segment. No loadable
section should be set to PT\_NULL.
- PT\_DYNAMIC - Segment where dynamic linking information is stored
- PT\_INTERP - Segment where the name of the dynamic linker is stored
- PT\_NOTE - Segment where note information is stored
- PT\_SHLIB - Reserved program header type
- PT\_PHDR - Segment where program headers are stored

- **FILEHDR PHDRS** | **AT (&lt;address&gt;)**
    - Not supported. These options are parsed but have no effect on linking.

- **FLAGS (&lt;flags&gt;)**
    - Specifies the p\_flags field in the ELF header. The value of *p\_flags*
must be an integer.

The FLAGS argument takes a numeric value as input. You can determine the
values by checking the Linux definitions. The loader of the executable
knows about those values.

The following example is from the Elf header file
(*/usr/include/elf.h*):

#define PF_X (1 << 0) /* Segment is executable */
    #define PF_W (1 << 1) /* Segment is writable */
    #define PF_R (1 << 2) /* Segment is readable */
    #define PF_MASKOS 0x0ff00000 /* OS-specific */
    #define PF_MASKPROC 0xf0000000 /* Processor-specific */
    Copy to clipboard

Thus, to set `PF_R|PF_W = (1 << 1) | (1 << 2) = 0x6 and PF_R=0x4`:

> 
> 
> PHDRS {
>        tim0 PT_LOAD FLAGS (0x4); //read only tim1 PT_LOAD FLAGS
>        (0x6);                    //read|write
>     }
>     
>     SECTIONS {
>        .text : { *(.text*) } :A
>     }
>     Copy to clipboard

Note

If the sections in an output file have different flag settings
than PHDRS, the linker chooses the least-restrictive settings for the
output file.

#### PHDRS example

More than one program header specification can be assigned to a given
section. The following linker script generates a linker error indicating
that the same section cannot be included in two different segments:

PHDRS {
       phdr1 PT_LOAD; phdr2 PT_LOAD;
    }
    
    .text : {
       *(*.text*)
    } : phdr1 :phdr2
    Copy to clipboard

The PHDRS command overrides the linker’s default program header
settings. For multiple program headers, only the first can have an LMA
or VMA definition.

For an example linker script that demonstrates the use of the PHDRS, see
[Example script file](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#example-script-file).

### SECTIONS

The SECTIONS script command specifies how input sections are mapped to
output sections, and where output sections are located in memory. This
command must be specified once, and only once, in a linker script. For
an example linker script that demonstrates the use of the SECTIONS, see
[Example script file](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#example-script-file)

SECTIONS {
       <section_statement> <section_statement>
       ...
    }
    Copy to clipboard

#### Section statements

A SECTIONS command contains one or more section statements, where each
statement can be one of the following:

- An ENTRY command ([ENTRY](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#entry)).
- A *symbol assignment statement* to set the location counter ([Symbol assignment](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#symbol-assignment-1)).

    The location counter specifies the default address in subsequent
section-mapping statements that do not explicitly specify an address.
- An *output section description* to specify one or more input sections
in one or more library files, and to map those sections to an output
section.

    The virtual memory address of the output section can be specified using
attribute keywords.

#### Output section description

A SECTIONS command can contain one or more output section descriptions.

<section-name> [<virtual_addr>][(<type>)] :
    [AT(<load_addr>)] [ALIGN(<section_align>)]
    [SUBALIGN(<subsection_align>)] [<constraint>]
    {
       ...
       <output-section-command> <output-section-command>
    }[><region>][AT><lma_region>][:<phdr>...][
    =<fillexp>]
    Copy to clipboard

##### Syntax

- *&lt;section-name&gt;*
    - Specifies the name of the output section.

- *&lt;virtual\_addr&gt;*
    - Specifies the virtual address of the output section (optional). The
address value can be an expression (see [Expressions](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#expressions-1)).

- *&lt;type&gt;*
    - Specifies the section load property (optional).

- NOLOAD - Marks a section as not loadable.
- DSECT - Parsed only; has no effect on linking.
- COPY - Parsed only; has no effect on linking.
- INFO - Parsed only; has no effect on linking.
- OVERLAY - Parsed only; has no effect on linking.

- *&lt;load\_addr&gt;*
    - Specifies the load address of the output section (optional).

The address value can be specified as an expression
(see [Expressions](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#expressions-1)).

- *&lt;section\_align&gt;*
    - Specifies the section alignment of the output section (optional). The
alignment value can be an expression (see [Expressions](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#expressions-1)).

- *&lt;subsection\_align&gt;*
    - Specifies the subsection alignment of the output section (optional). The
alignment value can be an expression (see [Expressions](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#expressions-1)).

- *&lt;constraint&gt;*
    - Specifies the access type of the input sections (optional).

- NOLOAD - All input sections are read-only.
- DSECT - All input sections are read/write (default).

- *&lt;output-section-command&gt;*
    - Specifies an output section command
(see [Output section commands](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#output-section-commands)).

An output section description contains one or more output section
commands.

- *&lt;region&gt;*
    - Specifies the region of the output section (optional). The region is
expressed as a string.

This option is parsed but has no effect on linking.

- *&lt;lma-region&gt;*
    - Specifies the load memory address (LMA) region of the output section
(optional). The value can be an expression.

This option is parsed, but it has no effect on linking.

- *&lt;fillexp&gt;*
    - Specifies the fill value of the output section (optional). The value can
be an expression.

This option is parsed, but it has no effect on linking.

- *&lt;phdr&gt;*
    - Specifies a program segment for the output section (optional).

To assign multiple program segments to an output section, this option
can appear more than once in an output section description.

Note

Setting phdr in an output section description will affect
subsequent output sections. This behavior differs from the GNU linker.

#### Output section commands

An output section description contains one or more output section
commands. An output section command consists of one or more statements
separated by semicolons. The statements can be any of the following:

- Output section data
- Output section keyword
- *Symbol assignment statement* to set the location counter (see
[Symbol assignment](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#symbol-assignment-1)). The location counter
specifies the default address in subsequent section-mapping
statements that do not explicitly specify an address.
- *Input section description* to specify one or more input sections in
one or more library files (see [Input section description](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#input-section-description)).

#### Output section data

The OUTPUT\_SECTION\_DATA operator can be used to include specific bytes
of data from an expression value ([Expressions](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#expressions-1)).

OUTPUT_SECTION_DATA_<keyword>(<expression>)
    Copy to clipboard

Where *&lt;keyword&gt;* can have literal values: BYTE, SHORT, LONG, QUAD, or
SQUAD.

Note

Currently, output section data is not supported by the linker.
The keyword is parsed but the data value generated is undefined and the
linker does not generate a warning message. Replace all output section
data references with fill expressions ([Output section description](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#output-section-description)).

#### Output section keywords

For compatibility with the GNU linker, the CREATE\_OBJECT\_SYMBOLS,
CONSTRUCTORS, and SORT\_BY\_NAME(CONSTRUCTORS) keywords are parsed,
but they have no effect on linking.

#### Input section description

An output section command may contain one or more input section
descriptions. An input section description specifies the sections to be
linked and the files they are contained in. An input section description
has the following basic syntax for specifying a section in an object
file:

<file_name>(<section_name>)
    Copy to clipboard

A single input section description can specify multiple files or
sections:

<file_name>[:<file_name>]...
    (<section_name>[<section_name>[...)
    Copy to clipboard

Separate multiple file names with colons, and separate multiple section
names with spaces.

The \* and ? wildcard characters can be used in file names and section
names. For example, the following input file description specifies all
input sections named .text\* contained in all linker input files:

*(.text*)
    Copy to clipboard

Use the EXCLUDE\_FILE operator to reduce the number of items matched by a
wildcard expression. Excluded items can be files, archives, or archive
members. For example:

*(EXCLUDE_FILE(*crtend.o) .text .data)
    Copy to clipboard

This example specifies all the linker input files except for any files
named \*crtend.o.

Note

If an exclusion is used in a list of section names, it applies
only to the immediately following section name in the list (.text in the
example above). For examples of using exclusions, see
[Linker script examples](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#linker-script-examples).

Use the KEEP operator to prevent the linker performing garbage
collection on unused sections when the -gc-sections linker option is
used. For example:

KEEP(*(.init))
    Copy to clipboard

This example says that the input section.init will be retained by the
linker even if it is not referenced in the program being linked.

Note

For compatibility with the GNU linker, the following sort
operators are all parsed, but they have no effect on linking:
SORT\_NONE, SORT\_BY\_NAME, SORT\_BY\_ALIGNMENT, and
SORT\_BY\_INIT\_PRIORITY.

#### Orphan section placement

Orphan sections are sections that are present in the input files but not
explicitly placed into the output file by the linker script. The linker
will still copy these sections into the output file but without
attempting to place them anywhere. The linker uses a simple heuristic
and attempts to place orphan sections with the following steps:

1. The linker checks the properties of the section that it is to
automatically place.

    It looks for these properties in the text, data, and bss sections or any
predefined section in the linker. If a match is found, the linker places
the orphan section at the predefined location.
2. If the orphan section does not match any predefined sections, the
linker places the orphan section after nonorphan sections of the same
attribute or permissions.

A special category of orphan sections have an attribute that the
compiler tells the linker to place. The compiler communicates this by
using an attribute that specifies an address. You can use attribute
((at(*XXX*))) to specify the address. The linker uses this information
to place the section at the specified address. If there is not enough
room, it produces an error.

### ENTRY

The ENTRY script command specifies the program execution entry point.
The entry point is the first instruction that is executed after a
program is loaded.

ENTRY (<symbol>)
    Copy to clipboard

This command is equivalent to the linker command-line option, -e.

### OUTPUT\_FORMAT

The OUTPUT\_FORMAT script command specifies the output file properties.
For compatibility with the GNU linker, this command is parsed but has no
effect on linking.

OUTPUT_FORMAT (<string>)
    Copy to clipboard

### OUTPUT\_ARCH

The OUTPUT\_ARCH script command specifies the target processor
architecture. For compatibility with the GNU linker, this command is
parsed but has no effect on linking.

OUTPUT_ARCH ("aarch64")
    Copy to clipboard

### SEARCH\_DIR

The SEARCH\_DIR script command specifies which adds the specified path to
the list of paths that the linker uses to search for libraries.

SEARCH_DIR (<path>)
    Copy to clipboard

This command is equivalent to the linker command-line option, -L.

### INCLUDE

The INCLUDE script command specifies the contents of the text file at
the current location in the linker script. The specified file is
searched for in the current directory and any directory that the linker
uses to search for libraries.

Note

Include files can be nested.

INCLUDE (<file>)
    Copy to clipboard

### OUTPUT

The OUTPUT script command defines the location and file where the linker
will write output data. Only one output is allowed per linking.

OUTPUT (<file>)
    Copy to clipboard

### GROUP

The GROUP script command includes a list of achieved file names. The
achieved names defined in the list are searched repeatedly until all
defined references are resolved.

GROUP (<file>, <file>, ...)
    Copy to clipboard

### ASSERT

The ASSERT script command adds an assertion to the linker script.

ASSERT(<expression>, <string>)
    Copy to clipboard

### NOCROSSREFS

The NOCROSSREFS command takes a list of space-separated output section
names as its arguments. Any cross-references among these output sections
will result in link editor failure. The list can also contain an orphan
section that is not specified in the linker script.

NOCROSSREFS(<section> <section> ...)
    Copy to clipboard

A linker script can contain multiple NOCROSSREFS commands. Each command
is treated as an independent set of output sections that are checked for
cross-references.

## Expressions

Expressions in linker scripts are identical to C expressions. They are
evaluated in 32-bit for Arm architecture and 64-bit for AArch64
architecture.

In addition to the SECTION command operators ([SECTIONS](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#sections)), the
linker defines the following functions that can be used in linker script
expressions.

- **.**
    - Return the location counter value representing the current virtual address.

- **ABSOLUTE (&lt;expression&gt;)**
    - Return the absolute value of the expression.

- **ADDR (&lt;string&gt;)**
    - Return the virtual address of the symbol or section. A period character
(.) is supported.

- **ALIGN (&lt;expression&gt;)**
    - Return the value when the current location counter is aligned to the
next expression boundary. The value of the current location counter is
not changed.

- **ALIGN (&lt;expression1&gt;, &lt;expression2&gt;)**
    - Return the value when the value of *expression1* is aligned to the next
*expression2* boundary.

- **ALIGNOF (&lt;string&gt;)**
    - Return the align information of the symbol or section.

- **ASSERT (&lt;expression&gt;, &lt;string&gt;)**
    - Throw an assertion if the expression result is zero.

- **BLOCK (&lt;expression&gt;)**
    - Synonym for ALIGN (*expression*).

- **CONSTANT (COMMONPAGESIZE)**
    - Return the defined common page size.

- **CONSTANT (MAXPAGESIZE)**
    - Return the defined default page size required by the ABI.

- **DATA\_SEGMENT\_ALIGN(&lt;maxpagesize&gt;, &lt;commonpagesize&gt;)**
    - Equivalent to:

`(ALIGN(maxpagesize)+(.&(maxpagesize ? 1)))`

Or

`ALIGN(maxpagesize)+(.&(maxpagesize -commonpagesize)))`

The linker computes both of these values and returns the larger one.

- **DATA\_SEGMENT\_END (&lt;expression&gt;)**
    - Not used; return the value of the expression.

- **DATA\_SEGMENT\_RELRO\_END(&lt;expression&gt;)**
    - Not used; return the value of the expression.

- **DEFINED (&lt;symbol&gt;)**
    - Return 1 if the symbol is defined in the global symbol table of the
linker. Otherwise, return 0.

- **LOADADDR (&lt;string&gt;)**
    - Synonym for ADDR (*string*).

- **MAX (&lt;expression&gt;, &lt;expression&gt;)**
    - Return the maximum value of two expressions.

- **MIN (&lt;expression1&gt;, &lt;expression2&gt;)**
    - Return the minimum value of two expressions.

- **SEGMENT\_START (&lt;string&gt;,&lt;expression&gt;)**
    - If a string matches a known segment, return the start address of that
segment. If nothing is found, return the value of the expression.

- **SIZEOF (&lt;string&gt;)**
    - Return the size of the symbol, section, or segment.

- **SIZEOF\_HEADERS**
    - Return the section start file offset.

## Symbol assignment

Any symbol defined in a linker script becomes a global symbol. The
following C assignment operators are supported to assign a value to a
symbol:

symbol = expression;
    symbol += expression;
    symbol -= expression;
    symbol *= expression;
    symbol /= expression;
    symbol &= expression;
    symbol |= expression;
    symbol <<= expression;
    symbol >>= expression;
    Copy to clipboard

The first statement defines a symbol and assigns it the value of the
expression. In the other statements, the symbol must already be defined.
All the statements must be terminated with semicolons.

A common way to create an empty space in memory is to use the
.+=space\_size expression. For example, the following statement generates
a section named BSS1 with size 0x2000:

> 
> 
> `BSS1 { . += 0x2000 }`

The linker script supports the following symbol assignment functions.

> 
> 
> `HIDDEN (<symbol = expression>)`

Hide the defined symbol so it is not exported.

> 
> 
> `FILL (<expression>)`

Specify the fill value for the current section.

The fill length can be 1, 2, 4, or 8. The linker determines the length
by selecting the minimum fit length. In the following example, the fill
length is 8:

> 
> 
> `FILL( 0xdeadc0de )`

A FILL statement covers memory locations from the point at which it
occurs to the end of the current section.

Multiple FILL statements can be used in an output section definition to
fill different parts of the section with different patterns.

> 
> 
> `ASSERT (<expression>, <string>)`

When the specified expression is zero, the linker throws an assertion
with the specified message string.

> 
> 
> `PROVIDE (<symbol = expression>)`

Similar to symbol assignment, but does not perform checking for an
unresolved reference.

> 
> 
> `PROVIDE_HIDDEN (<symbol = expression>)`

Similar to PROVIDE, but hides the defined symbol so it will not be
exported.

> 
> 
> `PRINT (<symbol = expression>)`

Instruct the linker to print symbol name and expression value to
standard output during parsing.

## Linker script examples

The following example linker scripts show how to specify input files for
linking. The examples use the EXCLUDE\_FILE operator, which is defined in
the input section descriptions

([Input section description](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#input-section-description)).

### Exclude file in archive

To exclude a file in an archive from linking, specify the archive as
part of the input expression, and specify the file to be excluded as the
parameter of the following the EXCLUDE\_FILE operator.

The following example uses four relocatable files: a1.o, a2.o, a3.o, and
a4.o. Each file contains functions named foo\_N and bar\_N, where N
indicates the digit in the file name. The linker script excludes foo\_2
but not bar\_2 from .text1 because EXCLUDE\_FILE applies only to the
immediately following section name.

script.t : SECTIONS {
       .text1 : {
          *lib23.a:(EXCLUDE_FILE(a2.o) .text.foo* .text.bar*)
       }
       .text2 : {
          *(*)
       }
    }
    
    clang -ffunction-sections -c a1.c a2.c a3.c a4.c
    arm-ar cr lib23.a a2.o a3.o arm-ar cr lib4.a a4.o
    arm-link -T script.t -o mcld.out a1.o --whole-archive lib23.a lib4.a --no- whole-archive
    Copy to clipboard

Section headers starting at offset 0x22a0 are printed as follows:

[Nr]   Name     Type       Addr           Off      Size     ES   Flg   Lk  Inf   Al
    [ 0]            NULL       00000000   000000   000000   00   0     0   0
    [ 1]   .text1   PROGBITS     00000000   001000   00002c   00   AX    0   0     16
    [ 2]   .text2   PROGBITS     00000030   002030   00009c   00   WAX   0   0     16
    Copy to clipboard

The symbol table is printed as follows:

Num: Value Size Type Bind Vis Ndx Name

Num: Value    Size Type      Bind       Vis     Ndx Name
    8:      00000040     12        FUNC  GLOBAL  DEFAULT 2        bar_1
    9:      00000000     12        FUNC  GLOBAL  DEFAULT 1        bar_2
    10:  00000020        12        FUNC  GLOBAL  DEFAULT 1        bar_3
    11:  000000c0        12        FUNC  GLOBAL  DEFAULT 2        bar_4
    12:  00000030        12        FUNC  GLOBAL  DEFAULT 2        foo_1
    13:  000000a0        12        FUNC  GLOBAL  DEFAULT 2        foo_2
    14:  00000010        12        FUNC  GLOBAL  DEFAULT 1        foo_3
    15:  000000b0        12        FUNC  GLOBAL  DEFAULT 2        foo_4
    Copy to clipboard

### Exclude all files in archive

To exclude all files in an archive from linking, specify the archive to
be excluded as the parameter of the EXCLUDE\_FILE operator.

The following example uses four relocatable files: a1.o, a2.o, a3.o,
and a4.o. Each file contains functions named foo\_N and bar\_N, where N
indicates the digit in the file name. The linker script excludes
foo\_2/3 but not bar\_2/3 from .text1 because EXCLUDE\_FILE applies only
to the immediately following section name.

script.t : SECTIONS {
       .text1 : {
          *lib*:(EXCLUDE_FILE(*lib23.a) .text.foo* .text.bar*) }
       .text2 : {
          *(*)
       }
    }
    clang -ffunction-sections -c a1.c a2.c a3.c a4.c arm-ar cr lib23.a a2.o a3.o arm-ar cr lib4.a a4.o
    arm-link -T script.t -o mcld.out a1.o --whole-archive lib23.a lib4.a --no- whole-archive
    Copy to clipboard

Section headers starting at offset 0x22a0 are printed as follows:

[Nr] Name       Type     Addr              Off           Size           ES   Flg     Lk      Inf     Al
    [ 0]            NULL     00000000    000000   000000 00                 0    0          0
    [ 1] .text1  PROGBITS         00000000       001000   00003c 00      AX         0    0          16
    [ 2] .text2  PROGBITS         00000040       002040   00008c 00      WAX     0       0          16
    Copy to clipboard

The symbol table is printed as follows:

Num: Value       Size   Type    Bind    Vis     Ndx  Name
    8:      00000050        12       FUNC           GLOBAL       DEFAULT 2         bar_1
    9:      00000000        12       FUNC           GLOBAL       DEFAULT 1         bar_2
    10:  00000010           12       FUNC           GLOBAL       DEFAULT 1         bar_3
    11:  00000030           12       FUNC           GLOBAL       DEFAULT 1         bar_4
    12:  00000040           12       FUNC           GLOBAL       DEFAULT 2         foo_1
    13:  000000b0           12       FUNC           GLOBAL       DEFAULT 2         foo_2
    14:  000000c0           12       FUNC           GLOBAL       DEFAULT 2         foo_3
    15:  00000020           12       FUNC           GLOBAL       DEFAULT 1         foo_4
    Copy to clipboard

### Exclude multiple files

To exclude multiple files from linking, specify the files as parameters
of the EXCLUDE\_FILE operator.

EXCLUDE\_FILE accepts multiple file name parameters.

The following example uses four relocatable files: a1.o, a2.o, a3.o,
and a4.o. Each file contains functions named foo\_N and bar\_N, where N
indicates the digit in the file name. The linker script excludes
foo\_2/3 but not bar\_2/3 from .text1 because EXCLUDE\_FILE applies only
to the immediately following section name.

script.t : SECTIONS {
       .text1 : {
          *lib*:(EXCLUDE_FILE(a2.0 a3.0) .text.foo* .text.bar*)
       }
       .text2 : {
          *(*)
       }
    }
    
    clang -ffunction-sections -c a1.c a2.c a3.c a4.c arm-ar cr lib23.a a2.o a3.o arm-ar cr lib4.a a4.o
    arm-link -T script.t -o mcld.out a1.o --whole-archive lib23.a lib4.a --no- whole-archive
    Copy to clipboard

Section headers starting at offset 0x2260 are printed as follows:

[Nr] Name       Type     Addr              Off          Size    ES    Flg    Lk       Inf    Al
    [ 0]            NULL     00000000    000000  000000  00              0       0        0
    [ 1] .text1  PROGBITS         00000000       001000  00003c  00       AX     0        0         16
    [ 2] .text2  PROGBITS         00000040       002040  000040  00       WAX    0        0         16
    Copy to clipboard

The symbol table is printed as follows:

Num: Value       Size   Type Bind       Vis     Ndx  Name
    8:      00000050        12       FUNC        GLOBAL  DEFAULT 2         bar_1
    9:      00000000        12       FUNC        GLOBAL  DEFAULT 1         bar_2
    10:  00000010           12       FUNC        GLOBAL  DEFAULT 1         bar_3
    11:  00000030           12       FUNC        GLOBAL  DEFAULT 1         bar_4
    12:  00000040           12       FUNC        GLOBAL  DEFAULT 2         foo_1
    13:  00000060           12       FUNC        GLOBAL  DEFAULT 2         foo_2
    14:  00000070           12       FUNC        GLOBAL  DEFAULT 2         foo_3
    15:  00000020           12       FUNC        GLOBAL  DEFAULT 1         foo_4
    Copy to clipboard

### Exclude archive and non-archive files

To exclude archive and non-archive files from linking, specify the files
as parameters of the

EXCLUDE\_FILE operator. EXCLUDE\_FILE searches inside and outside
archives for files to exclude.

The following example uses four relocatable files: a1.o, a2.o, a3.o,
and a4.o. Each file contains functions named foo\_N and bar\_N, where N
indicates the digit in the file name. The linker script excludes
foo\_1/2 but not bar\_1/2 from .text1 because EXCLUDE\_FILE applies only
to the immediately following section name.

script.t : SECTIONS {
       .text1 : {
          *:(EXCLUDE_FILE(a[12].o) .text.foo* .text.bar*)
       }
       .text2 : {
          *(*)
       }
    }
    
    clang -ffunction-sections -c a1.c a2.c a3.c a4.c arm-ar cr lib23.a a2.o a3.o arm-ar cr lib4.a a4.o
    arm-link -T script.t -o mcld.out a1.o --whole-archive lib23.a lib4.a --no- whole-archive
    Copy to clipboard

Section headers starting at offset 0x2260 are printed as follows:

[Nr] Name       Type     Addr              Off          Size    ES      Flg  Lk       Inf    Al
    [ 0]            NULL     00000000    000000  000000  00                    0  0         0
    [ 1] .text1  PROGBITS         00000000       001000  00004c  00         AX      0     0    16
    [ 2] .text2  PROGBITS         00000050       002050  000030  00         WAX  0        0         16
    Copy to clipboard

The symbol table is printed as follows:

Num: Value       Size   Type Bind       Vis     Ndx  Name
    8:      00000060        12       FUNC        GLOBAL  DEFAULT 2         bar_1
    9:      00000000        12       FUNC        GLOBAL  DEFAULT 1         bar_2
    10:  00000020           12       FUNC        GLOBAL  DEFAULT 1         bar_3
    11:  00000040           12       FUNC        GLOBAL  DEFAULT 1         bar_4
    12:  00000050           12       FUNC        GLOBAL  DEFAULT 2         foo_1
    13:  00000070           12       FUNC        GLOBAL  DEFAULT 2         foo_2
    14:  00000010           12       FUNC        GLOBAL  DEFAULT 1         foo_3
    15:  00000030           12       FUNC        GLOBAL  DEFAULT 1         foo_4
    Copy to clipboard

### Conflicting wildcards

To exclude archive and nonarchive files from linking, specify the files
as parameters of the

EXCLUDE\_FILE operator. EXCLUDE\_FILE earches inside and outside
archives for files to exclude.

The following example uses four relocatable files: a1.o, a2.o, a3.o, and
a4.o. Each file contains functions named foo\_N and bar\_N, where N
indicates the digit in the file name. The linker script excludes foo\_1/2
but not bar\_1/2 from .text1 because EXCLUDE\_FILE applies only to the
immediately following section name.

script.t : SECTIONS {
       .text1 : {
          *:(EXCLUDE_FILE(a[12].o) .text.foo* .text.bar*)
       }
       .text2 : {
          *(*)
       }
    }
    clang -ffunction-vb419sections -c a1.c a2.c a3.c a4.c arm-ar cr lib23.a a2.o a3.o arm-ar cr lib4.a a4.o
    arm-link -T script.t -o mcld.out a1.o --whole-archive lib23.a lib4.a --no- whole-archive
    Copy to clipboard

Section headers starting at offset 0x2260 are printed as follows:

[Nr] Name       Type     Addr              Off          Size    ES    Flg    Lk       Inf    Al
    [ 0]            NULL     00000000    000000  000000  00                 0     0         0
    [ 1] .text1  PROGBITS         00000000       001000  00004c  00       AX     0        0         16
    [ 2] .text2  PROGBITS         00000050       002050  000030  00       WAX    0        0         16
    Copy to clipboard

The symbol table is printed as follows:

Num: Value          Size    Type        Bind    Vis  Ndx Name
    8:      00000060     12          FUNC           GLOBAL       DEFAULT 2          bar_1
    9:      00000000     12          FUNC           GLOBAL       DEFAULT 1          bar_2
    10:  00000020        12          FUNC           GLOBAL       DEFAULT 1          bar_3
    11:  00000040        12          FUNC           GLOBAL       DEFAULT 1          bar_4
    12:  00000050        12          FUNC           GLOBAL       DEFAULT 2          foo_1
    13:  00000070        12          FUNC           GLOBAL       DEFAULT 2          foo_2
    14:  00000010        12          FUNC           GLOBAL       DEFAULT 1          foo_3
    15:  00000030        12          FUNC           GLOBAL       DEFAULT 1          foo_4
    Copy to clipboard

### GNU linker options

This section lists all GNU linker options (arranged by linker support
and no linker support). The slashes (/) in certain options indicate
aliases for those options.

#### [Options supported by the linker](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#id11)

@FILE | --allow-multiple-definition
    --allow-shlib-undefined | --no-allow-shlib-undefined
    --as-needed | --no-as-needed
    -Bdynamic / -dy / -call_shared | -Bgroup
    -Bstatic / -dn / -non_shared / -static
    -Bsymbolic | -Bsymbolic-functions
    --build-id[=<STYLE>]
    --copy-dt-needed-entries | --no-copy-dt-needed-entries
    --cref | -d / -dc / -dp
    --defsym <SYMBOL>=<EXPRESSION>| --discard-all / -x
    --discard-locals / -X | --dynamic-linker *PROGRAM*
    --dynamic-list <FILE> | --emit-reloc
    --enable-new-dtags | --disable-new-dtags
    --eh-frame-hdr | --entry <ADDRESS> / -e <ADDRESS>
    --exclude-libs=<LIBS>
    --export-dynamic / -E | --no-export-dynamic
    --fatal-warnings | --no-fatal-warnings
    -fini <SYMBOL>
    --fix-cortex-a53-835769 | --[no-]fix-cortex-a8
    -flto | -g
    --gc-sections | --no-gc-sections
    --gpsize <SIZE> / -G <SIZE> | --hash-size=<NUMBER>
    --hash-style=<STYLE> | --help
    -init <SYMBOL>
    --just-symbols <FILE> / -R <FILE>-library <LIBNAME> / -l <LIBNAME>
    --library-path <DIRECTORY> / -L <DIRECTORY>
    -m <EMULATION> | -Map <FILE>
    -no-demangle | --no-undefined
    --no-warn-mismatch | --noinhibit-exec
    -nostdlib | --nmagic / -n
    --omagic / -N | --no-omagic
    -output <FILE> / -o <FILE> | -P <AUDITLIB>
    --pic-executable / -pie | --print-gc-sections
    --print-map / -M | -Qy
    -r | --script <FILE> / -T <FILE>
    --default-script <FILE> | --section-start SECTION=<ADDRESS>
    -shared | -Bshareable | -soname <FILENAME> / -h <FILENAME>
    --start-group | --end-group
    --strip-all / -s / -S | --strip-debug
    --sysroot=<DIRECTORY> | --undefined <SYMBOL> / -u <SYMBOL>
    --verbose [=<NUMBER>] | --version
    --warn-common | --warn-once
    --warn-shared-textrel
    --whole-archive | --no-whole-archive
    --wrap <SYMBOL> | -Y <PATH>
    -z combreloc | -z nocombreloc
    -z common-page-size=<SIZE> | -z defs
    -z execstack | -z noexecstack
    -z global | -z initfirst
    -z lazy | -z max-page-size=<SIZE>
    -z muldefs | -z nocopyreloc
    -z nodelete | -z now
    -z origin
    -z relro | -z norelro
    Copy to clipboard

#### [Options supported by the linker but with different usage](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#id12)

--trace / -t
    Copy to clipboard

#### [Options not supported by the linker](https://docs.qualcomm.com/doc/80-VB419-102/topic/linker_scripts.html#id13)

-(
    -)
    -a <KEYWORD>
    --accept-unknown-input-arch | --no-accept-unknown-input-arch
    --architecture <ARCH> / -A <ARCH> | -assert <KEYWORD>
    --audit=<AUDITLIB> | --depaudit=<AUDITLIB>
    --be8
    --check-sections | --no-check-sections
    --default-symver | --default-imported-symver
    --demangle [=<STYLE>] | --discard-none
    -dT | --dynamic-list-data
    --dynamic-list-cpp-new | --dynamic-list-cpp-typeinfo
    -EB | -EL
    --embedded-relocs
    -f <SHLIB> / -F <SHLIB> / --filter <SHLIB> / --auxiliary <SHLIB> Auxiliary
    --fix-v4bx | --fix-v4bx-interworking
    -flto-partition= | --force-exe-suffix
    --format <TARGET> / -b <TARGET> | -fuse-ld=
    -I <PROGRAM> | --ignore-unresolved-symbol <SYMBOL>
    --long-plt | --mri-script <FILE> / -c <FILE>
    --no-define-common | --no-enum-size-warning
    --[no-]fix-arm1176 | --no-keep-memory
    --no-merge-exidx-entries | --no-print-gc-sections
    --no-undefined-version | --no-warn-search-mismatch
    --no-wchar-size-warning | -O
    --oformat <TARGET> | --pic-veneer
    -plugin <PLUGIN> | -plugin-opt <ARG>
    --print-output-format | --print-sysroot
    --push-state | --pop-state
    -q | -qmagic
    --reduce-memory-overheads
    --relax | --no-relax
    --relocatable / -i | --retain-symbols-file <FILE>
    -rpath <PATH> | -rpath-link <PATH>
    --sort-common | --sort-section
    --spare-dynamic-tags <COUNT> | --split-by-file [=<SIZE>]
    --split-by-reloc [=<COUNT>] | --stats
    --strip-discarded | --no-strip-discarded
    --stub-group-size=<N> | -Tbss <ADDRESS>
    -Tdata <ADDRESS> | -Tldata-segment <ADDRESS>
    -Ttext <ADDRESS> | -Ttext-segment <ADDRESS>
    -Trodata-segment <ADDRESS> | --target-help
    --target1-rel | --target1-abs
    --target2=<type> | --task-link <SYMBOL>
    --thumb-entry=<sym> | --trace-symbol <SYMBOL> / -y <SYMBOL>
    --traditional-format | --unique [=<SECTION>]
    --unresolved-symbols=<method> | -Ur
    --use-blx
    -v | -V
    --version-script <FILE> | --version-exports-section <SYMBOL>
    --vfp11-denorm-fix | --warn-constructors
    --warn-multiple-gp | --warn-section-align
    -z interpose | -z loadfltr
    -z nodefaultlib | -z nodlopen
    -z nodump | -z stacksize=<SIZE>
    Copy to clipboard

#### Options supported by the linker

- **@FILE**
    - Read options from FILE.

- **–allow-multiple-definition**
    - Allow multiple definitions.

- **–allow-shlib-undefined**
    - Allow unresolved references in shared libraries.

- **–no-allow-shlib-undefined**
    - Do not allow unresolved references in shared libraries.

- **–as-needed**
    - Only set DT\_NEEDED for following dynamic libs if used.

- **–no-as-needed**
    - Always set DT\_NEEDED for dynamic libraries mentioned on the command line.

- **-Bdynamic** | **-dy** | **-call\_shared**
    - Link against shared libraries.

- **-Bgroup**
    - Select the group name lookup rules for the DSO.

- **-Bstatic** | **-dn** | **-non\_shared** | **-static**
    - Do not link against shared libraries.

- **-Bsymbolic**
    - Bind global references locally.

- **-Bsymbolic-functions**
    - Bind global function references locally.

- **–build-id[=&lt;STYLE&gt;]**
    - Generate a build ID note.

- **–copy-dt-needed-entries**
    - Copy DT\_NEEDED links mentioned inside DSOs that follow.

- **–no-copy-dt-needed-entries**
    - Do not copy DT\_NEEDED links mentioned inside DSOs that follow.

- **–cref**
    - Output a cross-reference table.

- **-d** | **-dc** | **-dp**
    - Force common symbols to be defined.

- **–defsym &lt;SYMBOL&gt;=&lt;EXPRESSION&gt;**
    - Define a symbol.

- **–discard-all** | **-x**
    - Discard all local symbols.

- **–discard-locals** | **-X**
    - Discard temporary local symbols (default).

- **–dynamic-linker** *PROGRAM*
    - Set PROGRAM as the dynamic linker to use.

- **–dynamic-list** *FILE*
    - Read the dynamic list.

- **–emit-relocs**
    - Generate relocations in the final output.

- **–enable-new-dtags**
    - Enable new dynamic tags.

- **–disable-new-dtags**
    - Disable new dynamic tags.

- **–eh-frame-hdr**
    - Create an .eh\_frame\_hdr section.

- **–entry** *ADDRESS* | **-e** *ADDRESS*
    - Set the start address.

- **–exclude-libs=&lt;LIBS&gt;**
    - Hide all symbols in LIBS.

- **–export-dynamic** | **-E**
    - Export all dynamic symbols.

- **–no-export-dynamic**
    - Undo the effect of –export-dynamic.

- **–fatal-warnings**
    - Treat warnings as errors.

- **–no-fatal-warnings**
    - Do not treat warnings as errors (default).

- **-fini** *SYMBOL*
    - Call SYMBOL at unload time.

- **–fix-cortex-a53-835769**
    - Fix erratum 835769.

- **–[no-]fix-cortex-a8**
    - Disable or enable a Cortex A8 Thumb 2 branch erratum fix.

- **-flto**
    - Ignored for GCC LTO option compatibility.

- **-g**
    - Ignored.

- **–gc-sections**
    - Remove unused sections (on some targets).

- **–no-gc-sections**
    - Do not remove unused sections (default).

- **–gpsize** *SIZE* | **-G** *SIZE*
    - Small data size. If no size is specified, the size is the same as `--shared`.

- **–hash-size=&lt;NUMBER&gt;**
    - Set the default hash table size close to *NUMBER*.

- **–hash-style=&lt;STYLE&gt;**
    - Set the hash style to sysv, gnu, or both.

- **–help**
    - Print option help.

- **-init** *SYMBOL*
    - Call SYMBOL at load time.

- **–just-symbols** *FILE* | **-R** *FILE*
    - Just link symbols. If a directory, same as –rpath.

- **–library** *LIBNAME* | **-l** *LIBNAME*
    - Search for library, *LIBNAME*.

- **–library-path** *DIRECTORY* | **-L** *DIRECTORY*
    - Add DIRECTORY to the library search path.

- **-m** *EMULATION*
    - Set the emulation.

- **-Map** *FILE*
    - Write a map file.

- **–no-demangle**
    - Do not demangle symbol names.

- **–no-undefined**
    - Do not allow unresolved references in object files.

- **–no-warn-mismatch**
    - Do not warn about mismatched input files.

- **–noinhibit-exec**
    - Create an output file even if errors occur.

- **-nostdlib**
    - Only use the library directories specified on the command line.

- **–nmagic** | **-n**
    - Do not page align the data.

- **–omagic** | **-N**
    - Do not page align the data. Do not make the text read-only.

- **–no-omagic**
    - Page the data. Do not make the text read-only.

- **–output** *FILE* | **-o** *FILE*
    - Set the output file name.

- **-P** *AUDITLIB*
    - Specify a library to use for auditing dependencies.

- **–pic-executable** | **-pie**
    - Create a PIE file.

- **–print-gc-sections**
    - List removed unused sections on stderr.

- **–print-map** | **-M**
    - Print the map file on standard output.

- **-Qy**
    - Ignored for SVR4 compatibility.

- **-r**
    - Generate the relocatable output.

- **–script** *FILE* | **-T** *FILE*
    - Read the linker script.

- **–default-script** *FILE*
    - Read the default linker script.

- **–section-start &lt;SECTION&gt;=&lt;ADDRESS&gt;**
    - Set the address of the named section.

- **-shared** | **-Bshareable**
    - Create a shared library.

- **-soname** *FILENAME* | **-h** *FILENAME*
    - Set the internal name of shared library.

- **–start-group**
    - Start a group.

- **–end-group**
    - End a group.

- **–strip-all** | **-s** | **-S**
    - Strip all symbols.

- **–strip-debug**
    - Strip debugging symbols.

- **–sysroot=&lt;DIRECTORY&gt;**
    - Override the default sysroot location.

- **–undefined** *SYMBOL* | **-u** *SYMBOL*
    - Start with an undefined reference to SYMBOL.

- **–verbose [=&lt;NUMBER&gt;]**
    - Output lots of information during link.

- **–version**
    - Print the version information.

- **–warn-common**
    - Warn about duplicate common symbols.

- **–warn-once**
    - Warn only once per undefined symbol.

- **–warn-shared-textrel**
    - Warn if a shared object has DT\_TEXTREL.

- **–whole-archive**
    - Include all objects from the archives that follow.

- **–no-whole-archive**
    - Turn off –whole-archive.

- **–wrap** *SYMBOL*
    - Use wrapper functions for SYMBOL.

- **-Y** *PATH*
    - Default search path for Solaris compatibility.

- **-z combreloc**
    - Merge dynamic relocations into one section and sort.

- **-z nocombreloc**
    - Do not merge dynamic relocations into one section.

- **-z common-page-size=&lt;SIZE&gt;**
    - Set the common page size to *SIZE*.

- **-z defs**
    - Report unresolved symbols in object files.

- **-z execstack**
    - Mark an executable as requiring an executable stack.

- **-z noexecstack**
    - Mark an executable as not requiring an executable stack.

- **-z global**
    - Make symbols in the DSO as available for subsequently loaded objects.

- **-z initfirst**
    - Mark the DSO to be initialized first at runtime.

- **-z lazy**
    - Mark an object as lazy runtime binding (default).

- **-z max-page-size=&lt;SIZE&gt;**
    - Set the maximum page size to *SIZE*.

- **-z muldefs**
    - Allow multiple definitions.

- **-z nocopyreloc**
    - Do not create copy relocations.

- **-z nodelete**
    - Mark the DSO as non-deletable at runtime.

- **-z now**
    - Mark an object as non-lazy runtime binding.

- **-z origin**
    - Mark an object as requiring immediate $ORIGIN processing at runtime.

- **-z relro**
    - Create a RELRO program header.

- **-z norelro**
    - Do not create the RELRO program header.

#### Options supported by the linker but with different usage

- **–trace** | **-t**
    - Trace file opens.

#### Options not supported by the linker

- **-(**
    - Start a group.

- **-)**
    - End a group.

- **-a** *KEYWORD*
    - Shared library control for HP/UX compatibility.

- **–accept-unknown-input-arch**
    - Accept input files whose architecture cannot be determined.

- **–no-accept-unknown-input-arch**
    - Reject input files whose architecture is unknown.

- **–architecture &lt;ARCH&gt;** | **-A &lt;ARCH&gt;**
    - Set the architecture.

- **-assert &lt;KEYWORD&gt;**
    - Ignored for Sun OS compatibility.

- **–audit=&lt;AUDITLIB&gt;**
    - Specify a library to use for auditing.

- **–depaudit=&lt;AUDITLIB&gt;**
    - Specify a library to use for auditing dependencies.

- **–be8**
    - Output the BE8 format image.

- **–check-sections**
    - Check section addresses for overlaps (default).

- **–no-check-sections**
    - Do not check section addresses for overlaps.

- **–default-symver**
    - Create default symbol version.

- **–default-imported-symver**
    - Create default symbol version for imported symbols.

- **–demangle [=&lt;STYLE&gt;]**
    - Demangle symbol names using STYLE.

- **–discard-none**
    - Do not discard any local symbols.

- **-dT**
    - Read the default linker script.

- **–dynamic-list-data**
    - Add data symbols to dynamic list

- **–dynamic-list-cpp-new**
    - Use C++ operator new/delete dynamic list

- **–dynamic-list-cpp-typeinfo**
    - Use C++ type information dynamic list.

- **-EB**
    - Link the big-endian objects.

- **-EL**
    - Link the little-endian objects.

- **–embedded-relocs**
    - Generate embedded relocations.

- **-f** *SHLIB* | **–auxiliary** *SHLIB* **Auxiliary** | **-F** *SHLIB* | **–filter** *SHLIB*
    - Filter for the shared object symbol table.

- **–fix-v4bx**
    - Rewrite BX rn as MOV pc, rn for the Armv4 processor.

- **–fix-v4bx-interworking**
    - Rewrite BX rn branch to the Armv4 interworking veneer.

- **-flto-partition=**
    - Ignored for GCC LTO option compatibility.

- **–force-exe-suffix**
    - Force generation of a file with the .exe suffix.

- **–format** *TARGET* | **-b** *TARGET*
    - Specify the target for the input files that follow.

- **-fuse-ld=**
    - Ignored for GCC linker option compatibility.

- **-I PROGRAM**
    - Set PROGRAM as the dynamic linker to use.

- **–ignore-unresolved-symbol** *SYMBOL*
    - Unresolved SYMBOL will not cause an error or warning.

- **–long-plt**
    - Generate long .plt entries to handle large .plt/.got displacements.

- **–mri-script** *FILE* | **-c** *FILE*
    - Read the MRI format linker script.

- **–no-define-common**
    - Do not define common storage.

- **–no-enum-size-warning**
    - Do not warn about objects with incompatible enum sizes.

- **–[no-]fix-arm1176**
    - Disable or enable Arm1176 BLX immediate erratum fix,
armelfb\_linux\_eabi.

- **–no-keep-memory**
    - Use less memory and more disk input/output.

- **–no-merge-exidx-entries**
    - Disable merging exidx entries.

- **–no-print-gc-sections**
    - Do not list removed unused sections.

- **–no-undefined-version**
    - Disallow undefined version.

- **–no-warn-search-mismatch**
    - Do not warn on finding an incompatible library.

- **–no-wchar-size-warning**
    - Do not warn about objects with incompatible wchar\_t sizes.

- **-O**
    - Optimize the output file.

- **–oformat** *TARGET*
    - Specify the target of output file.

- **–pic-veneer**
    - Always generate PIC interworking veneers.

- **-plugin** *PLUGIN*
    - Load the named plug-in.

- **-plugin-opt** *ARG*
    - Send ARG to the last-loaded plug-in.

- **–print-output-format**
    - Print the default output format.

- **–print-sysroot**
    - Print the current sysroot.

- **–push-state**
    - Push the state of flags governing input file handling.

- **–pop-state**
    - Pop the state of flags governing input file handling.

- **-q**
    - Generate relocations in the final output.

- **-qmagic**
    - Ignored for Linux compatibility.

- **–reduce-memory-overheads**
    - Reduce memory overheads, possibly taking much longer.

- **–relax**
    - Reduce code size by using target-specific optimizations.

- **–no-relax**
    - Do not use relaxation techniques to reduce code size.

- **–relocatable** | **-i**
    - Generate the relocatable output.

- **–retain-symbols-file** *FILE*
    - Keep only symbols listed in *FILE*.

- **-rpath** *PATH*
    - Set the runtime shared library search path.

- **-rpath-link** *PATH*
    - Set the link time shared library search path.

- **–sort-common**
    - Sort common symbols by alignment in a specified order.

- **–sort-section**
    - Sort sections by name or maximum alignment.

- **–spare-dynamic-tags** *COUNT*
    - Indicate how many tags to reserve in the .dynamic section.

- **–split-by-file [=&lt;SIZE&gt;]**
    - Split output sections every SIZE octets.

- **–split-by-reloc [=&lt;COUNT&gt;]**
    - Split output sections every COUNT relocations.

- **–stats**
    - Print memory usage statistics.

- **–strip-discarded**
    - Strip symbols in discarded sections.

- **–no-strip-discarded**
    - Do not strip symbols in discarded sections.

- **–stub-group-size=&lt;N&gt;**
    - Maximum size of a group of input sections that can be handled by one
stub section.

- **-Tbss** *ADDRESS*
    - Set the address of the .bss section.

- **-Tdata** *ADDRESS*
    - Set the address of the .data section.

- **-Tldata-segment** *ADDRESS*
    - Set the address of the ldata segment.

- **-Trodata-segment** *ADDRESS*
    - Set the address of the rodata segment.

- **-Ttext** *ADDRESS*
    - Set the address of the .text section.

- **-Ttext-segment** *ADDRESS*
    - Set the address of the .text segment.

- **–target-help**
    - Display target-specific options.

- **–target1-rel**
    - Interpret R\_ARM\_TARGET1 as R\_ARM\_REL32.

- **–target1-abs**
    - Interpret R\_ARM\_TARGET1 as R\_ARM\_ABS32.

- **–target2=&lt;type&gt;**
    - Specify the definition of R\_ARM\_TARGET2.

- **–task-link** *SYMBOL*
    - Do task-level linking.

- **–thumb-entry=&lt;sym&gt;**
    - Set the entry point to be a Thumb symbol &lt;sym&gt;.

- **–trace-symbol** *SYMBOL* | **-y** *SYMBOL*
    - Trace mentions of SYMBOL.

- **–traditional-format**
    - Use the same format as the native linker.

- **–unique [=&lt;SECTION&gt;]**
    - Do not merge input [*SECTION* | *orphan*] sections.

- **–unresolved-symbols=&lt;method&gt;**
    - Indicate how to handle unresolved symbols.

- **-Ur**
    - Build global constructor/destructor tables.

- **–use-blx**
    - Enable the use of BLX instructions.

- **-v**
    - Print the version information.

- **-V**
    - Print the version and emulation information.

- **–version-script** *FILE*
    - Read the version information script.

- **–version-exports-section** *SYMBOL*
    - Take the export symbols list from .exports, using *SYMBOL* as the
version.

- **–vfp11-denorm-fix**
    - Specify how to fix VFP11 denorm erratum.

- **–warn-constructors**
    - Warn if global constructors/destructors are seen.

- **–warn-multiple-gp**
    - Warn if multiple GP values are used.

- **–warn-section-align**
    - Warn if the start of section changes due to alignment.

- **-z interpose**
    - Mark an object to interpose all DSOs but executable.

- **-z loadfltr**
    - Mark an object as requiring immediate processing.

- **-z nodefaultlib**
    - Mark an object to not use default search paths.

- **-z nodlopen**
    - Mark the DSO as not available to dlopen.

- **-z nodump**
    - Mark the DSO not available to dldump.

- **-z stacksize=&lt;SIZE&gt;**
    - Set the size of stack segment.

Last Published: May 10, 2024

[Previous Topic
Link maps](https://docs.qualcomm.com/bundle/publicresource/80-VB419-102/topics/link_maps.md) [Next Topic
References](https://docs.qualcomm.com/bundle/publicresource/80-VB419-102/topics/references.md)