Skip to content

prithvisekhar/Having-Fun-with-C-and-CI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Outline

Building a simple program, phase wise

gcc hello.c -E          # stop with preprocess, actual tool is cpp
gcc hello.c -c          # compile only (no link), hello.o generated
gcc hello.o -o h.out    # link with std libs, startup code

Sections of a C/C++ Process

Use layoutdemo.c for this, dump symbol table using these steps

gcc layoutdemo.c -c -o demo.o
nm demo.o
objdump -t demo.o

observe symbol states like D,C/B,T,R, d,b,t,r What is the meaning of these symbol states in nm/objdump output?

More GNU Tools, gcc/g++ options

gcc hello.c   -S            # generate assebly code
gcc hello.s -c -o hello.o   # assemble the code
as hello.s -o hello.o       # assemble the code
gcc hello.o -o h.out        # link, generate executable

file hello.o                # check file type
file h.out                  # check file type
nm hello.o                  # symbol table
objdump -t hello.o          # symbol table
objdump -D hello.o	    # objdump --help
objdump -d hello.o          # disassemble the code
readelf -h hello.o          # header analysis, decode magic number
readelf -h h.out            # header analysis
size hello.o                # section wise footprint
size h.out                  # size --help

Debugging

gdb- Breakpoint, stepping, print etc.

gcc demo.c -c -g
gcc demo.o -o d.out -g
gdb ./d.out

In the IDE debug feature

Code Vizualization - Ctutor

Contribution

Of fantastic friends - Rajesh and Ganesh

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages