C Development Environment - PowerPoint PPT Presentation

About This Presentation
Title:

C Development Environment

Description:

... options to stop GCC at any step of the source code processing chain are available -c Stops after hw.o -S Stops after hw.s -E ... Note under linux ... – PowerPoint PPT presentation

Number of Views:78
Avg rating:3.0/5.0
Slides: 14
Provided by: usf94
Category:

less

Transcript and Presenter's Notes

Title: C Development Environment


1
C Development Environment
2
Life Cycle of a C program Development
  • Designing Your Brain
  • Editing xemacs , vi ?!
  • Compiling gcc
  • Code Checking lint, smash
  • Testing / Debugging gdb , gof printf
  • Purifying e-fence, valgrind , purify
  • Profiling Optimizing gcov , gprof
  • Packaging deb , rpm

3
Compiling with GCC
include ltstdio.hgt int main ( ) printf
(hi\n)
hw
GCC -o hw hw.c
Executable File
Source code File hw.c
Lets get it done the simplest way first
4
Compiling with GCC in one step
hw
hw.c
gcc -o hw hw.c
Source File
Executable File
tux/hw GCC -o hw hw.c tux/hw ls
-l hw -rwxr-xr-x 1 gaspara voicedb
13877 Aug 8 1505 hw tux/hw ./hw hi
tux/hw file hw hw ELF 32-bit LSB
executable, Intel 80386, version 1, dynamically
linked (uses shared libs), not stripped tux/hw
more /usr/share/magic
5
Compiling with GCC in two steps
hw.o
hw.c
gcc -c hw.c
Object File
Source File
hw
gcc -o hw hw.o
Executable File
tux/hw GCC -c hw.c tux/hw ls
-l hw.o tux/hw file hw.o tux/hw
GCC -o hw2 hw.o tux/hw ls -l hw
hw2 tux/hw file hw2
6
Whats behind GCC ?
hw.i
hw.c
cpp0
Preprocessor
Expanded Source File
Source File
Compiler
hw.s
ccl
asm File
Other User .o Files
Assembler
hw.o
as
obj File
Link Editor / Linker
/usr/lib Libraries
hw
ld collect2
Exec File
7
More Informations about GCC ?
hw.i
Expanded Source File
Different Types of Files Extensions are detailed
in man gcc Similarly, options to stop GCC at
any step of the source code processing chain are
available -c Stops after hw.o -S Stops after
hw.s -E Stops after hw.i
hw.s
Asm File
hw.o
Obj File
hw
Exec File
8
Precompiling
hw.i
Contents of /usr/include/stdio.h
Expanded Source File
include ltstdio.hgt int main ( ) printf
(hi\n)
int main ( ) printf (hi\n)
hw.s
Asm File
hw.o
Source code File hw.c
Expanded Source File hw.i
Obj File
hw
cpp
Exec File
GCC -E hw.c
9
Compiling
hw.i
() main pushl ebp movl
esp, ebp subl 8, esp subl
12, esp pushl .LC0 call
printf addl 16, esp ()
Contents of /usr/include/stdio.h
Expanded Source File
hw.s
int main ( ) printf (hi\n)
Asm File
hw.o
Expanded Source File hw.i
Asm Source File hw.s
Obj File
hw
ccl
Exec File
GCC -S hw.c
10
Assembling
hw.i
() main pushl ebp movl
esp, ebp subl 8, esp subl
12, esp pushl .LC0 call
printf addl 16, esp ()
Expanded Source File
hw.o
hw.s
Obj File
GCC -c hw.c
Asm File
as
Asm Source File hw.s
hw.o
Relocatable Object File assembled asm code
(architecture dependent) ELF32_i386 format
(linux) Ready for link w/ other obj to form an
executable file
Obj File
hw
Exec File
11
Linking
hw.i
hw
Expanded Source File
hw.o
Exec File
hw.s
Obj File
ld
Asm File
hw.o
GCC -o hw hw.c
Gathering altogether Your Object
Files Object Files from libraries The C
runtime code
Obj File
hw
Exec File
12
Linking
hw.i
hw.o
hw
ld
Expanded Source File
Exec File
Obj File
A taste of what linking is really about
(edited) ld -m elf_i386 -dynamic-linker
/lib/ld-linux.so.2 -o hw /usr/lib/crt1.o
/usr/lib/crti.o /usr/lib/gcc-lib/i386-redhat-linu
x/2.96/crtbegin.o -L/usr/lib/gcc-lib/i386-red
hat-linux/2.96 -L/usr/lib/ hw.o -lgcc -lc
-lgcc /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt
end.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/../
../../crtn.o
hw.s
Asm File
hw.o
Obj File
hw
Exec File
13
Blank Slide
Write a Comment
User Comments (0)
About PowerShow.com