sysprog2 Part2

698 views

Published on

second part of the second session in phase I of system programming sessions in eglug

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
698
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

sysprog2 Part2

  1. 1. C for Linux Session 2 BY: Eng.Ahmed Teirelbar Software Engineer Shuja' Consulting
  2. 2. Examples Preprocessing, Compilation and Linking cpp example ● gcc example with a -o and -c ● objdump of a .o and an ELF ●
  3. 3. Your program as a process Every executing piece of code (outside the ● kernel) is running in or as a process including yours – ps and top example ●
  4. 4. Process Address Space Concept of address space ● Stack why per process? – why segmented? – A very simplified view – Data Segment what does this have to do with C? – Code Segment
  5. 5. Stack and Scope again What's a stack? ● SP, push and pop – Scoping in ● SP stored – Scoping out ● stack unwinds, SP retrieved – What does this mean for declarations ●
  6. 6. Libraries A piece of code that encapsulates some ● functionality - Modularity Dynamic and Static ● run-time vs build-time -- functional scalability – Linking – Sharing ● One copy in memory – size – In Linux: Static libraries and Shared Objects ●
  7. 7. Using a shared object lib<x>.so ● gcc example with libm.so ● gcc -l<m> .... – The library search path ● objdump of this new program ● ldd ●
  8. 8. Makefiles Builds get complex: ● Files – Flags and directives – Stages – make utility ● Reference ● http://www.linuxtopia.org/online_books/programming_to –
  9. 9. Makefile Basics variables ● rules ● dependencies ● variable defaults ● wild characters ●
  10. 10. Makefile Example Same program from earlier ● Add the shared object example ●
  11. 11. gdb Basics -g ● In execution ● run – continue – step – breakpoint – variables – directives – execute code –
  12. 12. Pointer Concepts An array is a pointer to the first element ● Pointer subscript access ● Scope issues – Back to the stack picture ● NULL pointer ●
  13. 13. Pointers SEGV ● Memory overwrites ● null termination issues ● Core dump ● More gdb ● dumping memory – casting –

×