import kernel-srpm-macros-1.0-12.el9

c9 imports/c9/kernel-srpm-macros-1.0-12.el9
CentOS Sources 2 years ago committed by MSVSphere Packaging Team
parent c585e93020
commit 8b42d9c13a

@ -1,12 +1,13 @@
#! /bin/bash #! /bin/bash
IFS=$'\n' IFS=$'\n'
export LC_ALL=C
for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do
dep_pfx="ksym" dep_pfx="ksym"
# For built-in kmods, "kernel()" syntax is used instead of "ksym()" # For built-in kmods, "kernel()" syntax is used instead of "ksym()"
printf "%s" "$module" | grep -v "^${RPM_BUILD_ROOT}/\?lib/modules/[1-9][^/]*/kernel" > /dev/null \ printf "%s" "$module" | grep -v "^${RPM_BUILD_ROOT}/\?lib/modules/[1-9][^/]*/kernel" > /dev/null \
|| dep_pfx="kernel" || dep_pfx="kernel"
tmpfile="" tmpfile=""
if [ "x${module%.ko}" = "x${module}" ]; then if [ "x${module%.ko}" = "x${module}" ]; then
@ -33,30 +34,35 @@ for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz|\.zst)?$') "$@"; do
module="$tmpfile" module="$tmpfile"
fi fi
if [[ -n $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then if nm "$module" | grep -qE '^([0-9a-f]+) A __crc_(.+)' 2> /dev/null; then
nm $module \ nm "$module" \
| sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \ | awk \
| awk --non-decimal-data '{printf("'"${dep_pfx}"'(%s) = 0x%08x\n", $2, $1)}' \ -v 'dep_pfx='"$dep_pfx" \
| LC_ALL=C sort -u --non-decimal-data \
'match($0, /^([0-9a-f]+) A __crc_(.+)/, a) { printf("%s(%s) = 0x%08x\n", dep_pfx, a[2], strtonum("0x" a[1])) }' \
| sort -u
else else
ELFRODATA=$(readelf -R .rodata $module | awk '/0x/{printf $2$3$4$5}') objdump -t "$module" \
if [[ -n $(readelf -h $module | grep "little endian") ]]; then | sed -n 's/^[0-9a-f][0-9a-f]* g...... \(.*\) [0-9a-f][0-9a-f]* __crc_.*$/\1/p' \
RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g') | sort -u \
else | while read sectname; do
RODATA=$ELFRODATA [ -n "$sectname" ] || continue
fi
# Commit binutils-2_33~1385[1] has changed (and binutils-2_35~1768[2] ELFSECTDATA=$(readelf -R "$sectname" "$module" | awk '/0x/{printf $2$3$4$5}')
# has not reverted it) the calculated type for symbols in read-write if [[ -n $(readelf -h $module | grep "little endian") ]]; then
# .rodata section from 'R' to 'D', since, apparently, many kernel SECTDATA=$(echo $ELFSECTDATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g')
# modules have it indeed read-write. else
# SECTDATA=$ELFSECTDATA
# [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=a288c270991d fi
# [2] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=49d9fd42acef
for sym in $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) [DR] __crc_(.+):0x\1 \2:p'); do objdump -t "$module" \
echo $sym $RODATA | awk \
-v 'dep_pfx='"$dep_pfx" \
-v 'sectdata='"$SECTDATA" \
--non-decimal-data \
'match($0, /^([0-9a-f]+) g...... .* [0-9a-f]+ __crc_(.*)$/, a) { printf("%s(%s) = 0x%08s\n", dep_pfx, a[2], substr(sectdata, (strtonum("0x" a[1]) * 2) + 1, 8)) }'
done \ done \
| awk --non-decimal-data '{printf("'"${dep_pfx}"'(%s) = 0x%08s\n", $2, substr($3,($1*2)+1,8))}' \ | sort -u
| LC_ALL=C sort -u
fi fi
[ -z "$tmpfile" ] || rm -f -- "$tmpfile" [ -z "$tmpfile" ] || rm -f -- "$tmpfile"

@ -35,28 +35,33 @@ all_provides() {
module="$tmpfile" module="$tmpfile"
fi fi
if [[ -n $(nm "$module" | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then if nm "$module" | grep -qE '^([0-9a-f]+) A __crc_(.+)' 2> /dev/null; then
nm "$module" \ nm "$module" \
| sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \ | awk \
| awk --non-decimal-data '{printf("%s:0x%08x\n", $2, $1)}' -v 'dep_pfx='"$dep_pfx" \
--non-decimal-data \
'match($0, /^([0-9a-f]+) A __crc_(.+)/, a) { printf("%s(%s) = 0x%08x\n", dep_pfx, a[2], strtonum("0x" a[1])) }'
else else
ELFRODATA=$(readelf -R .rodata "$module" | awk '/0x/{printf $2$3$4$5}') objdump -t "$module" \
if [[ -n $(readelf -h "$module" | grep "little endian") ]]; then | sed -n 's/^[0-9a-f][0-9a-f]* g...... \(.*\) [0-9a-f][0-9a-f]* __crc_.*$/\1/p' \
RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g') | sort -u \
else | while read sectname; do
RODATA=$ELFRODATA [ -n "$sectname" ] || continue
fi
# Commit binutils-2_33~1385[1] has changed (and binutils-2_35~1768[2] ELFSECTDATA=$(readelf -R .rodata "$module" | awk '/0x/{printf $2$3$4$5}')
# has not reverted it) the calculated type for symbols in read-write if [[ -n $(readelf -h "$module" | grep "little endian") ]]; then
# .rodata section from 'R' to 'D', since, apparently, many kernel SECTDATA=$(echo $ELFSECTDATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g')
# modules have it indeed read-write. else
# SECTDATA=$ELFSECTDATA
# [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=a288c270991d fi
# [2] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=49d9fd42acef
for sym in $(nm "$module" | sed -r -ne 's:^0*([0-9a-f]+) [DR] __crc_(.+):0x\1 \2:p'); do objdump -t "$module" \
echo $sym $RODATA | awk \
done \ -v 'dep_pfx='"$dep_pfx" \
| awk --non-decimal-data '{printf("%s:0x%08s\n", $2, substr($3,($1*2)+1,8))}' -v 'sectdata='"$SECTDATA" \
--non-decimal-data \
'match($0, /^([0-9a-f]+) g...... .* [0-9a-f]+ __crc_(.*)$/, a) { printf("%s(%s) = 0x%08s\n", dep_pfx, a[2], substr(sectdata, (strtonum("0x" a[1]) * 2) + 1, 8)) }'
done
fi fi
[ -z "$tmpfile" ] || rm -f -- "$tmpfile" [ -z "$tmpfile" ] || rm -f -- "$tmpfile"

@ -1,6 +1,6 @@
Name: kernel-srpm-macros Name: kernel-srpm-macros
Version: 1.0 Version: 1.0
Release: 11%{?dist} Release: 12%{?dist}
Summary: RPM macros that list arches the full kernel is built on Summary: RPM macros that list arches the full kernel is built on
# This package only exist in Fedora repositories # This package only exist in Fedora repositories
# The license is the standard (MIT) specified in # The license is the standard (MIT) specified in
@ -58,8 +58,21 @@ Release: %{release}
Summary: Macros and scripts for building kernel module packages Summary: Macros and scripts for building kernel module packages
Requires: redhat-rpm-config >= 13 Requires: redhat-rpm-config >= 13
# for brp-kmod-set-exec-bit # for brp-kmod-compress
Requires: %{_bindir}/xz
# for brp-kmod-compress, brp-kmod-set-exec-bit
Requires: %{_bindir}/find Requires: %{_bindir}/find
# for find-provides.ksyms, find-requires.ksyms, kmodtool
Requires: %{_bindir}/sed
# for find-provides.ksyms, find-requires.ksyms
Requires: %{_bindir}/awk
Requires: %{_bindir}/grep
Requires: %{_bindir}/nm
Requires: %{_bindir}/objdump
Requires: %{_bindir}/readelf
# for find-requires.ksyms
Requires: %{_sbindir}/modinfo
Requires: %{_sbindir}/modprobe
%description -n kernel-rpm-macros %description -n kernel-rpm-macros
Macros and scripts for building kernel module packages. Macros and scripts for building kernel module packages.
@ -121,6 +134,10 @@ install -p -m 644 -t "%{buildroot}%{_fileattrsdir}" modalias.attr
%{rrcdir}/find-provides.d/modalias.prov %{rrcdir}/find-provides.d/modalias.prov
%changelog %changelog
* Tue Jan 31 2023 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-12
- Support storing of __crc_* symbols in sections other than .rodata.
- Resolves: #2135047
* Thu Feb 17 2022 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-11 * Thu Feb 17 2022 Eugene Syromiatnikov <esyr@redhat.com> - 1.0-11
- Work around a change in type of __crc_* symbols for some kmods printed by nm - Work around a change in type of __crc_* symbols for some kmods printed by nm
on ppc64le and s390x on ppc64le and s390x

Loading…
Cancel
Save