9.2. tiarmlibinfo - Library Information Archiver

The tiarmlibinfo command allows you to collect multiple versions of the same object file library, each version built with a different set of command-line options, into a single index library file. This index library file can then be used at link-time as a proxy for the actual object file library. The linker will consider the build options used to create the input object files to a link and find the matching object file library from among those included in the index library. If successful, the linker will incorporate the matching object file library into the link.

9.2.1. Usage

tiarmlibinfo [<options>] -o = <index_library> <archive1>[, <archive2>, …]

  • <options> - can be used to modify the default behavior.

  • -o= <index_library> - identify the index library file to be created or updated

  • <archiveN> - identify a list of one or more object file libraries, each of which will be given an entry in the <index_library> that is created or updated.

9.2.2. Options

-h, --help

Print usage information summary to stdout.

-o=<index_library>, --output=<index_library>

Identify the <index_library> file to be created or updated.

-u, --update

Update existing information in the specified <index_library> file. This option can be used to replace an existing object file library entry in the index_library> instead of adding what may be a duplicate.

9.2.3. Example

As an exploration of how to build up an index library from scratch, consider a simple example where there is a different version of the source file lib_mem.c for each of the Arm processor variants that are supported by tiarmclang. Each version contains a definition of a global variable, mem_global, that is initialized differently depending on the Arm processor option used to compile mem_lib.c.

  • Creating object file libraries

    Compiling each version of lib_mem.c and creating an object file library for each containing a single member, lib_mem.o:

    %> tiarmclang <build option> -c lib_mem.c
    %> tiarmar r <object library name> lib_mem.o
    

    results in the following list of libraries:

    Target

    mem_global value

    <build option>

    <object library name>

    cortex-m0

    10

    -mcpu=cortex-m0

    cortexm0_def.a

    cortex-m3

    20

    -mcpu=cortex-m3

    cortexm3_def.a

    cortex-m4

    30

    -mcpu=cortex-m4

    cortexm4_def.a

    cortex-m33

    40

    -mcpu=cortex-m33

    cortexm33_def.a

    cortex-r4

    50

    -mcpu=cortex-r4

    cortexr4_def.a

    cortex-r5

    60

    -mcpu=cortex-r5

    cortexr5_def.a

  • Creating an index library:

    An index library called def.a can then be constructed with the following command:

%> tiarmlibinfo -o def.a cortexm0_def.a cortexm3_def.a cortexm4_def.a \
   cortexm33_def.a cortexr4_def.a cortexr5_def.a

The contents of the def.a index library can then be checked via the following tiarmar command:

%> tiarmar t def.acortexm0_def.a.libinfo
cortexm3_def.a.libinfo
cortexm4_def.a.libinfo
cortexm33_def.a.libinfo
cortexr4_def.a.libinfo
cortexr5_def.a.libinfo
__TI_$$LIBINFO
  • Using an index library in the link step:

    A source file, print_lib_mem_global.c, containing a reference to the global variable mem_global can then be linked with the index library def.a.

%> tiarmclang -mcpu=cortex-m4 print_lib_mem_global.c -o print_mem.out -Wl,-llnk.cmd,def.a,-mprint_mem.map

At link-time, the linker will select the object file library in def.a that is most compatible with the object file generated by the compiler for print_lib_mem_global.c. In the above case, the linker should pull in the lib_mem.o file from the cortexm4_def.a object file library and the contents of the linker-generated print_mem.map file reveal that this is indeed the case:

******************************************************************************
TI ARM Clang Linker Unix v1.2.0
******************************************************************************
>> Linked Fri Jan 15 15:06:50 2021

OUTPUT FILE NAME:   <print_mem.out>
ENTRY POINT SYMBOL: "_c_int00"  address: 00000e89

...

SECTION ALLOCATION MAP

 output                                  attributes/
section   page    origin      length       input sections
--------  ----  ----------  ----------   ----------------
...
.data      0    2000a020    000001d1     UNINITIALIZED
                  2000a1ec    00000004     cortexm4_def.a : lib_mem.o (.data.mem_global)
...

If a different -mcpu option had been specified on the above tiarmclang command line, then the linker would have pulled in the lib_mem.o from a different, appropriate, version of the object file library that matches the specified mcpu option.

9.2.4. Exit Status

If tiarmar execution is successful, it will exit with a zero return code. If an error occurs during execution, tiarmar will exit with a non-zero return code.