Linker

Description

The linker is responsible to solve the referencement of labels, and eventually append library source codes to the build process.

To disable the automatic inclusion of 'header.s' and 'tail.s', just modify your OSDK_CONFIG.BAT file, and add the following:

	SET OSDKLINK=-B
Switches

The -d defines the location of the library files. It must be followed by a path:

	-d /usr/oric/lib/

The -s defines the location of the sources files. It must be followed by a path:

	-s /sources/oric/demo/

The -o defines the name of the outputed file. It must be followed by the file name. By default the output name will be 'go.s':

	-o final.s

The -l switch prints out defined labels.Usefull when building lib index files.

The -v switch activates the verbose mode.

The -q switch enables the quiet mode.

The -b switch disables the automatic inclusion of 'header.s' and 'tail.s

The -f inserts a #file directives before each linked file.

The -i defines an additional path to search for include files. It must be followed by a path:

	-i /usr/oric/include/

The -r defines the language tag used for conditional character replacement (see #pragma osdk replace_characters_if below). It must be followed by a tag string:

	-r french
Pragma directives

The linker supports special pragma directives embedded in the source files to control its behaviour:

#pragma osdk replace_characters defines a set of search/replace pairs to apply to all filtered output lines. This is used to perform text localization when the assembler source contains characters that need to be mapped differently depending on the target platform. The syntax uses a separator character of your choice, followed by pairs of tokens separated by that character:

	#pragma osdk replace_characters | sourcechar|replacementchar ...

Important limitation: each replace_characters directive unconditionally replaces the previously active replacement table. This means it only works correctly if there is no other replace_characters directive appearing earlier in the linked files that would override it before the texts to localize are reached. For any project targeting more than one language, using replace_characters_if is strongly recommended instead.

#pragma osdk replace_characters_if LANGUAGE_TAG works identically to replace_characters, but only takes effect if the tag passed to the -r command line option matches LANGUAGE_TAG. This allows multiple language-specific replacement tables to coexist in a single source file:

	#pragma osdk replace_characters_if french | e|é a|à
	#pragma osdk replace_characters_if spanish | n|ñ

Only the pragma whose tag matches the -r argument will be applied; the others are silently ignored.



Known issues


No known problem - please signal any issue on the Cross development tools forum.



Resolved issues


Reported by Jede the Mon 13th February 2017
Fixed in OSDK 1.9


Issue #13: Linker failing to include relative files
Details: While working on Telemon, found out that it was impossible to link a module containing #include "../oric-common/include/asm/telemon.h"


Reported by Chema the Tue 12th January 2016
Fixed in OSDK 1.8


Issue #11: Linker does not process include files
Details: If you include files that define labels (ex: the loader data table) the linker will generally ignore them and throw a undefined externals symbols error.


comments powered by Disqus
Coverity Scan Build Status
History
Version 1.2
  • Added support for a '#pragma osdk replace_characters_if LANGUAGE_TAG' directive and a '-r LANGUAGE_TAG' command line option to perform conditional character replacement: only the pragma whose tag matches the -r argument is applied
  • This allows multiple language pragmas to coexist in a single file without the last one overriding all others
Version 1.1
  • Added support for a '#pragma osdk replace_characters' directive used to perform localization of texts (experimental)
Version 1.0
  • Added a '-i' option to provide alternative include file paths
Version 0.68
  • The 'Unresolved external: ' now also specify the filename and line number of the first place where the symbol was requested, as well as the total number of references.
Version 0.67
  • Error messages now indicate that they came from the Linker, because a generic 'Error, can't load xxxx' was not very informative
Version 0.66
  • The new macro file generate lines that contain multiple instructions, the linker stopped at the first encountered instruction, this new version correctly parses that
Version 0.65
  • Fixed some issues in the token pattern matching used to detect labels resulting in #includes containing relative paths to be incorrectly parsed
Version 0.64
  • Fixed the age old problem of includes from assembler sources leading to Unresolved External errors
Version 0.59
  • Corrected a bug that made it impossible to 'link' only one source file
Version 0.58
  • Added filtering of all '#' directives
  • Added an icon to the executable file to make it more 'OSDK' integrated :)
  • Added '-F' option to enable #file directive (requires modified XA assembler)
  • Modified the handling of comments to avoid crashes on C and C++ comments
Version 0.57
  • Added '-B' option to suppress inclusion of HEADER and TAIL
Version 0.56
  • Handling of lines that have more than 180 characters