13.07.2015 Views

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>ARM</strong> <strong>User</strong> <strong>Guide</strong>8.3.2. How the Linker Extracts Objects from LibrariesA library built with the <strong>TASKING</strong> archiver ararm always contains an index part at the beginning of thelibrary. The linker scans this index while searching <strong>for</strong> unresolved externals. However, to keep the indexas small as possible, only the defined symbols of the library members are recorded in this area.When the linker finds a symbol that matches an unresolved external, the corresponding object file isextracted from the library and is processed. After processing the object file, the remaining library indexis searched. If after a complete search of the library unresolved externals are introduced, the library indexwill be scanned again. After all files and libraries are processed, and there are still unresolved externalsand you did not specify the linker option --no-rescan, all libraries are rescanned again. This way you donot have to worry about the library order on the command line and the order of the object files in thelibraries. However, this rescanning does not work <strong>for</strong> 'weak symbols'. If you use a weak symbol construction,like printf, in an object file or your own library, you must position this object/library be<strong>for</strong>e the C library.The option--verbose (-v) shows how libraries have been searched and which objects have been extracted.Resolving symbolsIf you are linking from libraries, only the objects that contain symbols to which you refer, are extractedfrom the library. This implies that if you invoke the linker like:lkarm mylib.libnothing is linked and no output file will be produced, because there are no unresolved symbols when thelinker searches through mylib.lib.It is possible to <strong>for</strong>ce a symbol as external (unresolved symbol) with the option --extern (-e):lkarm --extern=main mylib.libIn this case the linker searches <strong>for</strong> the symbol main in the library and (if found) extracts the object thatcontains main.If this module contains new unresolved symbols, the linker looks again in mylib.lib. This processrepeats until no new unresolved symbols are found.8.4. Incremental LinkingWith the <strong>TASKING</strong> linker it is possible to link incrementally. Incremental linking means that you link some,but not all .obj modules to a relocatable object file .out. In this case the linker does not per<strong>for</strong>m thelocating phase. With the second invocation, you specify both new .obj files as the .out file you hadcreated with the first invocation.Incremental linking is only possible on the command line.lkarm -darm.lsl --incremental test1.obj -otest.outlkarm -darm.lsl test2.obj test.out204

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!