Open main menu

CDOT Wiki β

Changes

SPO600 Compiled C Lab

257 bytes removed, 08:43, 1 November 2023
no edit summary
[[Category:SPO600 Labs- Retired]] {{Admon/lab|Purpose of this Lab|In this lab, you will investigate the relationship between basic C source code and the output of the C compiler.}}<!-- {{Admon/tip|IrelandHost System|Perform You can choose to perform this lab on ireland.proximity.on.ca -- an account has been created for each any of the [[SPO600Servers]] student. See your professor for login information. Alternately, you may use your own system if it has been set up with development tools and libraries, '''plus ''' the static version of the glibc library.}} --> {{Admon/tipimportant|AustraliaWinter 2020|Perform In Winter 2020, this lab on australia.proximity.on.ca is not a required lab and will instead be used as an in-- an account has been created for each [[SPO600]] student who submitted an SSH public key. See your professor for login information. Alternately, you may use your own system if it has been set up with development tools and libraries, '''plus''' the static version of the glibc libraryclass Demo.}}
== Resources ==
* [[Assembly Language]]
* [[ELF]] file format
* [[X86_64 Register and Instruction Quick Start]]
* [[Aarch64 Register and Instruction Quick Start]]
== Lab 4 / Demo ==
1. Write a basic C program which prints a message on the screen, [http://enwww.wikipediaroesler-ac.orgde/wikiwolfram/Hello_world_program hello.htm Hello World!]-style -- something like this:
#include <stdio.h>
}
2. Compile the program using the GCC compiler. Include each of these compiler options (refer to the gcc manpage for details):
-g # enable debugging information
(ii) Which section contains the string to be printed?
{{Admon/tip|objdump ''vs'' readelf|The way that <code>objdump</code> formats strings is not well suited for some uses. The <code>readelf -p</code> command may be a better tool for viewing some strings.}}
4. Try to gain a basic understanding of what the compiled code is doing. '''Focus on the section marked <main> but also take a look at the other sections and the overall file size.'''
== External Resources ==
* For a general overview of ELF, see the Wikipedia article on [http://en.wikipedia.org/wiki/Executable_and_Linkable_Format Executable and Linkable Format]