Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Thursday, June 13, 2019
 
 

elffile(1)

Name

elffile - identifyELFfile type

Synopsis

elffile [-s basic | detail | summary] [-V] file...

Description

The elffile utility is a specialized variant of the file command that is intended for use with ELF objects and related file types. elffile can identify files of the following types:

Archives

In addition to the information provided by file, elffile identifies the types of the archive members.

ELF Objects / Runtime Linker Configuration files

elffile provides the same output as file

Files of any other type are reported as non-ELF. No attempt to further classify such files is made. The file utility is recommended for general purpose file identification.

Options

The following options are supported:

–s basic | detail | summary

Specify the style of output to be provided

basic

Produce a one-line description in the same format used by file.

detail

For non-archives, summary output is the same as basic. When processing archives, the basic output line is followed by one line of output for each archive member.

summary

For non-archives, summary output is the same as basic. When processing archives, a summary description of the archive contents is added to the end of the basic output. If the –s option is not specified, elffile uses the summary style by default.

–V
–-version

Print version information and immediately exit.

–?
–-help

Print usage message and immediately exit.

Notes

The output produced for archives when using the summary style depends on the contents of the archive. If the archive contains a homogeneous collection of objects for the same platform, the platform details are shown in the same format used for a single object. Otherwise, a summary description is produced. The detail style can be used to obtain more specific information about individual archive members.

The summary and detail styles require examination of every member of an archive. Speed of execution is proportional to the number of archive members, and can be slow for extremely large archives.

Examples

Example 1 Displaying Summary Output for Archives

The following example displays the summary output from elffile for archives with differing content. The following archives are used.

same_elf.a

ELF objects for a single platform.

mixed_elf.a

ELF objects for more than one platform.

mixed.a

ELF objects and non-ELF files.

not_elf.a

Non-ELF files.

The summary output for archives depends on the types of the archive members.

example% elffile same_elf.a mixed_elf.a mixed.a not_elf.a
same_elf.a: current ar archive, 32-bit symbol table, \
    ELF 64-bit LSB relocatable AMD64 Version 1
mixed_elf.a: current ar archive, 32-bit symbol table, \
    mixed ELF content
mixed.a: current ar archive, 32-bit symbol table, \
    mixed ELF and non-ELF content
not_elf.a: current ar archive, non-ELF content
Example 2 Filtering Detailed Output for Archives

The detailed output from elffile produces one line of output for the archive, followed by one line of output per archive member. This output can be easily filtered in order to present the information in various forms. The following example demonstrates this using the archive, libCstd.a which contains relocatable objects for a 64–bit x86 system. The unfiltered detailed elffile output for this archive is as follows.

example% elffile -s detail libCstd.a
libCstd.a: current ar archive, 32-bit symbol table
libCstd.a(bitset.o): ELF 64-bit LSB relocatable \
    AMD64 Version 1 [CMOV]
libCstd.a(complex.o): ELF 64-bit LSB relocatable \
    AMD64 Version 1 [SSE2 SSE CMOV FPU]
libCstd.a(limits.o): ELF 64-bit LSB relocatable \
    AMD64 Version 1 [SSE2 SSE FPU]
libCstd.a(limitsinit.o): ELF 64-bit LSB relocatable \
    AMD64 Version 1
libCstd.a(stdexcept.o): ELF 64-bit LSB relocatable \
    AMD64 Version 1 [SSE CMOV]
...

This output shows that each object is tagged with the hardware capabilities it requires to run. These capability tags vary depending on the code found in each object. The following command filters the output from elffile to identify each unique capability mask, and to count the number of objects containing each mask within the archive. The sed command is used to remove the archive member name from the output, with the result that the output for every archive member with the same capability mask will be identical. The sort command is used to group these identical lines together, and the uniq command is used to replace each unique group with a single line from the group, preceded with a count of how many times that line occurred within the group.

example% elffile -s detail libCstd.a | sed 's,(.*),,' | \
    sort -f | uniq -c
   1 libCstd.a: current ar archive, 32-bit symbol table
 777 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1
   1 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [CMOV FPU]
 126 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [CMOV]
  12 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [FPU]
  69 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [SSE CMOV]
   2 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [SSE2 CMOV]
   3 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [SSE2 SSE CMOV FPU]
   3 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [SSE2 SSE CMOV]
   1 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [SSE2 SSE FPU]
   2 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [SSE2 SSE]
  20 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [SSE2]
   4 libCstd.a: ELF 64-bit LSB relocatable \
         AMD64 Version 1 [SSE]

Exit Status

The following exit values are returned:

0

Successful completion

>0

An error occurred

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/linker
Interface Stability
Committed

See Also

ar(1), dump(1), elfdump(1), file(1)

Oracle Solaris 11.4 Linkers and Libraries Guide