How does “Hello World!” Actually Work?

Kunal Desai
The Startup
Published in
8 min readJun 4, 2020

--

Have you ever wondered how the famous “Hello World!” actually works? This article dives deep into the assembly code of what happens under the hood when a “Hello World!” C program is executed. It primarily uncovers the dynamic linking process for functions like printf.

Let’s take the basic “Hello World!” program that looks like the following:

Our compiler (if you want an overview of the compilation and linking process the following articles will be helpful: overview and static linking) has turned this C source code into assembly code which are instructions that map to bits which the machine can then understand and execute. Each of the instructions are located at a memory address. A program’s memory generally looks something like this:

Credit: https://gabrieletolomei.wordpress.com/miscellanea/operating-systems/in-memory-layout/

A program’s instructions are generally included in the .text segment in memory. We can verify that this is the case for our program by running info files in GDB. The info files program shows us the different sections at memory address ranges.

--

--