Red Hat ENTERPRISE LINUX 4 - USING BINUTILS Using Instructions

Using binutils, the gnu binary utilities
Hide thumbs Also See for ENTERPRISE LINUX 4 - USING BINUTILS:

Advertisement

Red Hat Enterprise Linux 4
Using binutils, the GNU Binary
Utilities

Advertisement

Table of Contents
loading

Summary of Contents for Red Hat ENTERPRISE LINUX 4 - USING BINUTILS

  • Page 1 Red Hat Enterprise Linux 4 Using binutils, the GNU Binary Utilities...
  • Page 2 All other trademarks referenced herein are the property of their respective owners. The GPG fingerprint of the security@redhat.com key is: CA 20 86 86 2B D6 9D FC 65 F6 EC C4 21 91 80 CD DB 42 A6 0E...
  • Page 3: Table Of Contents

    Table of Contents 1. Introduction............................. 1 2. ar............................... 3 2.1. Controlling on the Command Line................3 2.2. Controlling with a Script ....................6 3. nm ..............................9 4. objcopy ............................13 5. objdump ............................21 6. ranlib .............................. 27 7. size ..............................29 8.
  • Page 5 gnu Binary Utilities...
  • Page 7: Introduction

    Chapter 1. Introduction This brief manual contains documentation for the gnu binary utilities (collectively version 2.15.92.0.2): This document is distributed under the terms of the GNU Free Documentation License. A copy of the license is included in the section entitled "GNU Free Documentation License".
  • Page 8 Chapter 1. Introduction...
  • Page 9: Ar Ar

    Chapter 2. ar [-] ...] relpos count archive member ar -M [ mri-script ] The gnu program creates, modifies, and extracts from archives. An archive is a single file holding a collection of other files in a structure that makes it possible to retrieve the original individual files (called members of the archive).
  • Page 10 Chapter 2. ar Delete modules from the archive. Specify the names of modules to be deleted as . . . ; the member archive is untouched if you specify no files to delete. If you specify the modifier, lists each module as it is deleted. Use this operation to move members in an archive.
  • Page 11 Chapter 2. ar If there is more than one file with the same name (say, ) in an archive (say ar t b.a lists only the first instance; to see them all, you must ask for a complete listing--in our example, ar t b.a Extract members (named...
  • Page 12: With A Script

    Chapter 2. ar This option will cause gnu to match file names using a complete path name, which can be convenient when extracting a single file from an archive 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.
  • Page 13 Chapter 2. ar comments are allowed; text after either of the characters is ignored. • Whenever you use a list of names as part of the argument to an command, you can separate the • individual names with either commas or blanks. Commas are shown in the explanations below, for clarity.
  • Page 14 Chapter 2. ar Exit from , with a exit code to indicate successful completion. This command does not save the output file; if you have changed the current archive since the last command, those SAVE changes are lost. EXTRACT , ... module module module...
  • Page 15: Controlling 3. Nm

    Chapter 3. nm [ --debug-syms --extern-only ]] [ --demangle style --dynamic --print-size --print-armap --print-file-name --numeric-sort --no-sort --reverse-sort --size-sort --undefined-only -t radix --radix=radix --portability --target=bfdname -fformat --format=format --defined-only --line-numbers --no-demangle ...] --version -X 32_64 --help objfile lists the symbols from object files .
  • Page 16 Chapter 3. nm The symbol is a debugging symbol. The symbol is in a read only data section. The symbol is in an uninitialized data section for small objects. The symbol is in the text (code) section. The symbol is undefined. The symbol is a weak object.
  • Page 17 Chapter 3. nm -demangle[= style Decode (demangle) low-level symbol names into user-level names. Besides removing any initial underscore prepended by the system, this makes C++ function names readable. Different compil- ers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler.
  • Page 18 Chapter 3. nm -print-armap When listing symbols from archive members, include the index: a mapping (stored in the archive ) of which modules contain definitions for which names. ranlib -reverse-sort Reverse the order of the sort (whether numeric or alphabetic); let the last come first. -size-sort Sort symbols by size.
  • Page 19: Objcopy

    Chapter 4. objcopy objcopy [ -F bfdname --target=bfdname -I bfdname --input-target=bfdname -O bfdname --output-target=bfdname -B bfdarch --binary-architecture=bfdarch --strip-all --strip-debug -K symbolname --keep-symbol=symbolname -N symbolname --strip-symbol=symbolname -G symbolname --keep-global-symbol=symbolname -L symbolname --localize-symbol=symbolname -W symbolname --weaken-symbol=symbolname --wildcard --discard-all --discard-locals -b byte --byte=byte -i interleave --interleave=interleave -j sectionname...
  • Page 20 Chapter 4. objcopy --help --info infile outfile The gnu utility copies the contents of an object file to another. uses the gnu bfd objcopy objcopy Library to read and write the object files. It can write the destination object file in a format different from that of the source object file.
  • Page 21 Chapter 4. objcopy _binary_ _end and _binary_ _size. e.g. you can transform a picture file into an objfile objfile object file and then access it in your code using these symbols. sectionname -only-section= sectionname Copy only the named section from the input file to the output file. This option may be given more than once.
  • Page 22 Chapter 4. objcopy the symbol name. If the first character of the symbol name is the exclamation point (!) then the sense of the switch is reversed for that symbol. For example: -w -W !foo -W fo* would cause objcopy to weaken all symbols that start with "fo" except for the symbol "foo". -discard-all Do not copy non-global symbols from the source file.
  • Page 23 Chapter 4. objcopy -change-addresses incr -adjust-vma incr Change the VMA and LMA addresses of all sections, as well as the start address, by adding . Some object file formats do not permit section addresses to be changed arbitrarily. Note incr that this does not relocate the sections;...
  • Page 24 Chapter 4. objcopy -add-section sectionname filename Add a new section named while copying the file. The contents of the new section sectionname are taken from the file . The size of the section will be the size of the file. This option filename only works on file formats which can support sections with arbitrary names.
  • Page 25 Chapter 4. objcopy -keep-symbols= filename Apply option to each symbol listed in the file is simply a -keep-symbol filename filename flat file, with one symbol name per line. Line comments may be introduced by the hash character. This option may be given more than once. -strip-symbols= filename Apply...
  • Page 26 Chapter 4. objcopy -add-gnu-debuglink= path-to-file Creates a .gnu_debuglink section which contains a reference to and adds it to path-to-file the output file. -only-keep-debug Strip a file, removing any sections that would be stripped by and leaving the -strip-debug debugging sections. The intention is that this option will be used in conjunction with -add-gnu-debuglink create a two part executable.
  • Page 27: Objdump

    Chapter 5. objdump objdump [ --archive-headers -b bfdname --target= bfdname --demangle style --disassemble --disassemble-all --disassemble-zeroes {big | little }] --endian= --file-headers --file-start-context --debugging --debugging-tags --section-headers --headers --info -j section --section=section --line-numbers --source -m machine --architecture=machine -M options --disassembler-options=options --private-headers --reloc --dynamic-reloc --full-contents --stabs...
  • Page 28 Chapter 5. objdump -adjust-vma= offset When dumping information, first add to all the section addresses. This is useful if the offset section addresses do not correspond to the symbol table, which can happen when putting sections at particular addresses when using a format which can not represent section addresses, such as a.out.
  • Page 29 Chapter 5. objdump -endian={big|little} Specify the endianness of the object files. This only affects disassembly. This can be useful when disassembling a file format which does not describe endianness information, such as S-records. -file-headers Display summary information from the overall header of each of the files.
  • Page 30 Chapter 5. objdump options -disassembler-options= options Pass target specific information to the disassembler. Only supported on some targets. If it is necessary to specify more than one disassembler option then multiple options can be used or can be placed together into a comma separated list. If the target is an ARM architecture then this switch can be used to select which register name set is used during disassembler.
  • Page 31 Chapter 5. objdump reg-names= Print GPR and FPR names as appropriate for the selected ABI. reg-names= ARCH Print CPU-specific register names (CP0 register and HWR names) as appropriate for the selected CPU or architecture. For any of the options listed above, may be specified as to have numbers ARCH...
  • Page 32 Chapter 5. objdump -start-address= address Start displaying data at the specified address. This affects the output of the options. -stop-address= address Stop displaying data at the specified address. This affects the output of the options. -syms Print the symbol table entries of the file. This is similar to the information provided by the program.
  • Page 33: Ranlib

    Chapter 6. ranlib ranlib [ archive generates an index to the contents of an archive and stores it in the archive. The index lists ranlib each symbol defined by a member of an archive that is a relocatable object file. You may use to list this index.
  • Page 34 Chapter 6. ranlib...
  • Page 35: Size

    Chapter 7. size size [ --format=compatibility --help --radix=number --totals --target=bfdname --version ...] objfile The gnu utility lists the section sizes--and the total size--for each of the object or archive files size in its argument list. By default, one line of output is generated for each object file or each objfile module in an archive.
  • Page 36 Chapter 7. size -radix= number Using one of these options, you can control whether the size of each section is given in dec- imal ( , or ); octal ( , or ); or hexadecimal ( , or ). In -radix=10 -radix=8 -radix=16...
  • Page 37: Strings

    Chapter 8. strings strings [ -afov -min-len -n min-len --bytes=min-len -t radix --radix=radix -e encoding --encoding=encoding --all --print-file-name --target=bfdname --help --version file For each given, gnu prints the printable character sequences that are at least 4 charac- file strings ters long (or the number given with the options below) and are followed by an unprintable character. By default, it only prints the strings from the initialized and loaded sections of object files;...
  • Page 38 Chapter 8. strings encoding -encoding= encoding Select the character encoding of the strings that are to be found. Possible values for encoding are: = single-7-bit-byte characters (ASCII, ISO 8859, etc., default), = single-8-bit-byte char- acters, = 16-bit bigendian, = 16-bit littleendian, = 32-bit bigendian, = 32-bit littleendian.
  • Page 39: Strip

    Chapter 9. strip strip [ -F bfdname --target=bfdname -I bfdname --input-target=bfdname -O bfdname --output-target=bfdname --strip-all --strip-debug -K symbolname --keep-symbol=symbolname -N symbolname --strip-symbol=symbolname --wildcard --discard-all --discard-locals -R sectionname --remove-section=sectionname -o file --preserve-dates --only-keep-debug --verbose --version --help --info objfile discards all symbols from object files .
  • Page 40 Chapter 9. strip -strip-all Remove all symbols. -strip-debug Remove debugging symbols only. -strip-unneeded Remove all symbols that are not needed for relocation processing. symbolname -keep-symbol= symbolname Keep only symbol from the source file. This option may be given more than once. symbolname symbolname -strip-symbol=...
  • Page 41 Chapter 9. strip -only-keep-debug Strip a file, removing any sections that would be stripped by and leaving the -strip-debug debugging sections. The intention is that this option will be used in conjunction with -add-gnu-debuglink create a two part executable. One a stripped binary which will occupy less space in RAM and in a distribution and the second a debugging information file which is only needed if debugging abilities are required.
  • Page 42 Chapter 9. strip...
  • Page 43: C++Filt

    Chapter 10. c++filt c++filt [ --strip-underscores --java --no-strip-underscores --no-params -s format --format=format ...] --help --version symbol The C++ and Java languages provides function overloading, which means that you can write many functions with the same name (providing each takes parameters of different types). All C++ and Java function names are encoded into a low-level assembly label (this process is known as mangling).
  • Page 44 Chapter 10. c++filt format -format= format can decode various methods of mangling, used by different compilers. The argument c++filt to this option selects which method it uses: auto Automatic selection based on executable (the default method) the one used by the gnu C++ compiler (g++) lucid the one used by the Lucid compiler (lcc) the one specified by the C++ Annotated Reference Manual...
  • Page 45 Chapter 10. c++filt...
  • Page 46 Chapter 10. c++filt...
  • Page 47: Addr2Line

    Chapter 11. addr2line addr2line [ -b bfdname --target=bfdname --demangle style -e filename --exe=filename --functions --basename --help --version [addr addr ...] translates program addresses into file names and line numbers. Given an address and an addr2line executable, it uses the debugging information in the executable to figure out which file name and line number are associated with a given address.
  • Page 48 Chapter 11. addr2line -functions Display function names as well as file and line number information. -basenames Display only the base of each file name.
  • Page 49: Nlmconv

    Chapter 12. nlmconv converts a relocatable object file into a NetWare Loadable Module. nlmconv Warning: is not always built as part of the binary utilities, since it is only useful for NLM targets. nlmconv nlmconv [ -I bfdname --input-target=bfdname -O bfdname --output-target=bfdname -T headerfile --header-file=headerfile...
  • Page 50 Chapter 12. nlmconv linker -linker= linker for any linking. can be an absolute or a relative pathname. linker linker -help Prints a usage summary. -version Prints the version number for nlmconv...
  • Page 51: Windres

    Chapter 13. windres may be used to manipulate Windows resources. windres Warning: is not always built as part of the binary utilities, since it is only useful for Windows windres targets. windres [options] [input-file] [output-file] reads resources from an input file and copies them into an output file. Either file may be in windres one of three formats: A text format read by the Resource Compiler.
  • Page 52 Chapter 13. windres filename -output filename The name of the output file. If this option is not used, then will use the first non-option windres argument, after any used for the input file name, as the output file name. If there is no non-option argument, then will write to standard output.
  • Page 53 Chapter 13. windres -language Specify the default language to use when reading an file. should be a hexadecimal lan- guage code. The low eight bits are the language, and the high eight bits are the sublanguage. -use-temp-file Use a temporary file to instead of using popen to read the output of the preprocessor. Use this option if the popen implementation is buggy on the host (eg., certain non-English language ver- sions of Windows 95 and Windows 98 are known to have buggy popen where the output will instead go the console).
  • Page 54 Chapter 13. windres...
  • Page 55: Create Files Needed To Build And Use Dlls

    Chapter 14. Create files needed to build and use DLLs may be used to create the files needed to build and use dynamic link libraries (DLLs). dlltool Warning: is not always built as part of the binary utilities, since it is only useful for those targets dlltool which support DLLs.
  • Page 56 Chapter 14. Create files needed to build and use DLLs The second file needed for DLL creation is an exports file. This file is linked with the object files that make up the body of the DLL and it handles the interface between the DLL and the outside world. This is a binary file and it can be created by giving the option to when it is creating or...
  • Page 57 Chapter 14. Create files needed to build and use DLLs -no-export-all-symbols Only export symbols explicitly listed in an input .def file or in sections in the input .drectve object files. This is the default behaviour. The sections are created by .drectve dllexport attributes in the source code.
  • Page 58 Chapter 14. Create files needed to build and use DLLs -kill-at Specifies that when is creating the exports file it should not append the string dlltool ¨ © The option is ignored for symbols with an explicit internal name specification number provided in a .def file.
  • Page 59 Chapter 14. Create files needed to build and use DLLs -version Displays dlltool’s version number and then exits.
  • Page 60 Chapter 14. Create files needed to build and use DLLs...
  • Page 61: Readelf

    Chapter 15. readelf readelf [ --all --file-header --program-headers --segments --section-headers --sections --headers --syms --symbols --notes --relocs --unwind --dynamic --version-info --arch-specific --use-dynamic number number --hex-dump= -w[liaprmfFso] [=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=frames-in --debug-dump -histogram --version --wide --help elffile displays information about one or more ELF format object files. The options control what readelf particular information to display.
  • Page 62 Chapter 15. readelf -sections -section-headers Displays the information contained in the file’s section headers, if it has any. -symbols -syms Displays the entries in symbol table section of the file, if it has one. -headers Display all the headers in the file. Equivalent to -h -l -S -notes Displays the contents of the NOTE segment, if it exists.
  • Page 63 Chapter 15. readelf -w[liaprmfFso] -debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=frames-interp,=str Displays the contents of the debug sections in the file, if any are present. If one of the optional letters or words follows the switch then only data found in those specific sections will be dumped. -histogram Display a histogram of bucket list lengths when displaying the contents of the symbol tables.
  • Page 64 Chapter 15. readelf...
  • Page 65: Selecting The Target System

    Chapter 16. Selecting the Target System You can specify two aspects of the target system to the gnu binary file utilities, each in several ways: the target • the architecture • In the following summaries, the lists of ways to specify values are in order of decreasing precedence. The ways listed first override those listed later.
  • Page 66: Architecture Selection

    Chapter 16. Selecting the Target System 16.1.3. Output Target objcopy strip Ways to specify: 1. command line options: , or -output-target -target 2. the input target (see " Input Target" above) objcopy strip 3. environment variable GNUTARGET 4. deduced from the input file 16.1.4.
  • Page 67: Reporting Bugs

    Chapter 17. Reporting Bugs Your bug reports play an essential role in making the binary utilities reliable. Reporting a bug may help you by bringing a solution to your problem, or it may not. But in any case the principal function of a bug report is to help the entire community by making the next version of the binary utilities work better.
  • Page 68 Chapter 17. Reporting Bugs Without this, we will not know whether there is any point in looking for the bug in the current version of the binary utilities. Any patches you may have applied to the source, including any patches made to the library.
  • Page 69 Chapter 17. Reporting Bugs A patch for the bug. • A patch for the bug does help us if it is a good one. But do not omit the necessary information, such as the test case, on the assumption that a patch is all we need. We might see problems with your patch and decide to fix the problem another way, or we might not understand it at all.
  • Page 70 Chapter 17. Reporting Bugs...
  • Page 71: Gnu Free Documentation License

    Appendix A. GNU Free Documentation License Version 1.1, March 2000 Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 1.
  • Page 72 Appendix A. GNU Free Documentation License A "Transparent" copy of the Document means a machine-readable copy, represented in a for- mat whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pix- els) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suit- able for input to text formatters.
  • Page 73 Appendix A. GNU Free Documentation License version of the Document. 5. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sec- tions 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and mod- ification of the Modified Version to whoever possesses a copy of it.
  • Page 74 Appendix A. GNU Free Documentation License You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combi- nation all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice.
  • Page 75: Addendum: How To Use This License For Your Documents

    Appendix A. GNU Free Documentation License The Free Software Foundation may publish new, revised versions of the GNU Free Documenta- tion License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number.
  • Page 76 Appendix A. GNU Free Documentation License...
  • Page 77: Index

    Index dates in archive, see Section 2.1 Controlling on the Command Line debug symbols, see Chapter 5 objdump .stab, see Chapter 5 objdump debugging symbols, see Chapter 3 nm deleting from archive, see Section 2.1 Controlling on the Command Line demangling C++ symbols, see Chapter 10 c++filt demangling in nm, see Chapter 3 nm addr2line, see Chapter 11 addr2line...
  • Page 78 Index printing from archive, see Section 2.1 Controlling header information, all, see Chapter 5 objdump on the Command Line printing strings, see Chapter 8 strings input .def file, see Chapter 14 Create files needed to build and use DLLs quick append to archive, see Section 2.1 Controlling input file name, see Chapter 3 nm on the Command Line radix for section sizes, see Chapter 7 size...
  • Page 79 Index symbol table entries, printing, see Chapter 5 objdump symbols, see Chapter 3 nm symbols, discarding, see Chapter 9 strip undefined symbols, see Chapter 3 nm Unix compatibility, , see Section 2.1 Controlling on the Command Line unwind information, see Chapter 15 readelf updating an archive, see Section 2.1 Controlling the Command Line version, see Chapter 1 Introduction...

This manual is also suitable for:

Enterprise linux 4

Table of Contents