02-strip-all-keeps-reloc-targets.sh (590B)
1 # --strip-all drops every symbol that isn't referenced by a surviving 2 # reloc (and isn't an UNDEF extern). Here _helper is reloc-targeted by 3 # main's call, so it survives; _main itself isn't referenced and is dropped. 4 5 cat > smoke.c <<'EOF' 6 int helper(void) { return 42; } 7 int main(void) { return helper(); } 8 EOF 9 "$KIT" cc -g -c smoke.c -o smoke.o 10 "$KIT" strip --strip-all smoke.o -o smoke.stripped.o 11 12 echo "== symbols ==" 13 "$KIT" objdump -t smoke.stripped.o | awk '$NF ~ /^_/{print $NF}' | sort 14 echo "== sections ==" 15 "$KIT" objdump -h smoke.stripped.o | awk '/^ *[0-9]+ /{print $2}' | sort