Removing Unused Files

An input relocatable object file is determined to be unused if all allocatable sections provided by the relocatable object are unused.

Unused files are diagnosed with the -z guidance option, and can be discarded from the link-edit by using the -z discard-unused=files option.

The -z discard-unused option provides independent control over unused sections and unused files in order to compliment -z guidance processing. Under -z guidance, files that are determined to be unused are identified. Unused files can often easily be removed from a link-edit. However, sections that are determined to be unused are not identified under -z guidance processing. Unused sections can involve much more investigation and effort to remove and can be a consequence of compiler actions that are beyond your control.

By using the -z discard-unused=sections option together with the -z guidance option, unused sections are automatically removed, while unused files are identified for you to remove from the link-edit.