Open main menu

CDOT Wiki β

Changes

SPO600 Compiled C Lab

1,228 bytes added, 10:46, 17 January 2014
no edit summary
--source # (implies -d) show source code, if available, along with disassembly
4. Try to gain a basic understanding of what the compiled code is doing.
5. Recompile the code with these changes and note the effect --
 
(1) Add <code>-static</code>. Note and explain the change in size, section headers, and the function call.
 
(2) Remove <code>-fno-builtins</code>. Note and explain the change in the function call.
 
(3) Remove <code>-g</code>. Note and explain the change in size, section headers, and disassembly output.
 
(4) Add additional arguments to the <code>printf()</code> function in the program. Note which register each argument is placed in. (Tip: Use sequential integer arguments after the first string argument. Go up to 10 arguments and note the pattern).
 
(5) Move the <code>printf()</code> call to a separate function, and call that function from <code>main()</code>. Explain the changes in the object code.
 
(6) Remove <code>-O0</code> and add <code>-O3</code> to the gcc options. Note and explain the difference in the compiled code.
 
6. Blog about your results. Important! -- explain what you're doing so that a reader coming across your blog post understands the context.
 
{{Admon/tip|Make|Learn how to use [[Make and Makefiles|make]] -- your life as a programmer will be much easier!}}
== 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]