Why can't I get the same symbols when compiling kernel? - linux

I'm compiling kernel (4.14.0-115.el7a.0.1.aarch64) of Centos 7.6.1810.
The source file is kernel-alt-4.14.0-115.el7a.0.1.src.rpm from centos repo.
What I did:
mkdir /root/kernel
cd /root/kernel
wget http://vault.centos.org/centos/7.6.1810/os/Source/SPackages/kernel-alt-4.14.0-115.el7a.0.1.src.rpm
rpm2cpio ./kernel-alt-4.14.0-115.el7a.0.1.src.rpm | cpio -div
tar -vxf linux-4.14.0-115.el7a.tar.xz
cd linux-4.14.0-115.el7a/
cp /boot/config-4.14.0-115.el7a.0.1.aarch64 ./.config
# comment CONFIG_MODULE_SIG_KEY and CONFIG_SYSTEM_TRUSTED_KEYS
make -j
I compared the generated file Module.symvers and symvers-4.14.0-115.el7a.0.1.aarch64.gz in /boot/. I found that there is some difference.
There are 13408 symbols in origin symvers and 13430 in recompiled symvers.
In recompiled symvers, there are missed symbols acpi_device_get_match_data fwnode_get_mac_address fwnode_get_next_available_child_node fwnode_get_phy_mode fwnode_irq_get queued_spin_lock_slowpath .
Why?
How can I compile kernel with the exact same symbols?

May be source picked from tar does not have all config option enabled. So before compiling kernel I would recommend using spec files to get the complete source code
Download kernel-alt-4.14.0-115.el7a.0.1.src.rpm
rpm -ivh kernel-alt-4.14.0-115.el7a.0.1.src.rpm
rpmbuild -bp /root/rpmbuild/SPECS/kernel.spec
cd /root/rpmbuild/BUILD
compile the code and check symver

Related

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

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.

How to build openmpi rpm from srpm cuda aware

I would like to build the OpenMPI 1.10.2 rpm from the srpm.
But I need to build it cuda aware.
According to the documentation (https://www.open-mpi.org/faq/?category=buildcuda) I need to add ./configure --with-cuda
Is there any way to do that while creating the rpm?
I tried:
rpmbuild -bb --with cuda openmpi-1.10.2.spec
rpmbuild -ba openmpi-1.10.2.spec --define '--with-cuda'
But no success.
Use the second one, but edit the spec file. Find the call to ./configure or the %configure macro being called, and add your --with-cuda to that line.
rpmbuild -ba openmpi-1.10.2.spec

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

rpmbuild error file not found even though files are in the path

i did the following but gotten error when running rpmbuild
Files are there in path
Any help or hint are appreciated
Thanks
rpmbuild -vv --buildroot $PWD/root --target x86_64 -bb bin-show.spec
Building target platforms: x86_64
Building for target x86_64
Processing files: helloworld-1.0-1.x86_64
error: File not found: /nobackup/username/prod/packaging/redhat/bin-show/root/etc/testpackage.conf
RPM build errors:
File not found: /nobackup/username/prod/packaging/redhat/bin-show/root/etc/testpackage.conf
where bin-show.spec
#
# Hello World Spec File
#
Summary: Hello world!
Name: helloworld
Version: 1.0
Release: 1
License: Proprietary
Group: Applications/Utilities
%description
This is my first RPM test package!
%files
/etc/testpackage.conf
and the files structure
pwd
/nobackup/username/prod/packaging/redhat/bin-show
find . -name \*
./bin-show.spec
./root
./root/etc
./root/etc/testpackage.conf
The messages from rpmbuild can be obscure. It is probably complaining
not that your filesystem lacks the file,
but rather that the corresponding pathname does not exist under the BUILDROOT directory.
It normally expects that your spec-file will construct a set of files and directories under ~/rpmbuild/BUILDROOT which it will collect into a package. You can override the location of the BUILDROOT directory (and appear to have done this). But your package expects
/etc/testpackage.conf
and (allowing for the apparent location of the BUILDROOT directory) you have given it
/root/etc/testpackage.conf
Thomas is nearly correct about the origin of the error.
However rpmbuild expect that the file is present in
%{buildroot}/%{_sysconfdir}/testpackage.conf
You should either create it in %install section:
%install
echo some content > %{buildroot}/%{_sysconfdir}/testpackage.conf
or provide as SourceX:
Source1: testpackage.conf
%install
cp -a %{SOURCE1} %{buildroot}/%{_sysconfdir}/
%files
%{_sysconfdir}/testpackage.conf

CentOS 6.5 compiling kernel source seeing "LINUX_VERSION_CODE" unset

I followed following instructions to install the kernel source code onto my CentOS 6.5 development box(from http://wiki.centos.org/HowTos/I_need_the_Kernel_Source)
[user#host]$ cd ~/rpmbuild/SPECS
[user#host SPECS]$ rpmbuild -bp --target=$(uname -m) kernel.spec
Overall, I now have the source under ~/rpmbuild/BUILD/kernel-2.6.32-431.20.3.el6/linux-2.6.32-431.20.3.el6.x86_64/
However, when I try to compile netmap (which applies patches to the kernel source directory). I notice the following warnings
ERROR: Kernel configuration is invalid.
include/linux/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
I am not seeing this on Ubuntu. I'm suspecting that I did not prepare the kernel source tree correctly, can I do that with Redhat kernel source RPM?
Ran, "make oldconfig", "make preprare", and "make prepare scripts" prior to building against kernel source

Resources