SlideShare a Scribd company logo
© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
gcc & Friends
2© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
What is 'gcc'?
Internals of 'gcc'
How to use 'gcc'?
Friends of 'gcc'
3© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What is 'gcc'?
GNU C Compiler
Open Source Compiler for C & C++
Along with standard headers & libraries
Rather a collection of tools
Corresponding to various compiler stages
Various other compilers built using it
Cross Compilers for different architectures
4© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
'gcc': Internals Decoded
Pre
Processor
ICG
(machine
independent)
ICG
(machine
dependent)
Assembler
(as)
Linker
(ld)
.c .i IC(parse trees, ...) .S .o .exe
gcc core
gcc wrapper
gcc -S
gcc -c
gcc
gcc -E
5© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Using GNU C Compiler
gcc file.c → Creates the executable a.out
gcc file.c -o file
gcc -E file.c → Pre-process only
gcc -S file.c → Generate assembly code
gcc -c file.c → Create object code
gcc -I<hdrs_path> file.c
gcc -L<libs_path> file.c -l<lib>
gcc -D<define> file.c
gcc -On file.c, n = 0, 1, 2, 3, s, fast, g
gcc -M file.c
gcc -MM file.c
gcc -T <linker_script> file.c
gcc -Wl,<linker_option> file.c
... (including many architecture specific flags)
6© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Default Compiler Defines
Trick to find out (#gcc #define)
gcc -E -dM -xc /dev/null | sort
Also
gcc -E -dM -xc++ /dev/null | sort
gcc -E -dM -xc++ -std=c++0x /dev/null | sort
7© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Standard Paths
Standard Headers Path: /usr/include/
Standard Libraries Path: /usr/lib/
Library Prefix: lib
Standard Headers
stdio.h, strings.h, math.h, ...
Standard Libraries
libc, libm, …
Where is the code of printf?
8© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Friends of 'gcc'
Preprocessor: cpp
Assembler: as
Linker: ld
Name Lister: nm
Disassembler: objdump
Archiver: ar
Print strings from files: strings
...
9© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
gcc: GNU C Compiler
Standard Headers & Libraries
Collection of tools
Usage of 'gcc'
Friends of 'gcc'
10© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?
11© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Advanced Topics
Shared library vs Archive
Linking, Library Function Call, ...
Defining your own headers
Creating a shared library
Creating an archive

More Related Content

PDF
Board Bringup
PDF
BeagleBone Black Bootloaders
PDF
CNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic Analysis
PDF
Block Drivers
PDF
USB Drivers
PDF
Introduction to Linux Drivers
PDF
Embedded Android : System Development - Part II (Linux device drivers)
PDF
BeagleBone Black Booting Process
Board Bringup
BeagleBone Black Bootloaders
CNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic Analysis
Block Drivers
USB Drivers
Introduction to Linux Drivers
Embedded Android : System Development - Part II (Linux device drivers)
BeagleBone Black Booting Process

Viewers also liked (15)

PDF
Embedded C
PDF
References
PDF
Kernel Debugging & Profiling
PDF
File System Modules
PDF
PCI Drivers
PDF
Network Drivers
PDF
Interrupts
PDF
Linux Porting
PDF
BeagleBoard-xM Bootloaders
PDF
Character Drivers
PDF
File Systems
Embedded C
References
Kernel Debugging & Profiling
File System Modules
PCI Drivers
Network Drivers
Interrupts
Linux Porting
BeagleBoard-xM Bootloaders
Character Drivers
File Systems
Ad

Similar to gcc and friends (20)

PDF
PDF
GNU Compiler Collection - August 2005
PPT
Porting To Symbian
PDF
3 Open-Source-SYCL-Intel-Khronos-EVS-Workshop_May19.pdf
PPT
From gcc to the autotools
PDF
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
PDF
Userspace drivers-2016
PPT
Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Bo...
PDF
Challenges in GPU compilers
PPTX
C# Production Debugging Made Easy
ODP
Embedding Qt
PPTX
Best Programming Course in Jalandhar - TechCADD Computer Education
ODP
C Under Linux
PPTX
Advance Android Application Development
PPTX
CA-Lec2-Chap2-Instructions-HL-2-MCxxx.pptx
PPTX
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
PDF
不深不淺,帶你認識 LLVM (Found LLVM in your life)
PPT
CPlusPus
PPT
Abhishek lingineni
GNU Compiler Collection - August 2005
Porting To Symbian
3 Open-Source-SYCL-Intel-Khronos-EVS-Workshop_May19.pdf
From gcc to the autotools
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
Userspace drivers-2016
Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Bo...
Challenges in GPU compilers
C# Production Debugging Made Easy
Embedding Qt
Best Programming Course in Jalandhar - TechCADD Computer Education
C Under Linux
Advance Android Application Development
CA-Lec2-Chap2-Instructions-HL-2-MCxxx.pptx
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
不深不淺,帶你認識 LLVM (Found LLVM in your life)
CPlusPus
Abhishek lingineni
Ad

More from Anil Kumar Pugalia (20)

PDF
File System Modules
PDF
Kernel Debugging & Profiling
PDF
PDF
System Calls
PDF
Introduction to Linux
PDF
Embedded Software Design
PDF
Playing with R L C Circuits
PDF
Audio Drivers
PDF
Video Drivers
PDF
Mobile Hacking using Linux Drivers
PDF
Shell Scripting
PDF
Functional Programming with LISP
PDF
Power of vi
PDF
"make" system
PDF
Hardware Design for Software Hackers
PDF
RPM Building
PDF
Linux User Space Debugging & Profiling
PDF
Linux Network Management
PDF
System Calls
File System Modules
Kernel Debugging & Profiling
System Calls
Introduction to Linux
Embedded Software Design
Playing with R L C Circuits
Audio Drivers
Video Drivers
Mobile Hacking using Linux Drivers
Shell Scripting
Functional Programming with LISP
Power of vi
"make" system
Hardware Design for Software Hackers
RPM Building
Linux User Space Debugging & Profiling
Linux Network Management
System Calls

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Modernizing your data center with Dell and AMD
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
A Presentation on Artificial Intelligence
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Modernizing your data center with Dell and AMD
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
A Presentation on Artificial Intelligence
Digital-Transformation-Roadmap-for-Companies.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
NewMind AI Monthly Chronicles - July 2025
MYSQL Presentation for SQL database connectivity
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The Rise and Fall of 3GPP – Time for a Sabbatical?
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...

gcc and friends

  • 1. © 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. gcc & Friends
  • 2. 2© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? What is 'gcc'? Internals of 'gcc' How to use 'gcc'? Friends of 'gcc'
  • 3. 3© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What is 'gcc'? GNU C Compiler Open Source Compiler for C & C++ Along with standard headers & libraries Rather a collection of tools Corresponding to various compiler stages Various other compilers built using it Cross Compilers for different architectures
  • 4. 4© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. 'gcc': Internals Decoded Pre Processor ICG (machine independent) ICG (machine dependent) Assembler (as) Linker (ld) .c .i IC(parse trees, ...) .S .o .exe gcc core gcc wrapper gcc -S gcc -c gcc gcc -E
  • 5. 5© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Using GNU C Compiler gcc file.c → Creates the executable a.out gcc file.c -o file gcc -E file.c → Pre-process only gcc -S file.c → Generate assembly code gcc -c file.c → Create object code gcc -I<hdrs_path> file.c gcc -L<libs_path> file.c -l<lib> gcc -D<define> file.c gcc -On file.c, n = 0, 1, 2, 3, s, fast, g gcc -M file.c gcc -MM file.c gcc -T <linker_script> file.c gcc -Wl,<linker_option> file.c ... (including many architecture specific flags)
  • 6. 6© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Default Compiler Defines Trick to find out (#gcc #define) gcc -E -dM -xc /dev/null | sort Also gcc -E -dM -xc++ /dev/null | sort gcc -E -dM -xc++ -std=c++0x /dev/null | sort
  • 7. 7© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Standard Paths Standard Headers Path: /usr/include/ Standard Libraries Path: /usr/lib/ Library Prefix: lib Standard Headers stdio.h, strings.h, math.h, ... Standard Libraries libc, libm, … Where is the code of printf?
  • 8. 8© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Friends of 'gcc' Preprocessor: cpp Assembler: as Linker: ld Name Lister: nm Disassembler: objdump Archiver: ar Print strings from files: strings ...
  • 9. 9© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? gcc: GNU C Compiler Standard Headers & Libraries Collection of tools Usage of 'gcc' Friends of 'gcc'
  • 10. 10© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?
  • 11. 11© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Advanced Topics Shared library vs Archive Linking, Library Function Call, ... Defining your own headers Creating a shared library Creating an archive