Log date · Mon
Compiler protection vs wrappers: what changes?
Published on · Updated
Compiler changes affect generated code; a wrapper can change delivery. We compare optimization, stripping and a compressed launcher.
The short answer: inspect where the change happens
A compiler-stage change modifies the generated program; a wrapper can change the delivered file and restore the program at launch. In our C sample, stripping reduced visible defined symbols from 3 to 2 while leaving the marker string. The gzip file did not show that marker, but the launcher restored a byte-identical copy of the original -O2 executable.
That result does not rank every compiler protection against every wrapper. Compare the internal code, shipped artifacts and execution path separately, then examine coverage and compatibility costs.
| Question | Finding |
|---|---|
| Did optimization change the visible symbol count? | Both -O0 and -O2 showed 3; the marker remained visible. |
| What did strip remove? | The target local symbol disappeared; the marker stayed. |
| What did the wrapper show? | The compressed file lacked the visible marker; launch restored the original -O2 file. |
Sample, builds and scope
We wrote a fictional quote program: at 100 units or more the unit price is 82, otherwise 100, and it prints DEMO-QUOTE-RULE. The function is marked noinline so that we can compare the same symbol. We used Apple clang 21.0.0, Xcode 27.2 and Apple gzip 487.40.2 on macOS 27.2 arm64. This tests our own compression launcher, ordinary optimization and strip, not a commercial packer or obfuscator.
#include <stdio.h>
#include <stdlib.h>
__attribute__((noinline)) static int quote_total(int units) {
int price = units >= 100 ? 82 : 100;
return units * price;
}
int main(int argc, char **argv) {
int units = argc > 1 ? atoi(argv[1]) : 120;
printf("DEMO-QUOTE-RULE: %d units cost %d\n", units, quote_total(units));
return 0;
}Clang describes optimization and code generation as stages of compilation. Its documentation describes -O0 as no optimization and -O2 as enabling most optimizations. [1] These are build and performance choices, not confidentiality guarantees.
Compare the compiled files first
We compiled the same source at -O0 and -O2, then copied the -O2 output and ran the system strip -x on the copy. All four runs used 120 and returned 9840. That checks one input only; a real application also needs boundary and error-path tests.
== outputs ==
DEMO-QUOTE-RULE: 120 units cost 9840
DEMO-QUOTE-RULE: 120 units cost 9840
DEMO-QUOTE-RULE: 120 units cost 9840
DEMO-QUOTE-RULE: 120 units cost 9840== bytes, marker, defined symbols ==
sample-O0 | 33496 | present | 3
sample-O2 | 33496 | present | 3
sample-stripped | 33504 | present | 2
sample.gz | 1086 | absent | not-applicable
restored | 33496 | present | 3The count is the number of defined-symbol lines printed by nm -U, not all metadata and not a readability score. LLVM documents nm as a symbol-table listing tool; check the local tool’s options for your platform. [2] Both optimization builds were 33,496 bytes and showed three symbol lines. Equal size does not establish identical machine code.
After strip, the target function name disappeared from nm output, but the marker used by the program remained visible. Surprisingly the file grew from 33,496 to 33,504 bytes. That observation on this machine does not predict size changes for another binary or platform. Retain controlled symbols and debug information so that crash diagnosis remains possible.
== named quote symbol ==
sample-O0 | present
sample-O2 | present
sample-stripped | absent
restored | presentThe wrapped file and the file after launch
We compressed the unstripped -O2 build with gzip. The launcher writes the decompressed content to restored, makes it executable and runs it. The gzip specification describes a compressed data format and decompression; it is not a keyed encryption scheme. [3] Our launcher deliberately leaves the restored file on disk for inspection.
#!/bin/sh
set -eu
cd "$(dirname "$0")"
gzip -dc sample.gz > restored
chmod +x restored
exec ./restored "$@"The compressed file was 1,086 bytes and strings did not find the marker. It is not an executable, so we did not count nm symbols for it. After launch, restored had the marker and three defined symbols again; cmp confirmed it matched sample-O2 byte for byte. The size comparison excludes the script and gzip tool and is not an application package saving.
== restored matches O2 ==
byte-identicalThe practical question is which stage is being inspected: the compressed delivery file, launcher and program used at runtime have different appearances. Real wrappers may load differently or also transform code, so assess the actual product and release configuration.
How to choose: recommendations
These are selection recommendations, not protection strength measured by our experiment. First identify the asset, what an adversary can obtain, and acceptable performance and operating costs.
| Case | Recommendation |
|---|---|
| Reduce shipped symbols | Compare before and after stripping, retain private symbols and test crash symbolication. |
| Protect critical business logic | Request per-function coverage and transformation evidence; compare analysis effort on the same build. |
| Consider a wrapper product | Inspect delivery and post-launch states; measure startup, updates, signing and recovery. |
| Shared privileged secret | Do not rely on client packaging; move it to a controlled service and scope and rotate access. |
For a vendor evaluation, hold source revision, target, build configuration and test budget constant. Ask which functions change, which only gain checks, and whether dependencies and dynamically loaded code are covered. Repeat on a new release and record how much prior analysis carries over. A single demonstration or string search cannot answer those questions.
Put compatibility in the same result: cold start, memory, crash reports, updates and signing can affect a release. Define a fallback build and exercise the release flow on controlled test devices. A passing functional test alone is not release acceptance.
Agree who can access the test reports and symbol files, and how to roll back a failed release. Record each test input, artifact hash and tool configuration alongside the result. This makes the comparison repeatable after a compiler upgrade or a change of vendor, rather than relying on a memory of the previous build.
Repeat on your own application
For your own macOS build, copy the artifact and replace the path and known non-sensitive test marker below. Do not strip the only release artifact or send potentially sensitive inspection output to public logs.
cp path/to/your-app ./audit-copy
wc -c ./audit-copy
strings -a < ./audit-copy | grep -F "YOUR-TEST-MARKER"
nm -U ./audit-copyThen make comparison builds with the same configuration and record tool versions, symbol counts, markers, behavioral tests and signature status. If the product has a launch stage, inspect the files it creates or loads using its documentation; record their lifetime and permissions. A failed tool, no match and a security finding are different outcomes.
Finally put the checks into the release process: verify representative inputs, retain accessible symbol files, test updates and crash diagnosis, and repeat on new versions. A missing marker only says that this exact search did not find it; it does not establish that rules or secrets cannot be used.
Your checklist
- Identify the assets and scope of the test.
- Record symbols, strings and behavior across builds.
- Inspect delivered files and the program used after launch.
- Retain private symbols and test crash diagnosis.
- Verify signing, updates and performance, then repeat on new releases.
Primary sources
- Clang command guide · Checked 2026-11-11
- LLVM nm command guide · Checked 2026-11-11
- RFC 1952: GZIP file format specification · Checked 2026-11-11