Red Hat ENTERPRISE LINUX 3 - USING BINUTILS Using Instructions

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

Advertisement

Red Hat Enterprise Linux 3
Using binutils, the Gnu Binary
Utilities

Advertisement

Table of Contents
loading

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

  • Page 1 Red Hat Enterprise Linux 3 Using binutils, the Gnu Binary Utilities...
  • Page 2 HTML, PDF, and RPM versions of the manuals are available on the Documentation CD and online at http://www.redhat.com/docs/. 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: Introduction

    Chapter 1. Introduction This brief manual contains documentation for the gnu binary utilities (collectively version 2.14.90.0.4): 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 6 Chapter 1. Introduction...
  • Page 7: 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 8 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 9 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 10: 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 11 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 12 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 13: 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 14 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 15 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 com- pilers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler.
  • Page 16 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 17: 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 --discard-all --discard-locals -b byte --byte=byte -i interleave --interleave=interleave -j sectionname --only-section=sectionname...
  • Page 18 Chapter 4. objcopy creates temporary files to do its translations and deletes them afterward. uses bfd objcopy objcopy to do all its translation work; it has access to all the formats described in bfd and thus is able to recognize most formats without being told explicitly. . can be used to generate S-records by using an output target of (e.g., use objcopy...
  • Page 19 Chapter 4. objcopy sectionname -remove-section= sectionname Remove any section named from the output file. This option may be given more sectionname than once. Note that using this option inappropriately may make the output file unusable. -strip-all Do not copy relocation and symbol information from the source file. -strip-debug Do not copy debugging symbols from the source file.
  • Page 20 Chapter 4. objcopy or the default of 4. This option is useful for creating files to program rom. It is typically used with output target. srec interleave -interleave= interleave Only copy one out of every bytes. Select which byte to copy with the interleave -byte option.
  • Page 21 Chapter 4. objcopy VMA address, which is the address of the section at program run time, but on some systems, especially those where a program is held in ROM, the two can be different. If is used, the section address is set to .
  • Page 22 Chapter 4. objcopy formats. If the object file formats use the same leading character, this option has no effect. Oth- erwise, it will add a character, or remove a character, or change a character, as appropriate. -remove-leading-char If the first character of a global symbol is a special symbol leading character used by the object file format, remove the character.
  • Page 23 Chapter 4. objcopy -alt-machine-code= index If the output architecture has alternate machine codes, use the th code instead of the default index one. This is useful in case a machine is assigned an official code and the tool-chain adopts the new code, but other applications still depend on the original code being used.
  • Page 24 Chapter 4. objcopy...
  • Page 25: 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 --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 --syms...
  • Page 26 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 bfdname -target=...
  • Page 27 Chapter 5. objdump -file-headers Display summary information from the overall header of each of the files. objfile -file-start-context Specify that when displaying interlisted source code/disassembly (assumes ) from a file that has not yet been displayed, extend the context to the start of the file. -section-headers -headers Display summary information from the section headers of the object file.
  • Page 28 Chapter 5. objdump There are also two variants on the APCS register naming scheme enabled by which use the ARM/Thumb reg-names-atpcs -M reg-names-special-atpcs Procedure Call Standard naming conventions. (Either with the normal register names or the special register names). This option can also be used for ARM architectures to force the disassembler interpret instructions Thumb...
  • Page 29 Chapter 5. objdump -private-headers Print information that is specific to the object file format. The exact information printed depends upon the object file format. For some object file formats, no additional information is printed. -reloc Print the relocation entries of the file. If used with , the relocations are printed inter- spersed with the disassembly.
  • Page 30 Chapter 5. objdump -dynamic-syms Print the dynamic symbol table entries of the file. This is only meaningful for dynamic objects, such as certain types of shared libraries. This is similar to the information provided by the program when given the ) option.
  • Page 31: 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 32 Chapter 6. ranlib...
  • Page 33: 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 34 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 35: 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 36 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 37: 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 --discard-all --discard-locals -R sectionname --remove-section=sectionname -o file --preserve-dates --verbose --version --help --info objfile discards all symbols from object files .
  • Page 38 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 39: C++Filt

    Chapter 10. c++filt c++filt [ --strip-underscores --java --no-strip-underscores -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 40 Chapter 10. c++filt 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 the one used by the HP compiler (aCC) the one used by the EDG compiler gnu-v3 the one used by the gnu C++ compiler (g++) with the V3 ABI.
  • Page 41: 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 42 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 43: 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 44 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 45: 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 46 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 47 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 48 Chapter 13. windres...
  • Page 49: 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 50 Chapter 14. Create files needed to build and use DLLs This is a binary file and it can be created by giving the option to when it is creating or dlltool reading in a .def file. The third file needed for DLL creation is the library file that programs will link with in order to access the functions in the DLL.
  • Page 51 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 52 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 ¨ © . These numbers are called ordinal numbers and they represent another way of number accessing the function in a DLL, other than by name.
  • Page 53: 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 54 Chapter 15. readelf -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. -relocs Displays the contents of the file’s relocation section, if it has one.
  • Page 55 Chapter 15. readelf -histogram Display a histogram of bucket list lengths when displaying the contents of the symbol tables. -version Display the version number of readelf. -wide Don’t break output lines to fit into 80 columns. By default breaks section header and readelf segment listing lines for 64-bit ELF files, so that they fit into 80 columns.
  • Page 56 Chapter 15. readelf...
  • Page 57: 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 58: 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 59: 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 60 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 61 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 62 Chapter 17. Reporting Bugs...
  • Page 63: 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 64 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 65 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 66 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 67: 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 68 Appendix A. GNU Free Documentation License...
  • Page 69: 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 70 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 71 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 3

Table of Contents