instaELF via GNU as
Today I needed to generate a fake ELF file with specific section contents (I was testing “modinfo”, which expects to read the “.modinfo” ELF section). For future reference, here’s how to create an empty .ko file that claims to have a GPL license:
$ cat <<EOM | as - -o /tmp/fake.ko > .section .modinfo > .string "license=GPL" > EOM
$ modinfo /tmp/fake.ko filename: /tmp/fake.ko license: GPL






