---
title: "The smallest C binary"
url: https://daily.dev/posts/the-smallest-c-binary-5jsncdqut
source_url: https://blog.weineng.me/posts/smallest_c
type: article
source: "Lobsters"
published: 2026-06-06T13:03:11.034Z
updated: 2026-06-07T17:44:55.977Z
tags: ["c"]
reading_time: 13
upvotes: 1
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The smallest C binary

**[Lobsters](https://daily.dev/sources/lobsters)** · 13 min read · 1 upvotes · 0 comments

## Summary

A step-by-step exploration of minimizing a GCC-compiled C binary on Linux, starting from 15,816 bytes and reaching 400 bytes. Each optimization step is explained: stripping symbols (-s), removing startup files (-nostartfiles), eliminating libc and dynamic linking (-nostdlib -static -no-pie), dropping the .comment section (-fno-ident), removing stack unwind tables (-fno-asynchronous-unwind-tables -fno-exceptions), stripping GNU property notes (-Wa,-mx86-used-note=no), and finally removing page-alignment padding (-Wl,--nmagic). The final binary contains only the ELF header, two program headers, 11 bytes of x86-64 instructions (a direct syscall to exit(0)), and section metadata — totaling 400 bytes.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.weineng.me/posts/smallest_c>

## Similar posts on daily.dev

- [How Small Can A Linux Executable Be?](https://daily.dev/posts/how-small-can-a-linux-executable-be--dc08wt5uu) · Hackaday · 2 upvotes · 1 comments
- [Shrinking while linking](https://daily.dev/posts/shrinking-while-linking-awvvmpylk) · Planet Haskell · 1 upvotes · 0 comments

---

Tags: [#c](https://daily.dev/tags/c)

[View this post on daily.dev](https://daily.dev/posts/the-smallest-c-binary-5jsncdqut)
