IBM Support

How can I save an export list of symbols in my object file and limit the bloat that the -qkeepinlines option can cause?

Troubleshooting


Problem

When I use the -qexpfile option to save an export list of symbols in a designated shared object file, some of my existing programs fail to load with the new shared object.

Symptom

Some of my existing programs fail to load with my new shared object.

Cause

Currently, the compiler inlines some library functions at all call sites and discards their definitions. This means that some symbols are not in the new shared object. Some of these symbols disappear at -O3, or higher, optimization level; others are missing even when no optimization is specified.

Resolving The Problem

Download and apply the latest PTF for IBM XL C/C++ Enterprise Edition for AIX, V9.0, or IBM XL C/C++ for AIX, V10.1. This PTF has the new -qkeepinlines=exports option that can be used to avoid this problem.

Specify the symbols to export as follows:

xlC -qkeepinlines=exports -bE:<filename> [-bE:<filename> ...] <source>

OR

xlC -qkeepinlines=exports -bexport:<filename> [-bexport:<filename> ...] <source>

filename is the name of the file that contains the export list. The export list is made up of mangled names. The specified file must follow the syntax expected by the linkage editor, i.e. the ld command. If there is no export file or it is empty, definitions of unreferenced external inline functions are discarded. This is equivalent to specifying -qnokeepinlines.

Example:

When I rebuild my shared object with the new compiler, I need my shared object to export at least the symbols that were exported when it was built with the previous version, but some symbols, like __mine2_symbol, are missing.

1. Using the old compiler, add the -qexpfile option to the shared object link command.
For example:
  xlC -qmkshrobj -o liballmine.so mine1.o mine2.o mine3.o -qexpfile=old_liballmine.exp

2. Use the export file created when you build all objects that are part of the library with the new compiler.
For example:

  xlC -c mine1.C -o mine1.o -qkeepinlines=exports -bexport:old_liballmine.exp
  xlC -c mine2.C -o mine2.o -qkeepinlines=exports -bexport:old_liballmine.exp
  xlC -c mine3.C -o mine3.o -qkeepinlines=exports -bexport:old_liballmine.exp

3. Use the dump command to verify that __mine2_symbol has been kept in mine2.o.
For example:

 dump -tv mine2.o | grep __mine2_symbol

4. Use an export list on your new link line to specify any new symbols generated by new code added to the library to provide a cleaner interface to the library and reduce the need for this feature in the future.

(If no export lists are provided, the compiler will automatically export all global symbols, including some that future compilers may not deem necessary, and some that may no longer be possible to generate as a side-effect of library source code changes.)

For example:

xlC -qmkshrobj -o liballmine.so mine1.o mine2.o mine3.o
    -bE:old_liballmine.exp  -bE:new_code.exp

[{"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Component":"Compiler","Platform":[{"code":"PF002","label":"AIX"}],"Version":"9.0;10.1","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
08 August 2018

UID

swg21318649