MAN page from RedHat EL 6 toolchain-armiwmmx-2012-2012.12.1-oselas.2.2.x86_64.rpm


Section: GNU Development Tools (1)
Updated: 2017-09-21


ar - create, modify, and extract from archives 


ar [--plugin name] [-X32_64] [-]p[mod [relpos] [count]] archive [member...] 


The GNU ar program creates, modifies, and extracts fromarchives. An archive is a single file holding a collection ofother files in a structure that makes it possible to retrievethe original individual files (called members of the archive).

The original files' contents, mode (permissions), timestamp, owner, andgroup are preserved in the archive, and can be restored onextraction.

GNU ar can maintain archives whose members have names of anylength; however, depending on how ar is configured on yoursystem, a limit on member-name length may be imposed for compatibilitywith archive formats maintained with other tools. If it exists, thelimit is often 15 characters (typical of formats related to a.out) or 16characters (typical of formats related to coff).

ar is considered a binary utility because archives of this sortare most often used as libraries holding commonly neededsubroutines.

ar creates an index to the symbols defined in relocatableobject modules in the archive when you specify the modifier s.Once created, this index is updated in the archive whenever armakes a change to its contents (save for the q update operation).An archive with such an index speeds up linking to the library, andallows routines in the library to call each other without regard totheir placement in the archive.

You may use nm -s or nm --print-armap to list this indextable. If an archive lacks the table, another form of ar calledranlib can be used to add just the table.

GNU ar can optionally create a thin archive,which contains a symbol index and references to the original copiesof the member files of the archives. Such an archive is usefulfor building libraries for use within a local build, where therelocatable objects are expected to remain available, and copying thecontents of each object would only waste time and space. Thin archivesare also flattened, so that adding one or more archives to athin archive will add the elements of the nested archive individually.The paths to the elements of the archive are stored relative to thearchive itself.

GNU ar is designed to be compatible with two differentfacilities. You can control its activity using command-line options,like the different varieties of ar on Unix systems; or, if youspecify the single command-line option -M, you can control itwith a script supplied via standard input, like the MRI ``librarian''program. 


GNU ar allows you to mix the operation code p and modifierflags mod in any order, within the first command-line argument.

If you wish, you may begin the first command-line argument with adash.

The p keyletter specifies what operation to execute; it may beany of the following, but you must specify only one of them:

Delete modules from the archive. Specify the names of modules tobe deleted as member...; the archive is untouched if youspecify no files to delete.

If you specify the v modifier, ar lists each moduleas it is deleted.

Use this operation to move members in an archive.

The ordering of members in an archive can make a difference in howprograms are linked using the library, if a symbol is defined in morethan one member.

If no modifiers are used with "m", any members you name in themember arguments are moved to the end of the archive;you can use the a, b, or i modifiers to move them to aspecified place instead.

Print the specified members of the archive, to the standardoutput file. If the v modifier is specified, show the membername before copying its contents to standard output.

If you specify no member arguments, all the files in the archive areprinted.

Quick append; Historically, add the files member... to the end ofarchive, without checking for replacement.

The modifiers a, b, and i do not affect thisoperation; new members are always placed at the end of the archive.

The modifier v makes ar list each file as it is appended.

Since the point of this operation is speed, the archive's symbol tableindex is not updated, even if it already existed; you can use ar s orranlib explicitly to update the symbol table index.

However, too many different systems assume quick append rebuilds theindex, so GNU ar implements q as a synonym for r.

Insert the files member... into archive (withreplacement). This operation differs from q in that anypreviously existing members are deleted if their names match those beingadded.

If one of the files named in member... does not exist, ardisplays an error message, and leaves undisturbed any existing membersof the archive matching that name.

By default, new members are added at the end of the file; but you mayuse one of the modifiers a, b, or i to requestplacement relative to some existing member.

The modifier v used with this operation elicits a line ofoutput for each file inserted, along with one of the letters a orr to indicate whether the file was appended (no old memberdeleted) or replaced.

Add an index to the archive, or update it if it already exists. Notethis command is an exception to the rule that there can only be onecommand letter, as it is possible to use it as either a command or amodifier. In either case it does the same thing.
Display a table listing the contents of archive, or thoseof the files listed in member... that are present in thearchive. Normally only the member name is shown; if you also want tosee the modes (permissions), timestamp, owner, group, and size, you canrequest that by also specifying the v modifier.

