# 10 LDFLAGS I Love

DevFeed: [10 LDFLAGS I Love](<https://devfeed.tech/articles/10-ldflags-i-love-35211.md>)

Original publisher: [Read original article](<https://blog.jessfraz.com/post/top-10-favorite-ldflags/>)

Published: 2016-07-18T20:00:14Z

Content type: article

Language: en

Sources: [Jessie Frazelle](<https://devfeed.tech/sources/jessie-frazelle.md>)

Topics: [linker](<https://devfeed.tech/topics/linker.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [binaries](<https://devfeed.tech/tags/binaries.md>), [debug](<https://devfeed.tech/tags/debug.md>), [linker](<https://devfeed.tech/tags/linker.md>), [map](<https://devfeed.tech/tags/map.md>), [symbols](<https://devfeed.tech/tags/symbols.md>)

## AI overview

A sarcastic programming article presents ten favorite LDFLAGS and briefly explains their linker behavior, including static linking, symbol export, archive inclusion, link-map generation, symbol stripping, tracing, library search restrictions, and unresolved symbols.

## Source excerpt

Hello and welcome to what will become the most sarcastic post on my blog. This is going to be a series of "buzzfeed" style programming articles and after this post I very happily pass the baton to Filippo Valsorda to continue. And I urge you to write your own as well. @jessfraz "We asked Jess for her top 10 ldflags; you won't believe what happened next" -- adg (@enneff) July 17, 2016 So here they are: -static I would be an embarassment to myself if I didn't start with the flag that tells the linker to not link against shared libraries. This is the best flag. STATIC BINARIES FTW. --export-dynamic This flag tells the linker to add all the symbols to the dynamic symbol table. This is especially important if you want to do "The Macgyver of Dlopening" and dlopen yourself. --whole-archive This is another flag that comes in handy when you want to dlopen yourself. See most linkers will only take into account the things it knows it needs. But with this flag, you tell it "YOLO, I want it all" so that later you can dlopen yourself with that symbol that was never actually used until runtime. FUN! --no-whole-archive This flag un-sets the --whole-archive flag which is nice for when you only want the whole archive of one library but not all the others you are linking to. --print-map This flag is just dope. It prints a link map to stdout. This gives you information about object files, common symbols, and the values assigned to symbols. --strip-all This flag strips all the symbol information from the artifact produced. If say you are a few KB/MB off from your binary fitting on a floppy disk, this flag is your friend. --strip-debug This flag is very similar to --strip-all except it only strips the debug symbol information. This all really depends on how much you need to shave off to fit that binary on a floppy disk. --trace This flag is great for debugging. It prints the names of the input files as ld processes them. -nostdlib This flag forces the linker to only search the libraries y