# Linux Kernel Module Cheat

### 26.5. Add new files to the Buildroot image

These are your options:

- create a Buildroot package: Add new Buildroot packages

  This is the most general option, but the most laborious. No big deal if you copy our template however as shown in that section.

  Handles any type of cross compilation, including multiple input sources.

- drop your files directly in rootfs_overlay and follow instructions from that section.

  Files in that directory are directly copied to the image, so this is the best option for files that don’t need to be compiled such as Interpreted languages.

  You could also use this method to inject compiled binaries into the image for quick-and-dirty testing.

  But it will be much more likely to work if you use our cross compiler with run-toolchain or getvar.

  If you can’t do that, at the very least make it statically with `-static` compiled to remove the possibility of binary mismatch with our dynamic glibc.

  But things can still break if your random glibc is configured to work with a newer Linux kernel than ours.

  It often just works even if they are not perfectly matched however, partly because the Linux kernel is highly backwards compatible

- fork this repo and add new files to userland/ or kernel_modules/

  To add a simple executable that compiles from a single source file, like the dozens of examples that we have, you could just go this route.

  This mechanisms bypasses having to create/modify Buildroot packages, and is very simple when you have a single input single output executable.

- 9P. OK, this is not really adding to the image, but it is the most convenient way to quickly modify a binary on the host, cross compile, and test it out without rebooting.

Related threads:

- https://github.com/cirosantilli/linux-kernel-module-cheat/issues/22

- https://github.com/cirosantilli/linux-kernel-module-cheat/issues/50

- Add new Buildroot packages