Cnile
GCC plugin to remember what flags were used to compile a binary.
Install / Use
/learn @enferex/CnileREADME
cnile: GCC-plugin to store build flags in the resulting binary file.
What
cnile is a plugin for GCC which stores the flags used for compiling. What's that you ask? How many times have you been presented with a binary or object file and asked the question: "Was this compiled using xyz flags?" Perhaps you forgot? Well, that day is over. This is a stupid-simple plugin which stashes all build flags in a separate section of the binary being compiled.
Related Works
ld' provides a --build-id flag gcc' provides -frecord-gcc-switches and -grecord-gcc-switches
Dependencies
GCC version 4.5 introduced plugins. cnile has only been built and tested on 4.8 thus, for older versions, your mileage might vary.
Build
This is a GCC plugin and uses the plugin framework built with g++ in version 4.8 of GCC. To build things simply run `make' from the cnile directory.
Use
Next time you build with GCC 4.8 or higher, include the cnile plugin by passing the '-fplugin=cnile.so' flag to GCC.
The flags are stored as comma separated values in the .cnile section of the
binary. objdump' or 'strings' can be used to get the goodies out: objdump <your binary> -j .cnile -s'
The section begins with the text: "<cnile>" and ends with
"</cnile>". This permits trivial sed processing:
strings <your binary> | sed '/<cnile>/,/<\/cnile/>'
objcopy' is also another good utility that can aid extracting just the .cnile section from the binary. For instance, an executable named 'foo' and the .cnile section extracted to 'foo.csv' objcopy -O binary --only-section=.cnile foo foo.csv'
Thanks to ndim over at: http://stackoverflow.com/questions/3925075/how-do-you-extract-only-the-contents-of-an-elf-section
Install
GCC must know where cnile.so is located in order to use it. You can install this plugin where GCC recognizes your other plugins by copying cnile.so there. The general plugin directory can be found by issuing the following argument to GCC: `gcc -print-file-name=plugin' You will still have to issue the '-fplugin=cnile.so' flag for the magic to get rockin'.
But wait, what's easier is that you can merely specify the full path to the plugin when you compile your program: `gcc foo.c -fplugin=/path/to/cnile.so'
Contact
Matt Davis (enferex) mattdavis9@gmail.com
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
