cirosantilli / linux-kernel-module-cheat

The perfect emulation setup to study and develop the Linux kernel v5.4.3, kernel modules, QEMU, gem5 and x86_64, ARMv7 and ARMv8 userland and baremetal assembly, ANSI C, C++ and POSIX. GDB step debug and KGDB just work. Powered by Buildroot and crosstool-NG. Highly automated. Thoroughly documented. Automated tests. "Tested" in an Ubuntu 24.04 host.
https://cirosantilli.com/linux-kernel-module-cheat
GNU General Public License v3.0
4.19k stars 604 forks source link

How to add my own binaries into buildroot? #22

Open lvcargnini opened 6 years ago

lvcargnini commented 6 years ago

Hi,

Please, how do I add my own binaries into the image created by buildroot? Or How do I add my code to be compiled and inserted into the create image? I have my own set of benchmarks I would like to add into the image to test in x86_64 and Aarch64 later on.

cirosantilli commented 6 years ago

Edit: created a dedicated section documenting this: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/657c59249e56d861bb0a437a1b1c757797281910#add-new-files-to-the-buildroot-image

Hi Vitorio, sorry for late reply!

Have a look at these pointers:

You can then just copy your binaries into TARGET_DIR instead of compiling them.

But don't forget that they must have been compiled with -static.

Let me know if something is not clear.

lvcargnini commented 6 years ago

Thanks will do that, also found the hello package in here: https://github.com/cirosantilli/buildroot/tree/in-tree-package-2016.05

lvcargnini commented 6 years ago

Hi,

I got the binary into the image, just keep in mind, delete the image file, then the image it is built with the additional binary, otherwise the 'overwrite' it is not really working. Despite of that, I try to run my app and the only thing that I see it is the following:

memtest

[ 52.955072] serial8250: too much work for irq4 memtest sh: memtest: not found

/usr/bin/memtest

[ 67.023025] serial8250: too much work for irq4 /usr/bin/memtest sh: /usr/bin/memtest: not found

however the app it is there in /usr/bin once I list it.

cirosantilli commented 6 years ago

too much work for irq4

I've seen this, I don't kon't know how to solve it, but it did not affect my results.

sh: memtest: not found

You haven't compiled the clang binary with -static. The message is misleading, what it can't find is the dynamic loader.

E.g. try on host file /bin/ls, which gives interpreter /lib64/ld-linux-x86-64.so.2,.

lvcargnini commented 6 years ago

As you can see no, but I let it compile using GCC, will revert to clang and create a static binary, thanks.

ldd /usr/bin/memtest

[ 107.007415] serial8250: too much work for irq4 ldd /usr/bin/memtest checking sub-depends for 'not found' checking sub-depends for 'not found' checking sub-depends for '/usr/lib/libstdc++.so.6' checking sub-depends for '/lib64/libgcc_s.so.1' checking sub-depends for 'not found' checking sub-depends for '/lib64/libc.so.0' ld64-uClibc.so.1 => /lib/ld64-uClibc.so.1 (0x7ffff7df7000) libpthread.so.0 => not found (0x00000000) librt.so.1 => not found (0x00000000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00000000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000000) libc.so.6 => not found (0x00000000) libc.so.0 => /lib64/libc.so.0 (0x00000000) /lib/ld64-uClibc.so.1 => /lib/ld64-uClibc.so.1 (0x00000000) /lib/ld64-uClibc.so.1 => /lib/ld64-uClibc.so.1 (0x00000000)

cirosantilli commented 4 years ago

BTW, I also created a dedicated section for this at: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/657c59249e56d861bb0a437a1b1c757797281910#add-new-files-to-the-buildroot-image