Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, July 27, 2022



mcs - manipulate the comment section of an object file


mcs [-cdHpVz] [-a string] [-A file] [-n name] file...


The mcs command is used to display, deduplicate, or append content to comment sections in an ELF object file. It can also be used to delete comment or non-comment sections, and to zero SHT_PROGBITS sections. Unless otherwise specified, the section named .comment is manipulated. mcs cannot modify or delete a section that is contained within a segment.

If the input file is an archive (see ar.h(3HEAD)), the archive is treated as a set of individual files. For example, if the –a option is specified, the string is appended to the comment section of each object file in the archive; if the archive member is not an object file, then it is left unchanged.

mcs must be given one or more of the options described below. It applies each option, in the order given, to each file.

For append operations, if the object does not already contain a section with the specified name, mcs will create a new empty section with that name before performing the append operation.


The following options are supported:

–a string

Appends string to the comment section of the object files.

–A file

Appends the contents of the given file to the comment section of the object files.


Compresses the contents of the comment section of the object files by deduplication. All duplicate entries are removed. The ordering of the remaining entries is not disturbed.


Deletes the specified section from the object files.


When –p is used, suppress the output of the name of the file, as well as any blank lines normally inserted between the output for each file.

–n name

Specifies the name of the section to access if other than .comment. By default, mcs deals with the section named .comment. mcs can take multiple – n options to allow for specification of multiple sections. mcs assumes that any sections it manipulates have the format of a comment section.


Prints the contents of the comment section on the standard output. Unless used with –H, each section printed is prefixed with the name of the file from which it was extracted, using the format file[member_name ]: for archive files and file: for other files.


Print version information.


Replaces any SHT_PROGBITS sections with zeros while retaining the original attributes of the sections.


Print usage message and immediately exit.


Example 1 Printing a file's comment section

The following entry

example% mcs -p elf.file

prints the comment section of the file elf.file.

Example 2 Appending a string to a comment section

The following entry

example% mcs -a  xyz elf.file

appends string xyz to elf.file's comment section.

Example 3 Stripping a specified non-allocable section

Although used primarily with comment sections, mcs can operate on any non-allocable section. In contrast to the strip command, which removes a predefined selection of non-allocable sections, mcs can be used to delete a specific section. The following entry

example% mcs -d -n .annotate elf.file

removes the section named .annotate from the file elf.file.



temporary files


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

Interface Stability

See Also

ar(1), as(1), elfcompress(1), ld(1), strip(1), elf(3ELF), ar.h(3HEAD), a.out(5), attributes(7)


When mcs deletes a section using the –d option, it tries to bind together sections of type SHT_REL and target sections pointed to by the sh_info section header field. If one is to be deleted, mcs attempts to delete the other of the pair.

The –z option removes the contents of SHT_PROGBITS sections while retaining the original ELF structure of the object. The need for use of the –z option is limited. However, the option can be used to deliver an object file when the contents of SHT_PROGBITS sections are not relevant.

The mcs command is unable to modify core files.