Using ltrace and strace Utilities
7.7.2 Using the ranlib Utility
The ranlib command is used to create index entries inside an archive file. This can also be done using – s command with the ar command while creating or updating an archive library file. The following command creates index inside libcommon.a file. Note that these index entries are stored inside the archive file and no other file is created. ranlib libcommon.a Most of the time you don’t need to run ranlib, as the latest version of the ar command creates an index by itself. Index entries can be displayed using the nm command.7.7.3 Using the nm Utility
The nm utility is used to list symbols used in an object file. If no object file is provided on the command line, the utility assumes the a.out file in the current directory as the default object file and lists its symbols. A common use of the utility is listing functions defined in a library. The following command displays object file names and functions defined in the library file created with ar command in the previous section. [rootboota] nm -s libcommon.a Archive index: msg in common.o main in ftp.o Using GNU Binary Utilities 229 common.o: 00000000 T msg U printf ftp.o: 00000000 T main U msg U printf [rootboota make] For each symbol, nm displays three properties of the symbol.1. Value 2. Type
3. Name
The value of the symbol is displayed in hexadecimal by default. Type is a character, either uppercase or lowercase. The uppercase character shows that the symbol is global and the lower- case character shows that the symbol is local. The following line shows that the symbol value is 00000000, its type is T which shows that the symbol is in code section and its name is msg. 00000000 T msg Type U in the above output of nm command shows that the symbol is undefined and no value is displayed. Note that function msg is defined in common.o but undefined in the ftp.o member of the archive. This is because of the fact that the function was defined in common.c file and it is used in ftp.c file. Usually, the list of symbols is very long in executable files. Consider the following simple file that displays the string “Hello world”. include stdio.h main { printf Hello world\n; } Let us compile this file to create an executable a.out file. A list of symbols in the a.out executable file is shown below: [rootboota] nm -s a.out 08049540 ? _DYNAMIC 0804951c ? _GLOBAL_OFFSET_TABLE_ 080484e4 R _IO_stdin_used 08049510 ? __CTOR_END__ 0804950c ? __CTOR_LIST__ 08049518 ? __DTOR_END__ 08049514 ? __DTOR_LIST__ 230 Chapter 7 • Miscellaneous Tools 08049508 ? __EH_FRAME_BEGIN__ 08049508 ? __FRAME_END__ 080495e0 A __bss_start w __cxa_finalizeGLIBC_2.1.3 080494f8 D __data_start w __deregister_frame_infoGLIBC_2.0 08048480 t __do_global_ctors_aux 080483b0 t __do_global_dtors_aux w __gmon_start__ U __libc_start_mainGLIBC_2.0 w __register_frame_infoGLIBC_2.0 080495e0 A _edata 080495f8 A _end 080484c0 ? _fini 080484e0 R _fp_hw 080482e4 ? _init 08048360 T _start 08048384 t call_gmon_start 08049504 d completed.1 080494f8 W data_start 08048410 t fini_dummy 08049508 d force_to_data 08049508 d force_to_data 08048420 t frame_dummy 08048384 t gcc2_compiled. 080483b0 t gcc2_compiled. 08048480 t gcc2_compiled. 080484c0 t gcc2_compiled. 08048460 t gcc2_compiled. 08048450 t init_dummy 080484b0 t init_dummy 08048460 T main 080495e0 b object.2 08049500 d p.0 U printfGLIBC_2.0 [rootboota make] 7.7.3.1 Listing Line Numbers in Source Files Use of – l option is very useful with this command. This option also displays filenames and line numbers where these symbols are used. The following command lists symbols in lib- common.a file in more detail. Note that it displays the path to the source code file and the line number. This information is used in the debugging process. [rootboota] nm -s libcommon.a -l Archive index: msg in common.o main in ftp.o Using GNU Binary Utilities 231Parts
» the linux development platform 2003
» Requirement Gathering Life Cycle of a Software Development Project
» Writing Functional Specifications Life Cycle of a Software Development Project
» Creating Architecture and Design Documents
» Implementation and Coding Life Cycle of a Software Development Project
» Testing Life Cycle of a Software Development Project
» Technical documentation developed during the development process. This includes
» Technical documentation prepared for technical support staff. This includes technical
» End-user manuals and guides. This is the documentation for the end user to assist the
» Software Releases Support and New Features
» Hardware Platform Components of a Development System
» Operating System Components of a Development System
» Editors Components of a Development System
» Compilers and Assemblers Components of a Development System
» Debuggers Components of a Development System
» Version Control Systems Components of a Development System
» Selection Criteria for Hardware Platform Selection Criteria for Software Development Tools
» Creating Deadlines Managing Development Process
» Managing the Development Team
» Resolving Dependencies Managing Development Process
» Libraries Linux Development Platform Specifications LDPS and Linux
» Open Source Developers Network at http:www.osdn.org
» Extensibility What to Look for in an Editor
» References and Resources the linux development platform 2003
» Target machine. This is the machine for which the newly built compiler will generate
» Post-Installation Tasks Installing GNU Compiler
» Compiling to Intermediate Levels
» Compilation with Debug Support
» Compilation with Optimization Compiling a Program
» Compiling Source Code for Other Languages
» Linking a program Assembling a Program
» Creating Libraries the linux development platform 2003
» Standard Libraries the linux development platform 2003
» Compiling Fortran Programs the linux development platform 2003
» Smalltalk Oberon Other Compilers
» The target 2. Dependencies Basic Terminology
» The explicit rules 2. The implicit rules
» Input Files Introduction to GNU make
» Typical Contents of a Makefile
» Running make Introduction to GNU make
» Shell to Execute Commands Include Files
» The ftp server The The dnsresolver
» FTPOBJS OBJS Another Example of Makefile
» Explicit Rules The make Rules
» Implicit Rules The make Rules
» Defining Variables Types of Variables
» Pre-Defined Variables Automatic Variables
» Makefile in The Top Directory
» Makefile in common-dir Directory
» Makefile in the ftp-dir Directory
» Makefile in the tftp-dir Directory Makefile in the dns-dir Directory
» Building Everything Working with Multiple Makefiles and Directories
» The ifdef Directive Control Structures and Directives
» The ifndef Directive Control Structures and Directives
» Compilation Getting the Latest Version and Installation
» Most Commonly Used gdb Commands
» Passing Command Line Arguments to the Program Being Debugged
» The step and finish Commands
» Introduction to GDB Working with the Stack
» Displaying Program Variables Displaying Variables
» Automatic Displaying Variables with Each Command
» Displaying Environment Variables Displaying Variables
» Modifying Variables Displaying Variables
» Disabling Break Points Enabling Break Points
» Debugging Optimized Code the linux development platform 2003
» Debugging Running Processes the linux development platform 2003
» The kdbg Debugger Other Open Source Debuggers
» The ddd Debugger Other Open Source Debuggers
» The xxgdb Debugger Other Open Source Debuggers
» CVS Policies the linux development platform 2003
» Project Management and Communication
» Remote Repositories Checking out a Project
» Finding the Status of a Project
» Finding Differences Using the CVS Client
» Resolving Conflicts Using the CVS Client
» Checking the Project Back In Adding Files to a Project
» Removing Files from a Project
» Tags and Releases Using the CVS Client
» System Requirements Introduction to jCVS
» Installation Instructions Introduction to jCVS
» Using jCVS Introduction to jCVS
» Installing pcl-cvs Using Emacs with CVS
» Using pcl-cvs Using Emacs with CVS
» Have a shell account on the CVS server. 2. Create a publicprivate key pair on the client.
» Selecting Coding Styles Using indent Utility
» Formatting Braces Using indent Utility
» Formatting Declarations Using indent Utility
» Breaking Long Lines Using indent Utility
» Summary of Options Using indent Utility
» Using sed Utility Using cscope and cbrowser
» Generating C Function Prototypes from C Source Code Using cproto
» Using ltrace and strace Utilities
» Value 2. Type Name Using the nm Utility
» Using the ranlib Utility Using the strip Utility
» Using the strings Utility Using the addr2line Utility
» Host Machine Introduction to the Cross-Platform Development Process
» Target Machine Introduction to the Cross-Platform Development Process
» Cross Platform Development Cycle
» Embedded Systems and Moving Parts
» Embedded Systems and Power Consumption
» Embedded Operating Systems What are Embedded Systems?
» Knowledge of Target System Hardware
» Software Emulators Cross Compilations
» Using gdbserver with GNU Debugger
» Attaching to a Running Process Using gdbserver
» Arcom SBC-GX1 Board Hardware Used for Cross-Platform and Embedded Systems
» Artesyn PMPPC Mezzanine Card
» References the linux development platform 2003
» Java Compiler Java Virtual Machine
» Kaffe the linux development platform 2003
» The Jboss Java Development System
» Getting and Installing Java SDK from Sun Creating jar Files
» Creating Source Code File Compiling Java Code
» Running Java Applications Building Java Applications
» Using gcj to Build Java Applications
» Building Applets the linux development platform 2003
» Testing Applets with Netscape
» Jikes for Java the linux development platform 2003
Show more