Bi Nut Ils
Transcript of Bi Nut Ils
-
8/6/2019 Bi Nut Ils
1/84
The gnu Binary Utilities
(Sourcery G++ 2010.09-43)Version 2.20.51
October 2010
Roland H. PeschJefrey M. OsierCygnus Support
-
8/6/2019 Bi Nut Ils
2/84
Cygnus SupportTexino 2009-03-28.05
Copyright c 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Sotware Foundation, Inc.
Permission is granted to copy, distribute and/or modiy this document under the terms othe GNU Free Documentation License, Version 1.3 or any later version published by theFree Sotware Foundation; with no Invariant Sections, with no Front-Cover Texts, and withno Back-Cover Texts. A copy o the license is included in the section entitled GNU FreeDocumentation License.
-
8/6/2019 Bi Nut Ils
3/84
i
Table o Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1 ar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 Controlling ar on the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Controlling ar with a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 ld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 nm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 objcopy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
5 objdump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6 ranlib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7 size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
8 strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
9 strip. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
39
10 c++lt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
11 addr2line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
12 nlmconv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
13 windmc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
14 windres. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
15 dlltool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
15.1 The ormat o the dlltool .def le . . . . . . . . . . . . . . . . . . . . . . . . 59
16 readel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
-
8/6/2019 Bi Nut Ils
4/84
ii
17 eledit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
18 Common Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
19 Selecting the Target System . . . . . . . . . . . . . . . . . 66
19.1 Target Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6619.2 Architecture Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
20 Reporting Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
20.1 Have You Found a Bug? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6820.2 How to Report Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Appendix A GNU Free Documentation License. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Binutils Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
79
-
8/6/2019 Bi Nut Ils
5/84
Introduction 1
Introduction
This brie manual contains documentation or the gnu binary utilities (Sourcery G++2010.09-43) version 2.20.51:
ar Create, modiy, and extract rom archives
nm List symbols rom object les
objcopy Copy and translate object les
objdump Display inormation rom object les
ranlib Generate index to archive contents
readelf Display the contents o ELF ormat les.
size List le section sizes and total size
strings List printable strings rom les
strip Discard symbols
elfedit Update the ELF header o ELF les.
c++filt Demangle encoded C++ symbols (on MS-DOS, this program is named cxxfilt)
addr2line
Convert addresses into le names and line numbers
nlmconv Convert object code into a Netware Loadable Module
windres Manipulate Windows resources
windmc Genertor or Windows message resources
dlltool Create the les needed to build and use Dynamic Link Libraries
This document is distributed under the terms o the GNU Free Documentation Licenseversion 1.3. A copy o the license is included in the section entitled GNU Free Documen-tation License.
-
8/6/2019 Bi Nut Ils
6/84
Chapter 1: ar 2
1 ar
ar [--plugin name ] [-]p [mod [relpos ] [count ]] archive [member...]ar -M [
-
8/6/2019 Bi Nut Ils
7/84
Chapter 1: ar 3
1.1 Controlling ar on the Command Line
ar [--plugin name ] [-X32_64] [-]p [mod [relpos ] [count ]] archive [member...]
When you use ar in the Unix style, ar insists on at least two arguments to execute: one
keyletter speciying the operation (optionally accompanied by other keyletters speciyingmodifers ), and the archive name to act on.
Most operations can also accept urther member arguments, speciying particular lesto operate on.
gnu ar allows you to mix the operation code p and modier ags mod in any order,within the rst command-line argument.
I you wish, you may begin the rst command-line argument with a dash.
The p keyletter species what operation to execute; it may be any o the ollowing, butyou must speciy only one o them:
d Delete modules rom the archive. Speciy the names o modules to be deleted
as member. . .; the archive is untouched i you speciy no les to delete.I you speciy the v modier, ar lists each module as it is deleted.
m Use this operation to move members in an archive.
The ordering o members in an archive can make a diference in how programsare linked using the library, i a symbol is dened in more than one member.
I no modiers are used with m, any members you name in the member ar-guments are moved to the end o the archive; you can use the a, b, or imodiers to move them to a specied place instead.
p Print the specied members o the archive, to the standard output le. I thev modier is specied, show the member name beore copying its contents to
standard output.I you speciy no member arguments, all the les in the archive are printed.
q Quick append; Historically, add the les member. . . to the end o archive,without checking or replacement.
The modiers a, b, and i do not afect this operation; new members arealways placed at the end o the archive.
The modier v makes ar list each le as it is appended.
Since the point o this operation is speed, the archives symbol table index isnot updated, even i it already existed; you can use ar s or ranlib explicitlyto update the symbol table index.
However, too many diferent systems assume quick append rebuilds the index,so gnu ar implements q as a synonym or r.
r Insert the les member. . . into archive (with replacement). This operationdifers rom q in that any previously existing members are deleted i theirnames match those being added.
I one o the les named in member. . . does not exist, ar displays an errormessage, and leaves undisturbed any existing members o the archive matchingthat name.
-
8/6/2019 Bi Nut Ils
8/84
Chapter 1: ar 4
By deault, new members are added at the end o the le; but you may use oneo the modiers a, b, or i to request placement relative to some existingmember.
The modier v used with this operation elicits a line o output or each leinserted, along with one o the letters a or r to indicate whether the le wasappended (no old member deleted) or replaced.
t Display a table listing the contents o archive, or those o the les listed inmember. . . that are present in the archive. Normally only the member nameis shown; i you also want to see the modes (permissions), timestamp, owner,group, and size, you can request that by also speciying the v modier.
I you do not speciy a member, all les in the archive are listed.
I there is more than one le with the same name (say, fie) in an archive (sayb.a), ar t b.a fie lists only the rst instance; to see them all, you must askor a complete listingin our example, ar t b.a.
x Extract members (named member) rom the archive. You can use the v mod-ier with this operation, to request that ar list each name as it extracts it.
I you do not speciy a member, all les in the archive are extracted.
Files cannot be extracted rom a thin archive.
A number o modiers (mod) may immediately ollow the p keyletter, to speciy varia-tions on an operations behavior:
a Add new les ater an existing member o the archive. I you use the modiera, the name o an existing archive member must be present as the relposargument, beore the archive specication.
b Add new les beore an existing member o the archive. I you use the modier
b, the name o an existing archive member must be present as the relposargument, beore the archive specication. (same as i).
c Create the archive. The specied archive is always created i it did not exist,when you request an update. But a warning is issued unless you speciy inadvance that you expect to create it, by using this modier.
D Operate in deterministic mode. When adding les and the archive index usezero or UIDs, GIDs, timestamps, and use consistent le modes or all les.When this option is used, iar is used with identical options and identical inputles, multiple runs will create identical output les regardless o the input lesowners, groups, le modes, or modication times.
f Truncate names in the archive.gnu
ar will normally permit le names o anylength. This will cause it to create archives which are not compatible with thenative ar program on some systems. I this is a concern, the f modier maybe used to truncate le names when putting them in the archive.
i Insert new les beore an existing member o the archive. I you use the modieri, the name o an existing archive member must be present as the relposargument, beore the archive specication. (same as b).
l This modier is accepted but not used.
-
8/6/2019 Bi Nut Ils
9/84
Chapter 1: ar 5
N Uses the count parameter. This is used i there are multiple entries in thearchive with the same name. Extract or delete instance count o the givenname rom the archive.
o Preserve the original dates o members when extracting them. I you do notspeciy this modier, les extracted rom the archive are stamped with the timeo extraction.
P Use the ull path name when matching names in the archive. gnu ar cannot create an archive with a ull path name (such archives are not POSIXcomplaint), but other archive creators can. This option will cause gnu ar tomatch le names using a complete path name, which can be convenient whenextracting a single le rom an archive created by another tool.
s Write an object-le index into the archive, or update an existing one, even i noother change is made to the archive. You may use this modier ag either withany operation, or alone. Running ar s on an archive is equivalent to running
ranlib on it.
S Do not generate an archive symbol table. This can speed up building a largelibrary in several steps. The resulting archive can not be used with the linker.In order to build a symbol table, you must omit the S modier on the lastexecution o ar, or you must run ranlib on the archive.
T Make the specied archive a thin archive. I it already exists and is a regulararchive, the existing members must be present in the same directory as archive.
u Normally, ar r. . . inserts all les listed into the archive. I you would liketo insert only those o the les you list that are newer than existing memberso the same names, use this modier. The u modier is allowed only or the
operation r (replace). In particular, the combination qu is not allowed, sincechecking the timestamps would lose any speed advantage rom the operationq.
v This modier requests the verbose version o an operation. Many operationsdisplay additional inormation, such as lenames processed, when the modierv is appended.
V This modier shows the version number oar.
ar ignores an initial option spelt -X32_64, or compatibility with AIX. The behaviourproduced by this option is the deault or gnu ar. ar does not support any o the other-X options; in particular, it does not support -X32 which is the deault or AIX ar.
The optional command line switch --plugin name causes ar to load the plugin calledname which adds support or more le ormats. This option is only available i the toolchainhas been built with plugin support enabled.
1.2 Controlling ar with a Script
a r - M [
-
8/6/2019 Bi Nut Ils
10/84
Chapter 1: ar 6
input is coming directly rom a terminal. During interactive use, ar prompts or input (theprompt is AR >), and continues executing even ater errors. I you redirect standard inputto a script le, no prompts are issued, and ar abandons execution (with a nonzero exitcode) on any error.
The ar command language is not designed to be equivalent to the command-line options;in act, it provides somewhat less control over archives. The only purpose o the commandlanguage is to ease the transition to gnu ar or developers who already have scripts writtenor the MRI librarian program.
The syntax or the ar command language is straightorward:
commands are recognized in upper or lower case; or example, LIST is the same aslist. In the ollowing descriptions, commands are shown in upper case or clarity.
a single command may appear on each line; it is the rst word on the line.
empty lines are allowed, and have no efect.
comments are allowed; text ater either o the characters * or ; is ignored.
Whenever you use a list o names as part o the argument to an ar command, you canseparate the individual names with either commas or blanks. Commas are shown inthe explanations below, or clarity.
+ is used as a line continuation character; i + appears at the end o a line, the texton the ollowing line is considered part o the current command.
Here are the commands you can use in ar scripts, or when using ar interactively. Threeo them have special signicance:
OPEN or CREATE speciy a current archive, which is a temporary le required or most othe other commands.
SAVE commits the changes so ar specied by the script. Prior to SAVE, commands afect
only the temporary copy o the current archive.ADDLIB archive
ADDLIB archive (module , module , ... module )
Add all the contents o archive (or, i specied, each named module romarchive) to the current archive.
Requires prior use o OPEN or CREATE.
ADDMOD member, member, ... member
Add each named member as a module in the current archive.
Requires prior use o OPEN or CREATE.
CLEAR Discard the contents o the current archive, canceling the efect o any operations
since the last SAVE. May be executed (with no efect) even i no current archiveis specied.
CREATE archive
Creates an archive, and makes it the current archive (required or many othercommands). The new archive is created with a temporary name; it is not actu-ally saved as archive until you use SAVE. You can overwrite existing archives;similarly, the contents o any existing le named archive will not be destroyeduntil SAVE.
-
8/6/2019 Bi Nut Ils
11/84
Chapter 1: ar 7
DELETE module , module , ... module
Delete each listed module rom the current archive; equivalent to ar -darchive module ... module .
Requires prior use oOPEN
orCREATE
.DIRECTORY archive (module , ... module )
DIRECTORY archive (module , ... module ) outputfile
List each named module present in archive. The separate command VERBOSEspecies the orm o the output: when verbose output is of, output is like thato ar -t archive module .... When verbose output is on, the listing is likear -tv archive module ....
Output normally goes to the standard output stream; however, i you speciyoutputle as a nal argument, ar directs the output to that le.
END Exit rom ar, with a 0 exit code to indicate successul completion. This com-mand does not save the output le; i you have changed the current archive
since the last SAVE command, those changes are lost.
EXTRACT module , module , ... module
Extract each named module rom the current archive, writing them into thecurrent directory as separate les. Equivalent to ar -x archive module ....
Requires prior use o OPEN or CREATE.
LIST Display ull contents o the current archive, in verbose style regardless o thestate o VERBOSE. The efect is like ar tv archive . (This single command isa gnu ar enhancement, rather than present or MRI compatibility.)
Requires prior use o OPEN or CREATE.
OPEN archive
Opens an existing archive or use as the current archive (required or manyother commands). Any changes as the result o subsequent commands will notactually afect archive until you next use SAVE.
REPLACE module , module , ... module
In the current archive, replace each existing module (named in the REPLACE ar-guments) rom les in the current working directory. To execute this commandwithout errors, both the le, and the module in the current archive, must exist.
Requires prior use o OPEN or CREATE.
VERBOSE Toggle an internal ag governing the output rom DIRECTORY. When the agis on, DIRECTORY output matches output rom ar -tv . . ..
SAVE Commit your changes to the current archive, and actually save it as a le withthe name specied in the last CREATE or OPEN command.
Requires prior use o OPEN or CREATE.
-
8/6/2019 Bi Nut Ils
12/84
Chapter 2: ld 8
2 ld
The gnu linker ld is now described in a separate manual. See Section Overview in UsingLD: the gnu linker.
-
8/6/2019 Bi Nut Ils
13/84
Chapter 3: nm 9
3 nm
nm [-a|--debug-syms][-g|--extern-only][--plugin name ]
[-B] [-C|--demangle[=style ]] [-D|--dynamic][-S|--print-size] [-s|--print-armap][-A|-o|--print-file-name][--special-syms][-n|-v|--numeric-sort] [-p|--no-sort][-r|--reverse-sort] [--size-sort] [-u|--undefined-only][-t radix|--radix=radix] [-P|--portability][--target=bfdname ] [-fformat|--format=format][--defined-only] [-l|--line-numbers] [--no-demangle]
[-V|--version] [-X 32_64] [--help] [objfile ...]
gnu nm lists the symbols rom object les objle. . . . I no object les are listed asarguments, nm assumes the le a.out.
For each symbol, nm shows:
The symbol value, in the radix selected by options (see below), or hexadecimal bydeault.
The symbol type. At least the ollowing types are used; others are, as well, dependingon the object le ormat. I lowercase, the symbol is local; i uppercase, the symbol isglobal (external).
A The symbols value is absolute, and will not be changed by urther linking.
B
b The symbol is in the uninitialized data section (known as BSS).
C The symbol is common. Common symbols are uninitialized data. Whenlinking, multiple common symbols may appear with the same name. I thesymbol is dened anywhere, the common symbols are treated as undenedreerences. For more details on common symbols, see the discussion owarn-common in Section Linker options in The GNU linker.
D
d The symbol is in the initialized data section.
G
g The symbol is in an initialized data section or small objects. Some objectle ormats permit more ecient access to small data objects, such as aglobal int variable as opposed to a large global array.
i For PE ormat les this indicates that the symbol is in a section specic tothe implementation o DLLs. For ELF ormat les this indicates that thesymbol is an indirect unction. This is a GNU extension to the standardset o ELF symbol types. It indicates a symbol which i reerenced by arelocation does not evaluate to its address, but instead must be invoked atruntime. The runtime execution will then return the value to be used inthe relocation.
N The symbol is a debugging symbol.
p The symbols is in a stack unwind section.
http://ld.info.pdf/http://ld.info.pdf/http://ld.info.pdf/ -
8/6/2019 Bi Nut Ils
14/84
Chapter 3: nm 10
R
r The symbol is in a read only data section.
S
s The symbol is in an uninitialized data section or small objects.T
t The symbol is in the text (code) section.
U The symbol is undened.
u The symbol is a unique global symbol. This is a GNU extension to thestandard set o ELF symbol bindings. For such a symbol the dynamiclinker will make sure that in the entire process there is just one symbolwith this name and type in use.
V
v The symbol is a weak object. When a weak dened symbol is linked with
a normal dened symbol, the normal dened symbol is used with no error.When a weak undened symbol is linked and the symbol is not dened, thevalue o the weak symbol becomes zero with no error. On some systems,uppercase indicates that a deault value has been specied.
W
w The symbol is a weak symbol that has not been specically tagged as aweak object symbol. When a weak dened symbol is linked with a normaldened symbol, the normal dened symbol is used with no error. When aweak undened symbol is linked and the symbol is not dened, the valueo the symbol is determined in a system-specic manner without error. Onsome systems, uppercase indicates that a deault value has been specied.
- The symbol is a stabs symbol in an a.out object le. In this case, the nextvalues printed are the stabs other eld, the stabs desc eld, and the stabtype. Stabs symbols are used to hold debugging inormation. For moreinormation, see Section Stabs Overview in The stabs debug ormat.
? The symbol type is unknown, or object le ormat specic.
The symbol name.
The long and short orms o options, shown here as alternatives, are equivalent.
-A
-o
--print-file-name
Precede each symbol by the name o the input le (or archive member) in whichit was ound, rather than identiying the input le once only, beore all o itssymbols.
-a
--debug-syms
Display all symbols, even debugger-only symbols; normally these are not listed.
-B The same as --format=bsd (or compatibility with the MIPS nm).
http://stabs.info.pdf/http://stabs.info.pdf/http://stabs.info.pdf/ -
8/6/2019 Bi Nut Ils
15/84
Chapter 3: nm 11
-C
--demangle[=style ]
Decode (demangle) low-level symbol names into user-level names. Besides re-moving any initial underscore prepended by the system, this makes C++ unc-tion names readable. Diferent compilers have diferent mangling styles. Theoptional demangling style argument can be used to choose an appropriate de-mangling style or your compiler. See Chapter 10 [c++lt], page 42, or moreinormation on demangling.
--no-demangle
Do not demangle low-level symbol names. This is the deault.
-D
--dynamic
Display the dynamic symbols rather than the normal symbols. This is onlymeaningul or dynamic objects, such as certain types o shared libraries.
-f format
--format=format
Use the output ormat ormat, which can be bsd, sysv, or posix. The deaultis bsd. Only the rst character o ormat is signicant; it can be either upperor lower case.
-g
--extern-only
Display only external symbols.
--plugin name
Load the plugin called name to add support or extra target types. This optionis only available i the toolchain has been built with plugin support enabled.
-l
--line-numbers
For each symbol, use debugging inormation to try to nd a lename and linenumber. For a dened symbol, look or the line number o the address o thesymbol. For an undened symbol, look or the line number o a relocation entrywhich reers to the symbol. I line number inormation can be ound, print itater the other symbol inormation.
-n
-v--numeric-sort
Sort symbols numerically by their addresses, rather than alphabetically by theirnames.
-p
--no-sort
Do not bother to sort the symbols in any order; print them in the order en-countered.
-
8/6/2019 Bi Nut Ils
16/84
Chapter 3: nm 12
-P
--portability
Use the POSIX.2 standard output ormat instead o the deault ormat. Equiv-alent to -f posix.
-S
--print-size
Print both value and size o dened symbols or the bsd output style. Thisoption has no efect or object ormats that do not record symbol sizes, unless--size-sort is also used in which case a calculated size is displayed.
-s
--print-armap
When listing symbols rom archive members, include the index: a mapping(stored in the archive by ar or ranlib) o which modules contain denitionsor which names.
-r
--reverse-sort
Reverse the order o the sort (whether numeric or alphabetic); let the last comerst.
--size-sort
Sort symbols by size. The size is computed as the diference between the valueo the symbol and the value o the symbol with the next higher value. I thebsd output ormat is used the size o the symbol is printed, rather than thevalue, and -S must be used in order both size and value to be printed.
--special-syms
Display symbols which have a target-specic special meaning. These symbolsare usually used by the target or some special processing and are not nor-mally helpul when included included in the normal symbol lists. For exampleor ARM targets this option would skip the mapping symbols used to marktransitions between ARM code, THUMB code and data.
-t radix
--radix=radix
Use radix as the radix or printing the symbol values. It must be d or decimal,o or octal, or x or hexadecimal.
--target=bfdname
Speciy an object code ormat other than your systems deault ormat. SeeSection 19.1 [Target Selection], page 66, or more inormation.
-u
--undefined-only
Display only undened symbols (those external to each object le).
--defined-only
Display only dened symbols or each object le.
-
8/6/2019 Bi Nut Ils
17/84
-
8/6/2019 Bi Nut Ils
18/84
-
8/6/2019 Bi Nut Ils
19/84
Chapter 4: objcopy 15
[--writable-text][--readonly-text][--pure][--impure][--file-alignment=num ][--heap=size ]
[--image-base=address][--section-alignment=num ][--stack=size ][--subsystem=which :major.minor][-v|--verbose][-V|--version][--help] [--info]infile [outfile]
The gnu objcopy utility copies the contents o an object le to another. objcopy usesthe gnu bfd Library to read and write the object les. It can write the destination objectle in a ormat diferent rom that o the source object le. The exact behavior o objcopyis controlled by command-line options. Note that objcopy should be able to copy a ullylinked le between any two ormats. However, copying a relocatable object le between anytwo ormats may not work as expected.
objcopy creates temporary les to do its translations and deletes them aterward.objcopy uses bfd to do all its translation work; it has access to all the ormats describedin bfd and thus is able to recognize most ormats without being told explicitly. See SectionBFD in Using LD.
objcopy can be used to generate S-records by using an output target o srec (e.g., use-O srec).
objcopy can be used to generate a raw binary le by using an output target o binary(e.g., use -O binary). When objcopy generates a raw binary le, it will essentially pro-
duce a memory dump o the contents o the input object le. All symbols and relocationinormation will be discarded. The memory dump will start at the load address o thelowest section copied into the output le.
When generating an S-record or a raw binary le, it may be helpul to use -S toremove sections containing debugging inormation. In some cases -R will be useul toremove sections which contain inormation that is not needed by the binary le.
Noteobjcopy is not able to change the endianness o its input les. I the input ormathas an endianness (some ormats do not), objcopy can only copy the inputs into le ormatsthat have the same endianness or which have no endianness (e.g., srec). (However, seethe --reverse-bytes option.)
infileoutfile The input and output les, respectively. I you do not speciy outle, objcopy
creates a temporary le and destructively renames the result with the name oinle.
-I bfdname
--input-target=bfdname
Consider the source les object ormat to be bdname, rather than attemptingto deduce it. See Section 19.1 [Target Selection], page 66, or more inormation.
http://ld.info.pdf/http://ld.info.pdf/http://ld.info.pdf/http://ld.info.pdf/http://ld.info.pdf/ -
8/6/2019 Bi Nut Ils
20/84
Chapter 4: objcopy 16
-O bfdname
--output-target=bfdname
Write the output le using the object ormat bdname. See Section 19.1 [TargetSelection], page 66, or more inormation.
-F bfdname
--target=bfdname
Use bdname as the object ormat or both the input and the output le;i.e., simply transer data rom source to destination with no translation. SeeSection 19.1 [Target Selection], page 66, or more inormation.
-B bfdarch
--binary-architecture=bfdarch
Useul when transorming a architecture-less input le into an object le. In thiscase the output architecture can be set to bdarch. This option will be ignoredi the input le has a known bdarch. You can access this binary data inside aprogram by reerencing the special symbols that are created by the conversionprocess. These symbols are called binary objle start, binary objle endand binary objle size. e.g. you can transorm a picture le into an objectle and then access it in your code using these symbols.
-j sectionname
--only-section=sectionname
Copy only the named section rom the input le to the output le. This optionmay be given more than once. Note that using this option inappropriately maymake the output le unusable.
-R sectionname
--remove-section=sectionname
Remove any section named sectionname rom the output le. This option maybe given more than once. Note that using this option inappropriately may makethe output le unusable.
-S
--strip-all
Do not copy relocation and symbol inormation rom the source le.
-g
--strip-debug
Do not copy debugging symbols or sections rom the source le.
--strip-unneeded
Strip all symbols that are not needed or relocation processing.
-K symbolname--keep-symbol=symbolname
When stripping symbols, keep symbol symbolname even i it would normallybe stripped. This option may be given more than once.
-N symbolname
--strip-symbol=symbolname
Do not copy symbol symbolname rom the source le. This option may begiven more than once.
-
8/6/2019 Bi Nut Ils
21/84
Chapter 4: objcopy 17
--strip-unneeded-symbol=symbolname
Do not copy symbol symbolname rom the source le unless it is needed by arelocation. This option may be given more than once.
-G symbolname--keep-global-symbol=symbolname
Keep only symbol symbolname global. Make all other symbols local to the le,so that they are not visible externally. This option may be given more thanonce.
--localize-hidden
In an ELF object, mark all symbols that have hidden or internal visibility aslocal. This option applies on top o symbol-specic localization options such as-L.
-L symbolname
--localize-symbol=symbolname
Make symbol symbolname local to the le, so that it is not visible externally.This option may be given more than once.
-W symbolname
--weaken-symbol=symbolname
Make symbol symbolname weak. This option may be given more than once.
--globalize-symbol=symbolname
Give symbol symbolname global scoping so that it is visible outside o the lein which it is dened. This option may be given more than once.
-w
--wildcard
Permit regular expressions in symbolnames used in other command line options.The question mark (?), asterisk (*), backslash (\) and square brackets ([])operators can be used anywhere in the symbol name. I the rst character othe symbol name is the exclamation point (!) then the sense o the switch isreversed or that symbol. For example:
-w -W !foo -W fo*
would cause objcopy to weaken all symbols that start with o except or thesymbol oo.
-x
--discard-all
Do not copy non-global symbols rom the source le.
-X--discard-locals
Do not copy compiler-generated local symbols. (These usually start with L or..)
-b byte
--byte=byte
Keep only every byteth byte o the input le (header data is not afected). bytecan be in the range rom 0 to interleave-1, where interleave is given by the -i
-
8/6/2019 Bi Nut Ils
22/84
Chapter 4: objcopy 18
or --interleave option, or the deault o 4. This option is useul or creatingles to program rom. It is typically used with an srec output target.
-i interleave
--interleave=interleaveOnly copy one out o every interleave bytes. Select which byte to copy with the-b or --byte option. The deault is 4. objcopy ignores this option i you donot speciy either -b or --byte.
-p
--preserve-dates
Set the access and modication dates o the output le to be the same as thoseo the input le.
--debugging
Convert debugging inormation, i possible. This is not the deault becauseonly certain debugging ormats are supported, and the conversion process can
be time consuming.
--gap-fill val
Fill gaps between sections with val. This operation applies to the load address(LMA) o the sections. It is done by increasing the size o the section with thelower address, and lling in the extra space created with val.
--pad-to address
Pad the output le up to the load address address. This is done by increasingthe size o the last section. The extra space is lled in with the value speciedby --gap-fill (deault zero).
--set-start val
Set the start address o the new le to val. Not all object le ormats supportsetting the start address.
--change-start incr
--adjust-start incr
Change the start address by adding incr. Not all object le ormats supportsetting the start address.
--change-addresses incr
--adjust-vma incr
Change the VMA and LMA addresses o all sections, as well as the start address,by adding incr. Some object le ormats do not permit section addresses to bechanged arbitrarily. Note that this does not relocate the sections; i the program
expects sections to be loaded at a certain address, and this option is used tochange the sections such that they are loaded at a diferent address, the programmay ail.
--change-section-address section {=,+,-}val
--adjust-section-vma section {=,+,-}val
Set or change both the VMA address and the LMA address o the namedsection. I = is used, the section address is set to val. Otherwise, val isadded to or subtracted rom the section address. See the comments under
-
8/6/2019 Bi Nut Ils
23/84
Chapter 4: objcopy 19
--change-addresses, above. I section does not exist in the input le, awarning will be issued, unless --no-change-warnings is used.
--change-section-lma section {=,+,-}val
Set or change the LMA address o the named section. The LMA address isthe address where the section will be loaded into memory at program loadtime. Normally this is the same as the VMA address, which is the addresso the section at program run time, but on some systems, especially thosewhere a program is held in ROM, the two can be diferent. I = is used, thesection address is set to val. Otherwise, val is added to or subtracted romthe section address. See the comments under --change-addresses, above.I section does not exist in the input le, a warning will be issued, unless--no-change-warnings is used.
--change-section-vma section {=,+,-}val
Set or change the VMA address o the named section. The VMA address isthe address where the section will be located once the program has startedexecuting. Normally this is the same as the LMA address, which is the addresswhere the section will be loaded into memory, but on some systems, especiallythose where a program is held in ROM, the two can be diferent. I = is used,the section address is set to val. Otherwise, val is added to or subtracted romthe section address. See the comments under --change-addresses, above.I section does not exist in the input le, a warning will be issued, unless--no-change-warnings is used.
--change-warnings
--adjust-warnings
I --change-section-address or --change-section-lma or--change-section-vma is used, and the named section does not exist, issue
a warning. This is the deault.--no-change-warnings
--no-adjust-warnings
Do not issue a warning i --change-section-address or--adjust-section-lma or --adjust-section-vma is used, even i the named section does not exist.
--set-section-flags section =flags
Set the ags or the named section. The ags argument is a comma separatedstring o ag names. The recognized names are alloc, contents, load,noload, readonly, code, data, rom, share, and debug. You can setthe contents ag or a section which does not have contents, but it is not
meaningul to clear the contents ag o a section which does have contents just remove the section instead. Not all ags are meaningul or all object leormats.
--add-section sectionname =filename
Add a new section named sectionname while copying the le. The contents othe new section are taken rom the le lename. The size o the section will bethe size o the le. This option only works on le ormats which can supportsections with arbitrary names.
-
8/6/2019 Bi Nut Ils
24/84
Chapter 4: objcopy 20
--rename-section oldname =newname [,flags ]
Rename a section rom oldname to newname, optionally changing the sectionsags to ags in the process. This has the advantage over usng a linker scriptto perorm the rename in that the output stays as an object le and does notbecome a linked executable.
This option is particularly helpul when the input ormat is binary, since thiswill always create a section called .data. I or example, you wanted insteadto create a section called .rodata containing binary data you could use theollowing command line to achieve it:
objcopy -I binary -O -B \--rename-section .data=.rodata,alloc,load,readonly,data,contents \
--long-section-names {enable,disable,keep}
Controls the handling o long section names when processing COFF and PE-COFF object ormats. The deault behaviour, keep, is to preserve long sectionnames i any are present in the input le. The enable and disable optionsorcibly enable or disable the use o long section names in the output object;when disable is in efect, any long section names in the input object will betruncated. The enable option will only emit long section names i any arepresent in the inputs; this is mostly the same as keep, but it is let undenedwhether the enable option might orce the creation o an empty string tablein the output le.
--change-leading-char
Some object le ormats use special characters at the start o symbols. Themost common such character is underscore, which compilers oten add beoreevery symbol. This option tells objcopy to change the leading character o everysymbol when it converts between object le ormats. I the object le ormatsuse the same leading character, this option has no efect. Otherwise, it will adda character, or remove a character, or change a character, as appropriate.
--remove-leading-char
I the rst character o a global symbol is a special symbol leading characterused by the object le ormat, remove the character. The most common symbolleading character is underscore. This option will remove a leading underscorerom all global symbols. This can be useul i you want to link together objectso diferent le ormats with diferent conventions or symbol names. This isdiferent rom --change-leading-char because it always changes the symbolname when appropriate, regardless o the object le ormat o the output le.
--reverse-bytes=num
Reverse the bytes in a section with output contents. A section length must beevenly divisible by the value given in order or the swap to be able to take place.Reversing takes place beore the interleaving is perormed.
This option is used typically in generating ROM images or problematic targetsystems. For example, on some target boards, the 32-bit words etched rom8-bit ROMs are re-assembled in little-endian byte order regardless o the CPU
-
8/6/2019 Bi Nut Ils
25/84
Chapter 4: objcopy 21
byte order. Depending on the programming model, the endianness o the ROMmay need to be modied.
Consider a simple le with a section containing the ollowing eight bytes:12345678.
Using --reverse-bytes=2 or the above example, the bytes in the output lewould be ordered 21436587.
Using --reverse-bytes=4 or the above example, the bytes in the output lewould be ordered 43218765.
By using --reverse-bytes=2 or the above example, ollowed by--reverse-bytes=4 on the output le, the bytes in the second output lewould be ordered 34127856.
--srec-len=ival
Meaningul only or srec output. Set the maximum length o the Srecords beingproduced to ival. This length covers both address, data and crc elds.
--srec-forceS3
Meaningul only or srec output. Avoid generation o S1/S2 records, creatingS3-only record ormat.
--redefine-sym old =new
Change the name o a symbol old, to new. This can be useul when one istrying link two things together or which you have no source, and there arename collisions.
--redefine-syms=filename
Apply --redefine-sym to each symbol pair "old new" listed in the le le-name. lename is simply a at le, with one symbol pair per line. Line com-ments may be introduced by the hash character. This option may be givenmore than once.
--weaken Change all global symbols in the le to be weak. This can be useul whenbuilding an object which will be linked against other objects using the -Roption to the linker. This option is only efective when using an object leormat which supports weak symbols.
--keep-symbols=filename
Apply --keep-symbol option to each symbol listed in the le lename. le-name is simply a at le, with one symbol name per line. Line comments maybe introduced by the hash character. This option may be given more than once.
--strip-symbols=filename
Apply --strip-symbol option to each symbol listed in the le lename. le-name is simply a at le, with one symbol name per line. Line comments maybe introduced by the hash character. This option may be given more than once.
--strip-unneeded-symbols=filename
Apply --strip-unneeded-symbol option to each symbol listed in the le le-name. lename is simply a at le, with one symbol name per line. Linecomments may be introduced by the hash character. This option may be givenmore than once.
-
8/6/2019 Bi Nut Ils
26/84
Chapter 4: objcopy 22
--keep-global-symbols=filename
Apply --keep-global-symbol option to each symbol listed in the le le-name. lename is simply a at le, with one symbol name per line. Linecomments may be introduced by the hash character. This option may be givenmore than once.
--localize-symbols=filename
Apply --localize-symbol option to each symbol listed in the le lename.lename is simply a at le, with one symbol name per line. Line commentsmay be introduced by the hash character. This option may be given more thanonce.
--globalize-symbols=filename
Apply --globalize-symbol option to each symbol listed in the le lename.lename is simply a at le, with one symbol name per line. Line commentsmay be introduced by the hash character. This option may be given more thanonce.
--weaken-symbols=filename
Apply --weaken-symbol option to each symbol listed in the le lename.lename is simply a at le, with one symbol name per line. Line commentsmay be introduced by the hash character. This option may be given more thanonce.
--alt-machine-code=index
I the output architecture has alternate machine codes, use the indexth codeinstead o the deault one. This is useul in case a machine is assigned anocial code and the tool-chain adopts the new code, but other applicationsstill depend on the original code being used. For ELF based architectures i theindex
alternative does not exist then the value is treated as an absolute numberto be stored in the e machine eld o the ELF header.
--writable-text
Mark the output text as writable. This option isnt meaningul or all objectle ormats.
--readonly-text
Make the output text write protected. This option isnt meaningul or allobject le ormats.
--pure Mark the output le as demand paged. This option isnt meaningul or allobject le ormats.
--impure Mark the output le as impure. This option isnt meaningul or all object leormats.
--prefix-symbols=string
Prex all symbols in the output le with string.
--prefix-sections=string
Prex all section names in the output le with string.
--prefix-alloc-sections=string
Prex all the names o all allocated sections in the output le with string.
-
8/6/2019 Bi Nut Ils
27/84
Chapter 4: objcopy 23
--add-gnu-debuglink=path-to-file
Creates a .gnu debuglink section which contains a reerence to path-to-le andadds it to the output le.
--keep-file-symbolsWhen stripping a le, perhaps with --strip-debug or --strip-unneeded,retain any symbols speciying source le names, which would otherwise getstripped.
--only-keep-debug
Strip a le, removing contents o any sections that would not be stripped by--strip-debug and leaving the debugging sections intact. In ELF les, thispreserves all note sections in the output.
The intention is that this option will be used in conjunction with--add-gnu-debuglink to create a two part executable. One a strippedbinary which will occupy less space in RAM and in a distribution and the
second a debugging inormation le which is only needed i debugging abilitiesare required. The suggested procedure to create these les is as ollows:
1. Link the executable as normal. Assuming that is is called foo then...
2. Run objcopy --only-keep-debug foo foo.dbg to create a le containingthe debugging ino.
3. Run objcopy --strip-debug foo to create a stripped executable.
4. Run objcopy --add-gnu-debuglink=foo.dbg foo to add a link to thedebugging ino into the stripped executable.
Notethe choice o .dbg as an extension or the debug ino le is arbitrary.Also the --only-keep-debug step is optional. You could instead do this:
1. Link the executable as normal.
2. Copy foo to foo.full
3. Run objcopy --strip-debug foo
4. Run objcopy --add-gnu-debuglink=foo.full foo
i.e., the le pointed to by the --add-gnu-debuglink can be the ull executable.It does not have to be a le created by the --only-keep-debug switch.
Notethis switch is only intended or use on ully linked les. It does not makesense to use it on object les where the debugging inormation may be incom-plete. Besides the gnu debuglink eature currently only supports the presenceo one lename containing debugging inormation, not multiple lenames on aone-per-object-le basis.
--file-alignment numSpeciy the le alignment. Sections in the le will always begin at le ofsetswhich are multiples o this number. This deaults to 512. [This option is specicto PE targets.]
--heap reserve
--heap reserve ,commit
Speciy the number o bytes o memory to reserve (and optionally commit) tobe used as heap or this program. [This option is specic to PE targets.]
-
8/6/2019 Bi Nut Ils
28/84
Chapter 4: objcopy 24
--image-base value
Use value as the base address o your program or dll. This is the lowest memorylocation that will be used when your program or dll is loaded. To reduce theneed to relocate and improve perormance o your dlls, each should have aunique base address and not overlap any other dlls. The deault is 0x400000 orexecutables, and 0x10000000 or dlls. [This option is specic to PE targets.]
--section-alignment num
Sets the section alignment. Sections in memory will always begin at addresseswhich are a multiple o this number. Deaults to 0x1000. [This option is specicto PE targets.]
--stack reserve
--stack reserve ,commit
Speciy the number o bytes o memory to reserve (and optionally commit) tobe used as stack or this program. [This option is specic to PE targets.]
--subsystem which--subsystem which :major
--subsystem which :major.minor
Species the subsystem under which your program will execute. The legalvalues or which are native, windows, console, posix, efi-app, efi-bsd,efi-rtd, sal-rtd, and xbox. You may optionally set the subsystem versionalso. Numeric values are also accepted or which. [This option is specic to PEtargets.]
--extract-symbol
Keep the les section ags and symbols but remove all section data. Speci-cally, the option:
removes the contents o all sections; sets the size o every section to zero; and
sets the les start address to zero.
This option is used to build a .sym le or a VxWorks kernel. It can also bea useul way o reducing the size o a --just-symbols linker input le.
-V
--version
Show the version number o objcopy.
-v
--verbose
Verbose output: list all object les modied. In the case o archives, objcopy-V lists all members o the archive.
--help Show a summary o the options to objcopy.
--info Display a list showing all architectures and object ormats available.
-
8/6/2019 Bi Nut Ils
29/84
Chapter 5: objdump 25
5 objdump
objdump [-a|--archive-headers][-b bfdname|--target=bfdname]
[-C|--demangle[=style ] ][-d|--disassemble][-D|--disassemble-all][-z|--disassemble-zeroes][-EB|-EL|--endian={big | little }]
[-f|--file-headers][-F|--file-offsets][--file-start-context][-g|--debugging][-e|--debugging-tags][-h|--section-headers|--headers][-i|--info][-j section|--section=section ][-l|--line-numbers]
[-S|--source][-m machine|--architecture=machine]
[-M options|--disassembler-options=options][-p|--private-headers][-r|--reloc][-R|--dynamic-reloc][-s|--full-contents][-W[lLiaprmfFsoRt]|
--dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges]]
[-G|--stabs][-t|--syms][-T|--dynamic-syms][-x|--all-headers]
[-w|--wide]
[--start-address=address][--stop-address=address][--prefix-addresses][--[no-]show-raw-insn][--adjust-vma=offset][--special-syms][--prefix=prefix][--prefix-strip=level ][--insn-width=width ][-V|--version]
[-H|--help]objfile ...
objdump displays inormation about one or more object les. The options control whatparticular inormation to display. This inormation is mostly useul to programmers who areworking on the compilation tools, as opposed to programmers who just want their programto compile and work.
objle. . . are the object les to be examined. When you speciy archives, objdump showsinormation on each o the member object les.
The long and short orms o options, shown here as alternatives, are equivalent. At leastone option rom the list -a,-d,-D,-e,-f,-g,-G,-h,-H,-p,-r,-R,-s,-S,-t,-T,-V,-x must be given.
-
8/6/2019 Bi Nut Ils
30/84
Chapter 5: objdump 26
-a
--archive-header
I any o the objle les are archives, display the archive header inormation(in a ormat similar to ls -l). Besides the inormation you could list with artv, objdump -a shows the object le ormat o each archive member.
--adjust-vma=offset
When dumping inormation, rst add ofset to all the section addresses. Thisis useul i the section addresses do not correspond to the symbol table, whichcan happen when putting sections at particular addresses when using a ormatwhich can not represent section addresses, such as a.out.
-b bfdname
--target=bfdname
Speciy that the object-code ormat or the object les is bdname. This optionmay not be necessary; objdump can automatically recognize many ormats.
For example,objdump -b oasys -m vax -h fu.o
displays summary inormation rom the section headers (-h) o fu.o, whichis explicitly identied (-m) as a VAX object le in the ormat produced byOasys compilers. You can list the ormats available with the -i option. SeeSection 19.1 [Target Selection], page 66, or more inormation.
-C
--demangle[=style ]
Decode (demangle) low-level symbol names into user-level names. Besides re-moving any initial underscore prepended by the system, this makes C++ unc-tion names readable. Diferent compilers have diferent mangling styles. Theoptional demangling style argument can be used to choose an appropriate de-mangling style or your compiler. See Chapter 10 [c++lt], page 42, or moreinormation on demangling.
-g
--debugging
Display debugging inormation. This attempts to parse STABS and IEEE de-bugging ormat inormation stored in the le and print it out using a C likesyntax. I neither o these ormats are ound this option alls back on the -Woption to print any DWARF inormation in the le.
-e
--debugging-tagsLike -g, but the inormation is generated in a ormat compatible with ctagstool.
-d
--disassemble
Display the assembler mnemonics or the machine instructions rom objle.This option only disassembles those sections which are expected to containinstructions.
-
8/6/2019 Bi Nut Ils
31/84
Chapter 5: objdump 27
-D
--disassemble-all
Like -d, but disassemble the contents o all sections, not just those expectedto contain instructions.
I the target is an ARM architecture this switch also has the efect o orcingthe disassembler to decode pieces o data ound in code sections as i they wereinstructions.
--prefix-addresses
When disassembling, print the complete address on each line. This is the olderdisassembly ormat.
-EB
-EL
--endian={big|little}
Speciy the endianness o the object les. This only afects disassembly. This
can be useul when disassembling a le ormat which does not describe endian-ness inormation, such as S-records.
-f
--file-headers
Display summary inormation rom the overall header o each o the objle les.
-F
--file-offsets
When disassembling sections, whenever a symbol is displayed, also display thele ofset o the region o data that is about to be dumped. I zeroes are beingskipped, then when disassembly resumes, tell the user how many zeroes wereskipped and the le ofset o the location rom where the disassembly resumes.When dumping sections, display the le ofset o the location rom where thedump starts.
--file-start-context
Speciy that when displaying interlisted source code/disassembly (assumes -S)rom a le that has not yet been displayed, extend the context to the start othe le.
-h
--section-headers
--headers
Display summary inormation rom the section headers o the object le.
File segments may be relocated to nonstandard addresses, or example by usingthe -Ttext, -Tdata, or -Tbss options to ld. However, some object leormats, such as a.out, do not store the starting address o the le segments.In those situations, although ld relocates the sections correctly, using objdump-h to list the le section headers cannot show the correct addresses. Instead,it shows the usual addresses, which are implicit or the target.
-H
--help Print a summary o the options to objdump and exit.
-
8/6/2019 Bi Nut Ils
32/84
Chapter 5: objdump 28
-i
--info Display a list showing all architectures and object ormats available or speci-cation with -b or -m.
-j name--section=name
Display inormation only or section name.
-l
--line-numbers
Label the display (using debugging inormation) with the lename and sourceline numbers corresponding to the object code or relocs shown. Only useulwith -d, -D, or -r.
-m machine
--architecture=machine
Speciy the architecture to use when disassembling object les. This can be
useul when disassembling object les which do not describe architecture inor-mation, such as S-records. You can list the available architectures with the -ioption.
I the target is an ARM architecture then this switch has an additional efect.It restricts the disassembly to only those instructions supported by the archi-tecture specied by machine. I it is necessary to use this switch because theinput le does not contain any architecture inormation, but it is also desiredto disassemble all the instructions use -marm.
-M options
--disassembler-options=options
Pass target specic inormation to the disassembler. Only supported on sometargets. I it is necessary to speciy more than one disassembler option thenmultiple -M options can be used or can be placed together into a commaseparated list.
I the target is an ARM architecture then this switch can be used to select whichregister name set is used during disassembler. Speciying -M reg-names-std(the deault) will select the register names as used in ARMs instruction setdocumentation, but with register 13 called sp, register 14 called lr and register15 called pc. Speciying -M reg-names-apcs will select the name set used bythe ARM Procedure Call Standard, whilst speciying -M reg-names-raw willjust use r ollowed by the register number.
There are also two variants on the APCS register naming scheme enabledby -M reg-names-atpcs and -M reg-names-special-atpcs which use the
ARM/Thumb Procedure Call Standard naming conventions. (Either with thenormal register names or the special register names).
This option can also be used or ARM architectures to orce the disassem-bler to interpret all instructions as Thumb instructions by using the switch--disassembler-options=force-thumb. This can be useul when attempt-ing to disassemble thumb code produced by other compilers.
For the x86, some o the options duplicate unctions o the -m switch, but allowner grained control. Multiple selections rom the ollowing may be specied
-
8/6/2019 Bi Nut Ils
33/84
Chapter 5: objdump 29
as a comma separated string. x86-64, i386 and i8086 select disassem-bly or the given architecture. intel and att select between intel syntaxmode and AT&T syntax mode. intel-mnemonic and att-mnemonic selectbetween intel mnemonic mode and AT&T mnemonic mode. intel-mnemonicimplies intel and att-mnemonic implies att. addr64, addr32, addr16,data32 and data16 speciy the deault address size and operand size. Theseour options will be overridden i x86-64, i386 or i8086 appear later in theoption string. Lastly, suffix, when in AT&T mode, instructs the disassem-bler to print a mnemonic sux even when the sux could be inerred by theoperands.
For PowerPC, booke controls the disassembly o BookE instructions. 32 and64 select PowerPC and PowerPC64 disassembly, respectively. e300 selectsdisassembly or the e300 amily. 440 selects disassembly or the PowerPC 440.ppcps selects disassembly or the paired single instructions o the PPC750CL.
For MIPS, this option controls the printing o instruction mnemonic namesand register names in disassembled instructions. Multiple selections rom theollowing may be specied as a comma separated string, and invalid options areignored:
no-aliases
Print the raw instruction mnemonic instead o some pseudo in-struction mnemonic. I.e., print daddu or or instead o move,sll instead o nop, etc.
gpr-names=ABI
Print GPR (general-purpose register) names as appropriate or thespecied ABI. By deault, GPR names are selected according to
the ABI o the binary being disassembled.
fpr-names=ABI
Print FPR (oating-point register) names as appropriate or thespecied ABI. By deault, FPR numbers are printed rather thannames.
cp0-names=ARCH
Print CP0 (system control coprocessor; coprocessor 0) registernames as appropriate or the CPU or architecture specied byARCH. By deault, CP0 register names are selected according tothe architecture and CPU o the binary being disassembled.
hwr-names=ARCH
Print HWR (hardware register, used by the rdhwr instruction)names as appropriate or the CPU or architecture specied byARCH. By deault, HWR names are selected according to the ar-chitecture and CPU o the binary being disassembled.
reg-names=ABI
Print GPR and FPR names as appropriate or the selected ABI.
-
8/6/2019 Bi Nut Ils
34/84
-
8/6/2019 Bi Nut Ils
35/84
Chapter 5: objdump 31
-W[lLiaprmfFsoRt]
--dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames
info,=trace_abbrev,=trace_aranges]
Displays the contents o the debug sections in the le, i any are present. I oneo the optional letters or words ollows the switch then only data ound in thosespecic sections will be dumped.
Note that there is no single letter option to display the content o trace sections.
-G
--stabs Display the ull contents o any sections requested. Display the contents o the.stab and .stab.index and .stab.excl sections rom an ELF le. This is onlyuseul on systems (such as Solaris 2.0) in which .stab debugging symbol-tableentries are carried in an ELF section. In most other le ormats, debuggingsymbol-table entries are interleaved with linkage symbols, and are visible in the--syms output. For more inormation on stabs symbols, see Section Stabs
Overview in The stabs debug ormat.
--start-address=address
Start displaying data at the specied address. This afects the output o the-d, -r and -s options.
--stop-address=address
Stop displaying data at the specied address. This afects the output o the-d, -r and -s options.
-t
--syms Print the symbol table entries o the le. This is similar to the inormationprovided by the nm program, although the display ormat is diferent. The
ormat o the output depends upon the ormat o the le being dumped, butthere are two main types. One looks like this:
[ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss
[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred
where the number inside the square brackets is the number o the entry in thesymbol table, the sec number is the section number, the value are the symbolsag bits, the ty number is the symbols type, the scl number is the symbolsstorage class and the nx value is the number o auxilary entries associated withthe symbol. The last two elds are the symbols value and its name.
The other common output ormat, usually seen with ELF based les, looks likethis:
00000000 l d .bss 00000000 .bss00000000 g .text 00000000 fred
Here the rst number is the symbols value (sometimes reered to as its address).The next eld is actually a set o characters and spaces indicating the ag bitsthat are set on the symbol. These characters are described below. Next is thesection with which the symbol is associated or *ABS* i the section is absolute(ie not connected with any section), or *UND* i the section is reerenced inthe le being dumped, but not dened there.
http://stabs.info.pdf/http://stabs.info.pdf/http://stabs.info.pdf/http://stabs.info.pdf/http://stabs.info.pdf/ -
8/6/2019 Bi Nut Ils
36/84
Chapter 5: objdump 32
Ater the section name comes another eld, a number, which or common sym-bols is the alignment and or other symbol is the size. Finally the symbolsname is displayed.
The ag characters are divided into 7 groups as ollows:l
g
u
! The symbol is a local (l), global (g), unique global (u), neitherglobal nor local (a space) or both global and local (!). A symbolcan be neither local or global or a variety o reasons, e.g., becauseit is used or debugging, but it is probably an indication o a bug iit is ever both local and global. Unique global symbols are a GNUextension to the standard set o ELF symbol bindings. For such asymbol the dynamic linker will make sure that in the entire processthere is just one symbol with this name and type in use.
w The symbol is weak (w) or strong (a space).
C The symbol denotes a constructor (C) or an ordinary symbol (aspace).
W The symbol is a warning (W) or a normal symbol (a space). Awarning symbols name is a message to be displayed i the symbolollowing the warning symbol is ever reerenced.
I
i The symbol is an indirect reerence to another symbol (I), a unctionto be evaluated during reloc processing (i) or a normal symbol (a
space).
d
D The symbol is a debugging symbol (d) or a dynamic symbol (D) ora normal symbol (a space).
F
f
O The symbol is the name o a unction (F) or a le () or an object(O) or just a normal symbol (a space).
-T
--dynamic-symsPrint the dynamic symbol table entries o the le. This is only meaningul ordynamic objects, such as certain types o shared libraries. This is similar to theinormation provided by the nm program when given the -D (--dynamic)option.
--special-syms
When displaying symbols include those which the target considers to be specialin some way and which would not normally be o interest to the user.
-
8/6/2019 Bi Nut Ils
37/84
Chapter 5: objdump 33
-V
--version
Print the version number o objdump and exit.
-x--all-headers
Display all available header inormation, including the symbol table and re-location entries. Using -x is equivalent to speciying all o -a -f -h -p -r-t.
-w
--wide Format some lines or output devices that have more than 80 columns. Also donot truncate symbol names when they are displayed.
-z
--disassemble-zeroes
Normally the disassembly output will skip blocks o zeroes. This option directs
the disassembler to disassemble those blocks, just like any other data.
-
8/6/2019 Bi Nut Ils
38/84
-
8/6/2019 Bi Nut Ils
39/84
Chapter 7: size 35
7 size
size [-A|-B|--format=compatibility][--help][-d|-o|-x|--radix=number][--common][-t|--totals][--target=bfdname] [-V|--version][objfile ...]
The gnu size utility lists the section sizesand the total sizeor each o the objector archive les objle in its argument list. By deault, one line o output is generated oreach object le or each module in an archive.
objle. . . are the object les to be examined. I none are specied, the le a.out willbe used.
The command line options have the ollowing meanings:
-A
-B--format=compatibility
Using one o these options, you can choose whether the output rom gnu sizeresembles output rom System V size (using -A, or --format=sysv), orBerkeley size (using -B, or --format=berkeley). The deault is the one-line ormat similar to Berkeleys.
Here is an example o the Berkeley (deault) ormat o output rom size:$ size --format=Berkeley ranlib sizetext data bss dec hex filename294880 81920 11592 388392 5ed28 ranlib294880 81920 11888 388688 5ee50 size
This is the same data, but displayed closer to System V conventions:$ size --format=SysV ranlib sizeranlib :section size addr.text 294880 8192.data 81920 303104.bss 11592 385024Total 388392
size :
section size addr.text 294880 8192.data 81920 303104.bss 11888 385024
Total 388688
--help Show a summary o acceptable arguments and options.
-d
-o
-x
--radix=number
Using one o these options, you can control whether the size o each section isgiven in decimal (-d, or --radix=10); octal (-o, or --radix=8); or hex-
-
8/6/2019 Bi Nut Ils
40/84
Chapter 7: size 36
adecimal (-x, or --radix=16). In --radix=number, only the three values(8, 10, 16) are supported. The total size is always given in two radices; decimaland hexadecimal or -d or -x output, or octal and hexadecimal i youre using-o.
--common Print total size o common symbols in each le. When using Berkeley ormatthese are included in the bss size.
-t
--totals Show totals o all objects listed (Berkeley ormat listing mode only).
--target=bfdname
Speciy that the ob ject-code ormat or objle is bdname. This option may notbe necessary; size can automatically recognize many ormats. See Section 19.1[Target Selection], page 66, or more inormation.
-V
--version
Display the version number o size.
-
8/6/2019 Bi Nut Ils
41/84
Chapter 8: strings 37
8 stringsstrings [-afovV] [-min-len]
[-n min-len] [--bytes=min-len ][-t radix] [--radix=radix]
[-e encoding] [--encoding=encoding][-] [--all] [--print-file-name][-T bfdname] [--target=bfdname][--help] [--version] file ...
For each le given, gnu strings prints the printable character sequences that are atleast 4 characters long (or the number given with the options below) and are ollowed by anunprintable character. By deault, it only prints the strings rom the initialized and loadedsections o object les; or other types o les, it prints the strings rom the whole le.
strings is mainly useul or determining the contents o non-text les.
-a
--all
- Do not scan only the initialized and loaded sections o object les; scan thewhole les.
-f
--print-file-name
Print the name o the le beore each string.
--help Print a summary o the program usage on the standard output and exit.
-min-len
-n min-len
--bytes=min-len
Print sequences o characters that are at least min-len characters long, insteado the deault 4.
-o Like -t o. Some other versions o strings have -o act like -t d instead.Since we can not be compatible with both ways, we simply chose one.
-t radix
--radix=radix
Print the ofset within the le beore each string. The single character argumentspecies the radix o the ofseto or octal, x or hexadecimal, or d ordecimal.
-e encoding
--encoding=encoding
Select the character encoding o the strings that are to be ound. Possiblevalues or encoding are: s = single-7-bit-byte characters (ASCII, ISO 8859,
etc., deault), S = single-8-bit-byte characters, b = 16-bit bigendian, l =16-bit littleendian, B = 32-bit bigendian, L = 32-bit littleendian. Useulor nding wide character strings. (l and b apply to, or example, UnicodeUTF-16/UCS-2 encodings).
-T bfdname
--target=bfdname
Speciy an object code ormat other than your systems deault ormat. SeeSection 19.1 [Target Selection], page 66, or more inormation.
-
8/6/2019 Bi Nut Ils
42/84
Chapter 8: strings 38
-v
-V
--version
Print the program version number on the standard output and exit.
-
8/6/2019 Bi Nut Ils
43/84
Chapter 9: strip 39
9 strip
strip [-F bfdname |--target=bfdname][-I bfdname |--input-target=bfdname]
[-O bfdname |--output-target=bfdname][-s|--strip-all][-S|-g|-d|--strip-debug][-K symbolname |--keep-symbol=symbolname][-N symbolname |--strip-symbol=symbolname][-w|--wildcard][-x|--discard-all] [-X |--discard-locals][-R sectionname |--remove-section=sectionname][-o file ] [-p|--preserve-dates][--keep-file-symbols][--only-keep-debug][-v |--verbose] [-V|--version]
[--help] [--info]objfile ...
gnu strip discards all symbols rom object les objle. The list o object les mayinclude archives. At least one object le must be given.
strip modies the les named in its argument, rather than writing modied copiesunder diferent names.
-F bfdname
--target=bfdname
Treat the original objle as a le with the object code ormat bdname, andrewrite it in the same ormat. See Section 19.1 [Target Selection], page 66, ormore inormation.
--help Show a summary o the options to strip and exit.
--info Display a list showing all architectures and object ormats available.
-I bfdname
--input-target=bfdname
Treat the original objle as a le with the object code ormat bdname. SeeSection 19.1 [Target Selection], page 66, or more inormation.
-O bfdname
--output-target=bfdname
Replace objle with a le in the output ormat bdname. See Section 19.1[Target Selection], page 66, or more inormation.
-R sectionname--remove-section=sectionname
Remove any section named sectionname rom the output le. This option maybe given more than once. Note that using this option inappropriately may makethe output le unusable.
-s
--strip-all
Remove all symbols.
-
8/6/2019 Bi Nut Ils
44/84
-
8/6/2019 Bi Nut Ils
45/84
Chapter 9: strip 41
--only-keep-debug
Strip a le, removing contents o any sections that would not be stripped by--strip-debug and leaving the debugging sections intact. In ELF les, thispreserves all note sections in the output.
The intention is that this option will be used in conjunction with--add-gnu-debuglink to create a two part executable. One a strippedbinary which will occupy less space in RAM and in a distribution and thesecond a debugging inormation le which is only needed i debugging abilitiesare required. The suggested procedure to create these les is as ollows:
1. Link the executable as normal. Assuming that is is called foo then...
2. Run objcopy --only-keep-debug foo foo.dbg to create a le containingthe debugging ino.
3. Run objcopy --strip-debug foo to create a stripped executable.
4. Run objcopy --add-gnu-debuglink=foo.dbg foo to add a link to the
debugging ino into the stripped executable.Notethe choice o .dbg as an extension or the debug ino le is arbitrary.Also the --only-keep-debug step is optional. You could instead do this:
1. Link the executable as normal.
2. Copy foo to foo.full
3. Run strip --strip-debug foo
4. Run objcopy --add-gnu-debuglink=foo.full foo
i.e., the le pointed to by the --add-gnu-debuglink can be the ull executable.It does not have to be a le created by the --only-keep-debug switch.
Notethis switch is only intended or use on ully linked les. It does not make
sense to use it on object les where the debugging inormation may be incom-plete. Besides the gnu debuglink eature currently only supports the presenceo one lename containing debugging inormation, not multiple lenames on aone-per-object-le basis.
-V
--version
Show the version number or strip.
-v
--verbose
Verbose output: list all object les modied. In the case o archives, strip
-v lists all members o the archive.
-
8/6/2019 Bi Nut Ils
46/84
Chapter 10: c++lt 42
10 c++lt
c++filt [-_|--strip-underscores]
[-n|--no-strip-underscores]
[-p|--no-params][-t|--types][-i|--no-verbose][-s format|--format=format][--help] [--version] [symbol ...]
The C++ and Java languages provide unction overloading, which means that you canwrite many unctions with the same name, providing that each unction takes parameters odiferent types. In order to be able to distinguish these similarly named unctions C ++ andJava encode them into a low-level assembler name which uniquely identies each diferentversion. This process is known as mangling. The c++filt1 program does the inversemapping: it decodes (demangles) low-level names into user-level names so that they can beread.
Every alphanumeric word (consisting o letters, digits, underscores, dollars, or periods)seen in the input is a potential mangled name. I the name decodes into a C++ name, theC++ name replaces the low-level name in the output, otherwise the original word is output.In this way you can pass an entire assembler source le, containing mangled names, throughc++filt and see the same source le containing demangled names.
You can also use c++filt to decipher individual symbols by passing them on the com-mand line:
c++filt symbol
I no symbol arguments are given, c++filt reads symbol names rom the standardinput instead. All the results are printed on the standard output. The diference betweenreading names rom the command line versus reading names rom the standard input is
that command line arguments are expected to be just mangled names and no checking isperormed to separate them rom surrounding text. Thus or example:
c++filt -n _Z1fv
will work and demangle the name to () whereas:c++filt -n _Z1fv,
will not work. (Note the extra comma at the end o the mangled name which makes itinvalid). This command however will work:
echo _Z1fv, | c++filt -n
and will display (),, i.e., the demangled name ollowed by a trailing comma. Thisbehaviour is because when the names are read rom the standard input it is expected thatthey might be part o an assembler source le where there might be extra, extraneous
characters trailing ater a mangled name. For example:.type _Z1fv, @function
-_
--strip-underscores
On some systems, both the C and C++ compilers put an underscore in ronto every name. For example, the C name foo gets the low-level name _foo.
1 MS-DOS does not allow + characters in le names, so on MS-DOS this program is named CXXFILT.
-
8/6/2019 Bi Nut Ils
47/84
Chapter 10: c++lt 43
This option removes the initial underscore. Whether c++filt removes theunderscore by deault is target dependent.
-n
--no-strip-underscoresDo not remove the initial underscore.
-p
--no-params
When demangling the name o a unction, do not display the types o theunctions parameters.
-t
--types Attempt to demangle types as well as unction names. This is disabled bydeault since mangled types are normally only used internally in the compiler,and they can be conused with non-mangled names. For example, a unctioncalled a treated as a mangled type name would be demangled to signed
char.-i
--no-verbose
Do not include implementation details (i any) in the demangled output.
-s format
--format=format
c++filt can decode various methods o mangling, used by diferent compilers.The argument to this option selects which method it uses:
auto Automatic selection based on executable (the deault method)
gnu the one used by the gnu C++ compiler (g++)
lucid the one used by the Lucid compiler (lcc)arm the one specied by the C++ Annotated Reerence Manual
hp the one used by the HP compiler (aCC)
edg the one used by the EDG compiler
gnu-v3 the one used by the gnu C++ compiler (g++) with the V3 ABI.
java the one used by the gnu Java compiler (gcj)
gnat the one used by the gnu Ada compiler (GNAT).
--help Print a summary o the options to c++filt and exit.
--version
Print the version number o c++filt and exit.
Warning: c++filt is a new utility, and the details o its user interace aresubject to change in uture releases. In particular, a command-line option maybe required in the uture to decode a name passed as an argument on thecommand line; in other words,
c++filt symbol
may in a uture release become
c++filt option symbol
-
8/6/2019 Bi Nut Ils
48/84
Chapter 11: addr2line 44
11 addr2lineaddr2line [-a|--addresses]
[-b bfdname|--target=bfdname][-C|--demangle[=style ]]
[-e filename|--exe=filename ][-f|--functions] [-s|--basename][-i|--inlines][-p|--pretty-print][-j|--section=name ][-H|--help] [-V|--version]
[addr addr ...]
addr2line translates addresses into le names and line numbers. Given an address in anexecutable or an ofset in a section o a relocatable object, it uses the debugging inormationto gure out which le name and line number are associated with it.
The executable or relocatable object to use is specied with the -e option. The deaultis the le a.out. The section in the relocatable object to use is specied with the -j
option.addr2line has two modes o operation.
In the rst, hexadecimal addresses are specied on the command line, and addr2linedisplays the le name and line number or each address.
In the second, addr2line reads hexadecimal addresses rom standard input, and printsthe le name and line number or each address on standard output. In this mode, addr2linemay be used in a pipe to convert dynamically chosen addresses.
The ormat o the output is FILENAME:LINENO. The le name and line number or eachaddress is printed on a separate line. I the -f option is used, then each FILENAME:LINENOline is preceded by a FUNCTIONNAME line which is the name o the unction containing theaddress. I the -a option is used, then the address read is rst printed.
I the le name or unction name can not be determined, addr2line will print twoquestion marks in their place. I the line number can not be determined, addr2line willprint 0.
The long and short orms o options, shown here as alternatives, are equivalent.
-a
--addresses
Display address beore unction names or le and line number inormation. Theaddress is printed with a 0x prex to easily identiy it.
-b bfdname
--target=bfdname
Speciy that the object-code ormat or the object les is bdname.
-C
--demangle[=style ]
Decode (demangle) low-level symbol names into user-level names. Besides re-moving any initial underscore prepended by the system, this makes C++ unc-tion names readable. Diferent compilers have diferent mangling styles. Theoptional demangling style argument can be used to choose an appropriate de-mangling style or your compiler. See Chapter 10 [c++lt], page 42, or moreinormation on demangling.
-
8/6/2019 Bi Nut Ils
49/84
Chapter 11: addr2line 45
-e filename
--exe=filename
Speciy the name o the executable or which addresses should be translated.The deault le is a.out.
-f
--functions
Display unction names as well as le and line number inormation.
-s
--basenames
Display only the base o each le name.
-i
--inlines
I the address belongs to a unction that was inlined, the source inormation orall enclosing scopes back to the rst non-inlined unction will also be printed.
For example, imain inlines callee1 which inlines callee2, and address is romcallee2, the source inormation or callee1 and main will also be printed.
-j
--section
Read ofsets relative to the specied section instead o absolute addresses.
-p
--pretty-print
Make the output more human riendly: each location are printed on one line. Ioption -i is specied, lines or all enclosing scopes are prexed with (inlinedby).
-
8/6/2019 Bi Nut Ils
50/84
Chapter 12: nlmconv 46
12 nlmconv
nlmconv converts a relocatable object le into a NetWare Loadable Module.
Warning: nlmconv is not always built as part o the binary utilities, since it isonly useul or NLM targets.
nlmconv [-I bfdname|--input-target=bfdname][-O bfdname|--output-target=bfdname ]
[-T headerfile|--header-file=headerfile][-d|--debug] [-l linker|--linker=linker][-h|--help] [-V|--version]infile outfile
nlmconv converts the relocatable i386 object le inle into the NetWare LoadableModule outle, optionally reading headerle or NLM header inormation. For instructionson writing the NLM command le language used in header les, see the linkers section,NLMLINK in particular, o the NLM Development and Tools Overview, which is part o theNLM Sotware Developers Kit (NLM SDK), available rom Novell, Inc. nlmconv usesthe gnu Binary File Descriptor library to read inle; see Section BFD in Using LD, ormore inormation.
nlmconv can perorm a link step. In other words, you can list more than one object leor input i you list them in the denitions le (rather than simply speciying one input leon the command line). In this case, nlmconv calls the linker or you.
-I bfdname
--input-target=bfdname
Object ormat o the input le. nlmconv can usually determine the ormat oa given le (so no deault is necessary). See Section 19.1 [Target Selection],page 66, or more inormation.
-O bfdname--output-target=bfdname
Object ormat o the output le. nlmconv iners the output ormat based onthe input ormat, e.g. or a i386 input le the output ormat is nlm32-i386.See Section 19.1 [Target Selection], page 66, or more inormation.
-T headerfile
--header-file=headerfile
Reads headerle or NLM header inormation. For instructions on writing theNLM command le language used in header les, see see the linkers sec-tion, o the NLM Development and Tools Overview, which is part o the NLMSotware Developers Kit, available rom Novell, Inc.
-d
--debug Displays (on standard error) the linker command line used by nlmconv.
-l linker
--linker=linker
Use linker or any linking. linker can be an absolute or a relative pathname.
-h
--help Prints a usage summary.
http://ld.info.pdf/http://ld.info.pdf/http://ld.info.pdf/ -
8/6/2019 Bi Nut Ils
51/84
Chapter 12: nlmconv 47
-V
--version
Prints the version number or nlmconv.
-
8/6/2019 Bi Nut Ils
52/84
Chapter 13: windmc 48
13 windmc
windmc may be used to generator Windows message resources.
Warning: windmc is not always built as part o the binary utilities, since it isonly useul or Windows targets.windmc [options] input-file
windmc reads message denitions rom an input le (.mc) and translate them into a seto output les. The output les may be o our kinds:
h A C header le containing the message denitions.
rc A resource le compilable by the windres tool.
bin One or more binary les containing the resource data or a specic messagelanguage.
dbg A C include le that maps message ids to their symbolic name.
The exact description o these diferent ormats is available in documentation rom Mi-crosot.
When windmc converts rom the mc ormat to the bin ormat, rc, h, and optional dbg itis acting like the Windows Message Compiler.
-a
--ascii_in
Species that the input le specied is ASCII. This is the deault behaviour.
-A
--ascii_out
Species that messages in the output bin les should be in ASCII ormat.
-b
--binprefix
Species that bin lenames should have to be prexed by the basename o thesource le.
-c
--customflag
Sets the customer bit in all message ids.
-C codepage
--codepage_in codepage
Sets the deault codepage to be used to convert input le to UTF16. The deault
is ocdepage 1252.-d
--decimal_values
Outputs the constants in the header le in decimal. Deault is using hexadeci-mal output.
-e ext
--extension ext
The extension or the header le. The deault is .h extension.
-
8/6/2019 Bi Nut Ils
53/84
-
8/6/2019 Bi Nut Ils
54/84
Chapter 13: windmc 50
-V
--version
Prints the version number or windmc.
-x path
--xdgb path
The path o the dbg C include le that maps message ids to the symbolic name.No such le is generated without speciying the switch.
-
8/6/2019 Bi Nut Ils
55/84
-
8/6/2019 Bi Nut Ils
56/84
Chapter 14: windres 52
-J format
--input-for