7.2. c29libinfo - Library Information Archiver

The c29libinfo 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 considers 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 incorporates the matching object file library into the link.

7.2.1. Usage

c29libinfo [<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 is given an entry in the <index_library> that is created or updated.

7.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.

7.2.3. Example

1 Creating object file libraries

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

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_oper.c for compiling with either the -mfpu=none option or the -mfpu=f64 option. Each version contains a definition of a global variable, bit_oper, that is initialized differently depending on the C29x processor option used to compile lib_oper.c.

%> c29clang <build option> -c lib_oper.c
%> c29ar r <object library name> lib_oper.o

results in the following list of libraries:

Target

bit_oper value

<build option>

<object library name>

Emulated 64-bit operations

0

-mfpu=none

c29_nofpu_def.a

Native 64-bit operations

1

-mfpu=f64

c29_fpu64_def.a

2 Creating an index library:

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

%> c29libinfo -o def.a c29_nofpu_def.a c29_fpu64_def.a

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

%> c29ar t def.a c29_nofpu_def.a.libinfo c29_fpu64_def.a.libinfo __TI_$$LIBINFO

3 Using an index library in the link step:

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

%> c29clang -mcpu=c29.c0 -mfpu=f64 print_bit_oper.c -o print_lib.out -Wl,-llnk.cmd,def.a,-mprint_lib.map

At link-time, the linker selects the object file library in def.a that is most compatible with the object file generated by the compiler for print_bit_oper.c. In the above case, the linker should pull in the lib_oper.o file from the c29_fpu64_def.a object file library and the contents of the linker-generated print_lib.map file reveal that this is indeed the case:

******************************************************************************
C29 Clang Linker Unix v1.2.0
******************************************************************************
>> Linked Fri Mar 15 15:06:50 2024

OUTPUT FILE NAME:   <print_lib.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     c29_fpu64_def.a : lib_oper.o (.data.bit_oper)
...

If a different -mfpu option had been specified on the above c29clang command line, then the linker would pull in the lib_oper.o from a different, appropriate, version of the object file library that matches the specified -mfpu option.

7.2.4. Exit Status

If c29libinfo execution is successful, it exits with a zero return code. If an error occurs during execution, c29libinfo exits with a non-zero return code.