Identifying a Platform and Machine Capability

The platform or machine capability of an object identifies the platform name or machine hardware name of the systems that the object, or specific symbols within the object, can execute upon. Multiple platform or machine capabilities can be defined. These identifications are very specific, and take precedence over any other capability types. These identifications can be used by specialized system libraries, however hardware capabilities typically provide a more flexible means of creating capabilities instances.

The platform name of a system can be displayed by the utility uname(1) with the -i option. A platform capability requirement can be defined using the following mapfile syntax.

    $mapfile_version 2
        CAPABILITY {
                PLATFORM  = platform_name...;
                PLATFORM += platform_name...;
                PLATFORM -= platform_name...;
        };

The machine hardware name of a system can be displayed by the utility uname(1) with the -m option. A machine capability requirement can be defined using the following mapfile syntax.

    $mapfile_version 2
        CAPABILITY {
                MACHINE  = machine_name...;
                MACHINE += machine_name...;
                MACHINE -= machine_name...;
        };

A PLATFORM or MACHINE attribute is qualified with one or more, space separated platform or machine names. The "+=" form of assignment augments the platform or machine capabilities specified by the input objects, while the "=" form overrides them. The "-=" form of assignment is used to exclude platform or machine capabilities from the output object.

The following SPARC example identifies the object foo.so.1 as being specific to the sun4v machine hardware name.

$ cat mapfile
$mapfile_version 2
CAPABILITY {
        MACHINE = sun4v;
};
$ cc -o foo.so.1 -G -K pic -Mmapfile foo.c -lc
$ elfdump -H foo.so.1

Capabilities Section:  .SUNW_cap

 Object Capabilities:
     index  tag               value
       [0]  CA_SUNW_MACH      sun4v

Relocatable objects can define platform and machine capabilities. These capabilities are gathered together to define the final capability requirements of the object being built.

The platform or machine capability of an object can be controlled explicitly from a mapfile by using the "=" form of assignment to override any platform or machine capabilities that might be provided from any input relocatable objects. An empty PLATFORM or MACHINE attribute used with the "=" form of assignment effectively removes any platform or machine capabilities requirement from the object being built.

A platform or machine capability requirement defined in a dynamic object is validated by the runtime linker against the platform and machine name of the system. The object is only used if one of the platform or machine names recorded in the object match the platform or machine name of the system.