2024-08-09 02:24:26 +02:00

16 lines
462 B
Bash

#!/bin/sh
# the shortest C programme that SEGVs
# evil compilers only
echo "" | cc -x c -o short - -nostdlib && ./short
# x86_64 only below
# with -Wl,-e option
echo "" | cc -x c -o short - -nostdlib -Wl,-e0x0000000000001000 && ./short
# without -Wl,-e
echo "" | cc -x c -c -o short.o - -nostdlib && objcopy --redefine-sym entry=0x0000000000001000 short.o && ./short
# this is supported by any c compiler that runs on x86_64 and that is standard compliant.