Link
====

See the Desktop Tools manual for documentation.


Changes up to version 5.32
==========================

Initialised static data in modules now works.

Consequently, modules written in C++ now get their global constructors called
(provided you invoke ______main() yourself if you have no main() function)

New option '-linkversion 525' - aborts the link if link isn't at least that
specified as a parameter (5.25 in the example shown).  This can be used to
ensure you have a new enough linker to support the things you are needing it
to do.

New option '-rescan' added to instruct the linker to rescan the libraries to
satisfy unresolved references imported from objects in later libraries.  You
should not use this option as a matter of course - only when you have
co-dependent libraries.

__RelocCode only goes in the executable if it's a module and it explicitly
imports it (so assembler modules can "link -rmf" and not get this function
appended to them unless they actually need it).

Support for ARM SYMDEFS symbol definitions file added.

Experimental support for basic ELF object files.

Support for library files (ALF/AR) to contain a mixture of filetypes - ELF,
AOF, AOUT and SYMDEFS.

Improvements and bug fixes to multi-instruction relocation.

Correction to multi-instruction relocations - wasn't checking that an
LDR/STR following an ADD/SUB was using the same register before relocating
it.

Fixed to not misinterpret "Thumb" and "Uses halfword" AOF attributes as
"Based area" and "Shared library stub data". This removes spurious attribute
conflict warnings, especially when using LDRH/STRH.

Added -nozeroinit flag, to force zeroinit areas to be included in the
output even if you're not using the -bin switch.

Increased maximum area name length to 96 from 64.

Unused area elimination can now be enabled on RISC OS via -unused or
-remove. It's still deactivated by default because it doesn't work with the
Shared C Library stubs.

xrefs are now calculated correctly for ELF input objects (required for
unused area elimination).

Area selection from ELF input objects improved. Non-SHF_ALLOC sections are
now kept during partial ELF link, and discarded otherwise.

Code areas in ELF files now act as though they have the AOF 32-bit code
attribute.


Changes from 5.32 to 5.33
=========================

Increased the limits for file and path names. There used to be a limit of 40
characters for leafnames and 80 characters for pathnames. Now upped to 256
and 1024 respectively.


Changes from 5.33 to 5.34
=========================

Lots of improvements to relocations - now fully supports ARMv7

Added ability to relocate MOV32 directives (MOVW,MOVT pairs) at link time
and (for modules and relocatable AIF) at load time. Load time relocation is
signalled using bit 0 of the offsets in the relocation table.

Tightened up instruction relocation so it doesn't confuse various newer,
mainly unconditional, instructions (BLX, CLREX, barrier and Advanced SIMD
instructions, SWPB, SMULL, SMLAL, UMAAL, MLS, LDREXB/H and STREXB/H) with
similarly-encoded relocatable instructions, and to require that all
instructions within a sequence use the same condition code. Preload
instructions are still permitted, however, even though they use an
unconditional encoding.

SWI instruction relocation was attempted but would always report failure.
Rather than have to support a second type of additive instruction
relocation in the relocation code, and because passing addresses in the SWI
comment field is of limited usefulness, this has been fully withdrawn.
(Note that SWI relocations are also deprecated in the latest ARM ELF
specification.)

PC-relative relocation would fail if the destination was exactly 7 bytes
further into its area than the relocated instruction was into its own area.

B and BL relocations are now range-checked (this used not to matter in
26-bit mode but in 32-bit mode they can only branch +/-32MB).

Relocation of sequences of 3 ADD/SUB instructions was broken.

Relocated ADD and SUB instructions now only use ARM's preferred form of
modified immediate constants.

Calls to OS_SynchroniseCodeAreas were missing from the relocation code for
self-moving relocatable AIF files.

Will now load small symdefs files (specifically, ones that are smaller
than an ELF header).

Fixed NULL pointer dereference when relocating to a symbol obtained from a
symdefs file.


Changes from 5.34 to 5.35
=========================

Warn if a FPREGARGS code symbol is matched to a non-FPREGARGS code symbol
or a data symbol.

Warn if a SOFTFP code symbol is matched to a non-SOFTFP code symbol or a
data symbol.

Warn if linking areas with differing VFP attributes.

Now supports relocation of LDC/STC{2}{L}, LDF/STF, LFM/SFM and VLDR/VSTR.

Set bit 0 of relocations to a Thumb code symbol.


Changes from 5.35 to 5.36
=========================

A new command-line option, -util, enables a new binary output format.
This features a header, with similarities to an AIF header, as required
by some versions of RISC OS Adjust. It also inserts module-style
relocation code if the symbol __RelocCode is referenced (required to
support any C source files that uses code or static data pointers). After
the relocation code, a small footer used to deactivate 26-bit emulation
(if Aemulor is installed) is inserted, provided all object files were
compiled/assembled using APCS32. The read-only and read-write fields in
the header are initialised, with the header itself assigned to the former
and the relocation code and footer (if present) assigned to the latter.
The -zeroinit flag is implicit if -util is used, since the RMA block into
which a utility is loaded will not be large enough for runtime
initialisation of a zero-init area, and there is no space in the header
to specify this size anyway.

If you linked with both -rmf and -nozeroinit, then Image$$RW$$Limit and
Image$$ZI$$Limit resolved to an address in the middle of the relocation
code. Similarly, the less well known automatically-generated symbol _edata
pointed to the middle of the relocation code (rather than the end of the
initialised data areas, as intended) when linking with -rmf *without*
-zeroinit. These problems are now fixed.


Changes from 5.36 to 5.37
=========================

An abort caused when printing a diagnostic message when conflicting FP
calling standards appeared in the AOF area flags were encountered has been
fixed.


Changes from 5.37 to 5.38
=========================

Add support for ARMv8.2 half precision FP variants of VLDR and VSTR.
Bugfix to LDC{2}{L}, STC{2}{L}, LDF, STF, LFM, SFM, VLDR, VSTR: relocation
was only correctly performed if the pre-relocation instruction featured a
negative offset (i.e. the data target was closer to the start of its area
than the instruction was from the start of its area).


Changes from 5.38 to 5.39
=========================

The linker's size calculation for areas with alignments greater than 4 bytes
meant that:
* zero-initialised areas were allocated at a higher address than necessary
* read-write areas were out of step with their initialisers if an earlier
  read-only area had an alignment greater than 4 bytes
The calculation has been corrected for other power-of-two alignments, as
well as the default of 4.
