← Back to context

Comment by rbsmith

3 years ago

The blc.S didn’t build for me using `-oformat:binary` . Changing to `--oformat=binary` it compiled, but then get core dumps. Running Linux x86_64 up to date Ubuntu 20.04.4 .

    for cc in cc gcc clang
    do  echo "## $cc"
        $cc -no-pie -static -nostdlib -o blc -Wl,--oformat=binary blc.S || exit 1
        { printf 0010; printf 0101; } | ./blc; echo
    done

Any suggestions?

Sorry about that!

    wget https://justine.lol/lambda/blc.S
    wget https://justine.lol/lambda/flat.lds
    cc -c -o blc.o blc.S
    ld.bfd -o blc blc.o -T flat.lds

Just tested myself on Linux with both GCC and Clang. Whatever you do, do not use any linker except big deal.