Over 10 Million Study Resources Now at Your Fingertips

Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Pages: 1

Able properly intermix the assembly and high-level source code

4.5 Assembly Listings


(gdb) where

#4 0x080718f4 in main ()

(gdb) print &select

We will focus more on stack tracebacks, problem determination facilities, and using a debugger in other chapters. For now, we will concentrate on the steps needed to create an assembly listing and how to correlate an offset with a line of code.

4.5.2 Generating Assembly Listings


int a = 5;

printf( “%s %d\n”, s, c );


Compiling Chap. 4

This produces the executable file as_listing. For gcc, specifying the -S flag causes the compilation to stop before the assembling phase and dump out the generated assembly code. By default, if -o is not used to specify an output filename, gcc converts the input source filename extension (such as .c) to .s. To be able to properly intermix the assembly and high-level source code, it is also required to use the -g flag to produce debug symbols and line number information. For the code in as_listing.c, to produce an assembly output, run the following command:

gcc as_listing.c -S -g

For the most part, the reason for examining an assembly listing is to determine how the compiler interpreted the high-level language and what assembly language resulted. When first looking at an assembly listing, it can be quite intimidating. It’s important to understand that there is a lot of information in this file that is only of use to a system’s assembler. Generally, much of this data can be ignored as often only a very specific area of the code will be desired and referred to by a function name and an offset in a stack dump or stack traceback for example. With this information and the assembly listing in hand,

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Make payment
Document download
Download File
PageId: ELI19C1E47
Uploaded by :
Page 1 Preview
able properly intermix the assembly and highlevel
Sell Your Old Documents & Earn Wallet Balance