If you do not specify a member, all files in the archiveare listed.

If there is more than one file with the same name (say, fie) inan archive (say b.a), ar t b.a fie lists only thefirst instance; to see them all, you must ask for a completelisting---in our example, ar t b.a.

Extract members (named member) from the archive. You canuse the v modifier with this operation, to request thatar list each name as it extracts it.

If you do not specify a member, all files in the archiveare extracted.

Files cannot be extracted from a thin archive.

A number of modifiers (mod) may immediately follow the pkeyletter, to specify variations on an operation's behavior:

Add new files after an existing member of thearchive. If you use the modifier a, the name of an existing archivemember must be present as the relpos argument, before thearchive specification.
Add new files before an existing member of thearchive. If you use the modifier b, the name of an existing archivemember must be present as the relpos argument, before thearchive specification. (same as i).
Create the archive. The specified archive is alwayscreated if it did not exist, when you request an update. But a warning isissued unless you specify in advance that you expect to create it, byusing this modifier.
Operate in deterministic mode. When adding files and the archiveindex use zero for UIDs, GIDs, timestamps, and use consistent file modesfor all files. When this option is used, if ar is used withidentical options and identical input files, multiple runs will createidentical output files regardless of the input files' owners, groups,file modes, or modification times.
Truncate names in the archive. GNU ar will normally permit filenames of any length. This will cause it to create archives which arenot compatible with the native ar program on some systems. Ifthis is a concern, the f modifier may be used to truncate filenames when putting them in the archive.
Insert new files before an existing member of thearchive. If you use the modifier i, the name of an existing archivemember must be present as the relpos argument, before thearchive specification. (same as b).
This modifier is accepted but not used.
Uses the count parameter. This is used if there are multipleentries in the archive with the same name. Extract or delete instancecount of the given name from the archive.
Preserve the original dates of members when extracting them. Ifyou do not specify this modifier, files extracted from the archiveare stamped with the time of extraction.
Use the full path name when matching names in the archive. GNUar can not create an archive with a full path name (such archivesare not POSIX complaint), but other archive creators can. This optionwill cause GNU ar to match file names using a complete pathname, which can be convenient when extracting a single file from anarchive created by another tool.
Write an object-file index into the archive, or update an existing one,even if no other change is made to the archive. You may use this modifierflag either with any operation, or alone. Running ar s on anarchive is equivalent to running ranlib on it.
Do not generate an archive symbol table. This can speed up building alarge library in several steps. The resulting archive can not be usedwith the linker. In order to build a symbol table, you must omit theS modifier on the last execution of ar, or you must runranlib on the archive.
Make the specified archive a thin archive. If it alreadyexists and is a regular archive, the existing members must be presentin the same directory as archive.
Normally, ar r... inserts all fileslisted into the archive. If you would like to insert only thoseof the files you list that are newer than existing members of the samenames, use this modifier. The u modifier is allowed only for theoperation r (replace). In particular, the combination qu isnot allowed, since checking the timestamps would lose any speedadvantage from the operation q.
This modifier requests the verbose version of an operation. Manyoperations display additional information, such as filenames processed,when the modifier v is appended.
This modifier shows the version number of ar.

ar ignores an initial option spelt -X32_64, forcompatibility with AIX. The behaviour produced by this option is thedefault for GNU ar. ar does not support any of the other-X options; in particular, it does not support -X32which is the default for AIX ar.

The optional command line switch --plugin name causesar to load the plugin called name which adds supportfor more file formats. This option is only available if the toolchainhas been built with plugin support enabled.

Read command-line options from file. The options read areinserted in place of the original @file option. If filedoes not exist, or cannot be read, then the option will be treatedliterally, and not removed.

Options in file are separated by whitespace. A whitespacecharacter may be included in an option by surrounding the entireoption in either single or double quotes. Any character (including abackslash) may be included by prefixing the character to be includedwith a backslash. The file may itself contain additional@file options; any such options will be processed recursively.



nm(1), ranlib(1), and the Info entries for binutils. 


Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.3or any later version published by the Free Software Foundation;with no Invariant Sections, with no Front-Cover Texts, and with noBack-Cover Texts. A copy of the license is included in thesection entitled ``GNU Free Documentation License''.




This document was created byman2html,using the manual pages.