Using LD, the GNU linker - 4. Machine Dependent Features

Go to the first, previous, next, last section, table of contents.

# 4. Machine Dependent Features

`ld` has additional features on some platforms; the following sections describe them. Machines where `ld` has no additional functionality are not listed.

## 4.1 `ld` and the H8/300

For the H8/300, `ld` can perform these global optimizations when you specify the ``--relax'` command-line option.

relaxing address modes
  `ld` finds all `jsr` and `jmp` instructions whose targets are within eight bits, and turns them into eight-bit program-counter relative `bsr` and `bra` instructions, respectively.
synthesizing instructions
  `ld` finds all `mov.b` instructions which use the sixteen-bit absolute address form, but refer to the top page of memory, and changes them to use the eight-bit address form. (That is: the linker turns ``mov.b `@`aa:16'` into ``mov.b `@`aa:8'` whenever the address aa is in the top page of memory).

## 4.2 `ld` and the Intel 960 family

You can use the ``-Aarchitecture'` command line option to specify one of the two-letter names identifying members of the 960 family; the option specifies the desired output target, and warns of any incompatible instructions in the input files. It also modifies the linker's search strategy for archive libraries, to support the use of libraries specific to each particular architecture, by including in the search loop names suffixed with the string identifying the architecture.

For example, if your `ld` command line included ``-ACA'` as well as ``-ltry'`, the linker would look (in its built-in search paths, and in any paths you specify with ``-L'`) for a library with the names

    try
    libtry.a
    tryca
    libtryca.a

The first two possibilities would be considered in any event; the last two are due to the use of ``-ACA'`.

You can meaningfully use ``-A'` more than once on a command line, since the 960 architecture family allows combination of target architectures; each use will add another pair of name variants to search for when ``-l'` specifies a library.

`ld` supports the ``--relax'` option for the i960 family. If you specify ``--relax'`, `ld` finds all `balx` and `calx` instructions whose targets are within 24 bits, and turns them into 24-bit program-counter relative `bal` and `cal` instructions, respectively. `ld` also turns `cal` instructions into `bal` instructions when it determines that the target subroutine is a leaf routine (that is, the target subroutine does not itself call any subroutines).

## 4.3 `ld`'s support for interworking between ARM and Thumb code

For the ARM, `ld` will generate code stubs to allow functions calls betweem ARM and Thumb code. These stubs only work with code that has been compiled and assembled with the ``-mthumb-interwork'` command line option. If it is necessary to link with old ARM object files or libraries, which have not been compiled with the -mthumb-interwork option then the ``--support-old-code'` command line switch should be given to the linker. This will make it generate larger stub functions which will work with non-interworking aware ARM code. Note, however, the linker does not support generating stubs for function calls to non-interworking aware Thumb code.

Go to the first, previous, next, last section, table of contents.