Oracle® Solaris 11.2 Linkers and Libraries Guide

Exit Print View

Updated: July 2014

Collapse Multiply-Defined Data

Data can be reduced by collapsing multiply-defined data. A program with multiple occurrences of the same error messages can be better off by defining one global datum, and have all other instances reference this. For example.

const char *Errmsg = "prog: error encountered: %d";

        (void) fprintf(stderr, Errmsg, error);

The main candidates for this sort of data reduction are strings. String usage in a shared object can be investigated using strings(1). The following example generates a sorted list of the data strings within the file Each entry in the list is prefixed with the number of occurrences of the string.

$ strings -10 | sort | uniq -c | sort -rn