4/26/2023 0 Comments Learn assembly on mac![]() ![]() ![]() ![]() Inside GDB, we’ll break on main and run until we get to the return statement. Now compile it with debugging symbols and no optimizations and then run GDB: 1 $ CFLAGS="-g -O0" make simple Type the following program into a text file and save it as simple.c: int main() Let’s start by disassembling a program with GDB and learning how to read the output. Note: All the code in this post was compiled on an x86_64 CPU running Mac OS X 10.8.1 using Clang 4.0 with optimizations disabled ( -O0 ). I’ll do this by showing you how to disassemble and read a simple program with GDB, and then we’ll use GDB and our knowledge of assembly to understand how static local variables work in C. My goal in this post is to convince you that in order to rigorously understand C, we must also understand the assembly that our C compiler generates. Today I want to go one step further and use GDB to help us understand assembly as well.Ībstraction layers are great tools for building things, but they can sometimes get in the way of learning. Last time, Alan showed how to use GDB as a tool to learn C. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |