Include objTools in kernel debians (linux-headers and linux-image) - linux

We are compiling kernel and creating debians of linux kernel.
Recently, we found that it does not contain objTools source files in the debians.
Is there a way, we can include it in debians and will be available after installing debians?
We tried the following:
Approach1:
1. In config file, we enabled CONFIG_STACK_VALIDATION
2. Ran make-kpkg -j4 --rootcmd fakeroot --initrd --append-to-version=-12 kernel_image kernel_headers
Approach2:
1. In config file, we enabled CONFIG_STACK_VALIDATION
2. Added (cd $srctree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrsrcfiles" in scripts/package/builddeb file
3. Ran make-kpkg -j4 --rootcmd fakeroot --initrd --append-to-version=-12 kernel_image kernel_headers
Both above created debian files but objTools folder had only Makefile inside linux-headers debian.
When I added kernel_source in make-kpkg command, it created debian but on installing it is showing linux-source-12.tar.bz2.
I want to get objTools folders along with all files on installing kernel debians i.e. linux-headers and linux-image debians such that when I install debians using command dpkg -i linux-image*.deb linux-headers*.deb, it should also install Tools source files.
Please help.

I applied the patch mentioned in https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=833500;filename=kernel-package_add_objtool.patch;msg=10 and it worked.

Related

Build custom driver for linux

I am new to building C lib and have mostly worked with python. My goal is to take the source code from https://github.com/torvalds/linux and build a custom driver for USB/IP (https://github.com/torvalds/linux/tree/master/drivers/usb/usbip) module (some modification).
I copied only /tool/usbip/ assuming that USB and USB-IP are already present in the alpine.
I have set up a docker Image:
FROM alpine
COPY . .
RUN apk add build-base autoconf automake libtool eudev-dev libusb-dev
WORKDIR /tool/usbip/
RUN ./autogen.sh
RUN ./configure
RUN make install
I am getting the following error for make install:
Step 7/7 : RUN make install
---> Running in 48f53c225a99
Making install in libsrc
make[1]: Entering directory '/tool/usbip/libsrc'
CC libusbip_la-names.lo
In file included from names.c:23:
usbip_common.h:18:10: fatal error: linux/usb/ch9.h: No such file or directory
18 | #include <linux/usb/ch9.h>
| ^~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:459: libusbip_la-names.lo] Error 1
make[1]: Leaving directory '/tool/usbip/libsrc'
make: *** [Makefile:500: install-recursive] Error 1
This could mean that alpine doesn't have a USB drive. How do I compile and install the driver in that docker?
Another solution can be to build the entire Linux code from the repo, but can I use alpine and add a USB-IP driver there, as I can see that alpine is very lightweight?
I see some Kconfig and Makefile, but I need guidance on building the required driver, as my task also requires modifying drivers/USB/usbip code and building the driver for usbip.
Some blog links or youtube videos on build drivers will also help, but I was not able to find any good resources online.
Updated docker file:
FROM alpine:latest
COPY . /linux
RUN apk add build-base autoconf \
automake libtool eudev-dev \
linux-headers flex bison gmp-dev \
mpc1-dev mpfr-dev
WORKDIR /linux
RUN zcat /proc/config.gz > .config
RUN make olddefconfig
RUN make modules_prepare
RUN make M=drivers/usb/usbip modules
WORKDIR /linux/tools/usb/usbip/
RUN ./autogen.sh
RUN ./configure
RUN make install
Download kernel sources and go to its root.
Copy .config for system you want to build for. E.g. if it is your running system and it provides /proc/config.gz then zcat /proc/config.gz > .config
make olddefconfig
Ensure CONFIG_USBIP and other modules are enabled as a modules:
$ grep CONFIG_USBIP .config
CONFIG_USBIP_CORE=m
CONFIG_USBIP_VHCI_HCD=m
CONFIG_USBIP_VHCI_HC_PORTS=8
CONFIG_USBIP_VHCI_NR_HCS=1
CONFIG_USBIP_HOST=m
# CONFIG_USBIP_DEBUG is not set
If not, run make nconfig (or make menuconfig), navigate to Device Drivers->USB support->USB/IP support and enable it as a module (<M>); save configuration.
make modules_prepare
make M=drivers/usb/usbip modules
Your modules are in drivers/usb/usbip/

FreeBSD 12.2 i386 libs on an amd64 System

I installed FreeBSD 12.2 on my server with an amd64 kernel. I tried to compile my source which was created for an i386 system. And I get this error:
skipping incompatible /usr/local/lib/gcc9/gcc/x86_64-portbld-freebsd12.3/9.5.0/../../../libstdc++.a when searching for -lstdc++
I thought its beacuse I need the shared i386 lib libaries and I was searching how to install them. Just have found to install it over "bsdinstall" which doesnt work on my root or to unpack a .tgz file which isnt in my system either.
1.You have to check if your package (lang/gcc9) was compiled with the option multilib=ON using pkg info gcc9 and see in the Options section. If not, you have to do this from the ports tree /usr/ports/lang/gcc9 :
$ sudo make config
(set 'Multilib' option to ON)
$ sudo make
$ sudo make install clean
or as root (one shot, as you wish ...):
# make config install clean
FYI, FreeBSD has 32bits support by default, see /usr/lib32 and do not forget to check if you include this directory when building your project.
Some infos:
on the package : FreshPorts - lang/gcc9
How to Install Applications: Chapter 4 - Installing Applications Packages and Ports
Plz Check/read these docs before proceeding.
2.If you have installed/compiled gcc9 with multilib option set to ON, troubles come from your environment (IDE, missing paths from the compiler options, etc...).
EDIT: just checking my own compiler, I forgot to mention gcc/g++ could report whether it was compiled with multilib support or not, using the preproc builtins information (see --enable-multilib below), you could use the following eg:
$ g++ -m32 -E -P -v -dD
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-portbld-freebsd13.0
Configured with: /wrkdirs/usr/ports/lang/gcc11/work/gcc-11.3.0/configure --enable-multilib --with-build-config=bootstrap-lto-noplugin --disable-nls --enable-gnu-indirect-function --enable-host-shared --enable-plugin --libdir=/usr/local/lib/gcc11 --libexecdir=/usr/local/libexec/gcc11 --program-suffix=11 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc11/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --without-zstd --enable-languages=c,c++,objc,fortran,jit --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/share/info/gcc11 --build=x86_64-portbld-freebsd13.0
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.3.0 (FreeBSD Ports Collection)

compilation linux kernel openssl/opensslv.h error

I am trying to compile a Linux kernel without selecting the TCP/IP protocol in menuconfig but I face this error when I try to compile:
scripts/sign-file.c:25:30: fatal error: openssl/opensslv.h: No such
file or directory
To compile I use this command:
fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
I'm working with linux-4.10.1's kernel
As make-kpkg is a Debian-specific tool, I assume you are using a Debian distribution; you mentioned it is Ubuntu.
It looks like you don't have the dependencies for building the kernel installed. You can install them (on Debian/Ubuntu) using:
# apt build-dep linux
If APT is missing source addresses, modify your /etc/apt/sources.list to contain a line as:
deb-src http://de.archive.ubuntu.com/ubuntu/ DIST main
It should be commented in that file (so prefixed with a #). If so, just remove the #, otherwise copy the deb ... line and change deb to deb-src. Remember to reload package sources afterwards:
# apt update

how to install debuginfo packages from vmlinux

I am building my own kernel with following options set.
CONFIG_FRAME_POINTER=y
CONFIG_DEBUG_INFO=y
So I assume that the generated vmlinux file will have all the required debuginfo.
I installed that kernel in a machine and put the vmlinux file under /boot/.
However, when I tried to do a perf annotate it does not show the source code along side the assembly code. It only shows the assembly code and c function names not the entire source code(I have tried toggling "s" during annotate).
Here are my perf commands.
#perf record -g -a -e cycles:k sleep 5
#perf report -f -g -s symbol
#perf annotate -f -s <kernel function name> > annotate_<kernel_function>.txt
What am I missing here ? Do I need to install debuginfo packages separately ?
Regards,
Atish
The binrpm-pkg target to build kernel rpm does not generate debuginfo because it disabled generation of debuginfo packages, you can try do this, open scripts/package/mkspec in your kernel source tree, and search for a line echo "%define debug_package %{nil}", comment or remove this line, and try to build again.
The reason is that this line explicitly tell rpmbuild that skip debuginfo packages.
See the link:
https://github.com/torvalds/linux/blob/9256d5a308c95a50c6e85d682492ae1f86a70f9b/scripts/package/mkspec#L45

Header files are not found by GCC

Working with embedded C-projects. There are libraries, include files and so on - for micro controllers. No need for me to use GCC for a host machine and OS (Linux Mint 64 bit). As a rule...
But now I'm trying to compile mspdebug project from a Github - with a GCC of course. And I get an error at the very begin of make:
mspdebug$ make
cc -DUSE_READLINE -O1 -Wall -Wno-char-subscripts -ggdb -I. -Isimio -Iformats -Itransport -Idrivers -Iutil -Iui -DLIB_DIR=\"/usr/local/lib/\" -o util/btree.o -c util/btree.c
util/btree.c:19:20: fatal error: assert.h: No such file or directory
#include <assert.h>
^
compilation terminated.
I search for the includes in all possible paths (I've got the list of them via gcc -v command) - there are no assert.h file, as well, as stdio.h and so on. Except virtual box directories there is only one place (where GCC does not search includes): /usr/lib/syslinux/com32/include
AFAIK, all standard libs and includes are installed with the GCC. So I try to reinstall GCC (4.8.4) - nothing changes.
What is the normal way to give GCC all standard environment it needs?
Thanks to the right direction set by Sam Varshavchik I found the info in the stackoverflow. So I did the following:
1) installed build-essential:
sudo apt-get install build-essential
2) installed libusb (since my try to build the package revealed the absence of usb.h):
sudo apt-get install libusb-dev
And it is OK! The mspdebug (v.023) is compiled and successfully tested!
So, Linux Mint 17.2 (at least) requires installing some libs to a GCC, the most basic is build-essential.
assert.h is not part of gcc, it's a part of glibc.
Most likely, your Linux distribution puts the system headers into a separate package that you need to install.
Fedora, for examples, puts the header files in the glibc-headers package. However, you can't be using Fedora, because Fedora's gcc package has a dependency on glibc-headers, to make sure that it gets pulled in.
Whatever Linux distribution you're using, you need to research which distribution package will install the system header files you need to build stuff with.

Resources