Show me your files, lib!

Getting to the details is my natural engineering passion, see memory is everything. The same applies for building my embedded application: you should know what you pack into your binary file.

One aspect of this are the libraries. The linker does the heavy lifting, but still I want to know the details, right? In CodeWarrior for MCU, things are a little bit different for the 8/16bit tools (HCS08 and RS08) compared to Kinetis, ColdFire, DSC and Qorivva: the format for the libraries is not the archive (*.a) format. Therefore, I cannot use the usual command line tools like readelf, objdump or elfdump available in the GNU Binutils to inspect the libraries. The good news is: there are other good ways to get the information I need :-).

The first thing I look at is at the .map file produced by the linker. Of interest is the FILE SECTION of the map file:

File section in linker map file

File section in linker map file

Here I can see that several files are used from the ANSI library: ansiis.lib. If you want to know the mapping of the library file names to the memory models, then I can consult the following readme files:

  • <installation>\MCU\lib\hc08c\readme.txt
  • <installation>\MCU\lib\rs08c\readme.txt

The map file is already very useful. But eclipse gives me a nice tool too: the Executables View:

Executables view in CodeWarrior

Executables view in CodeWarrior

This shows me all the files used in my linked binary executable file, together with the path information. Notice that it lists as well header files: this is the same information used by the debugger.

Looking closely at the Executables View, I notice that there is a toolbar icon to configure the view for additional columns:

Executable View Columns Toolbar Icon

Executable View Columns Toolbar Icon

Enabling all options, it shows me now more information, including the file size and the modification date:

Executables View with additional attributes

Executables View with additional attributes

But: it shows me only the files referenced and used in my application. Unused variables and functions of the library are not listed as they were removed by the linker. So I need to dig a little bit deeper to find out what is in the library.

The Executable View shows me that the library is located in \MCU\lib\hc08c\lib inside my CodeWarrior installation. In that folder I can find the corresponding listing file which reveals further details about the library:

Library Listing File

Library Listing File

Now I see the complete list of files together and the functions and variables inside the library.

But what if the library you are using does not come with such a listing file? The answer is: I can decode that library!

There is a decoder utility delivered with CodeWarrior inside the installation MCU\prog directory. On Windows it comes with a graphical user interface.Launch it and then simply drag & drop the library to decode it:

Decoder Utility User Interface

Decoder Utility User Interface (Windows)

That way I get a full listing of the library with files, functions and variable information, including the disassembly of the code.

If this is a too much information, I know another way. The trick is to use the Libmaker in the <installation>\MCU\prog folder: this is the librarian used to build the libraries.

Libmaker in CodeWarrior for MCU

Libmaker in CodeWarrior for MCU

It has a command line interface, and if I want to get a listing of the library MyLib, I can use following command:
-cmd(MyLib.lib = MyLib2.lib)
This produces a complete list with files, functions and variables of that library.

Happy listing 🙂

What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.