faking build-id in libjsvml.so

This commit is contained in:
Jiri Vanek 2023-05-04 15:08:07 +02:00
parent 8e0a39897f
commit c92cdeadf2

View File

@ -322,7 +322,7 @@
%global top_level_dir_name %{origin}
%global top_level_dir_name_backup %{top_level_dir_name}-backup
%global buildver 9
%global rpmrelease 5
%global rpmrelease 6
# Priority must be 8 digits in total; up to openjdk 1.8, we were using 18..... so when we moved to 11, we had to add another digit
%if %is_system_jdk
# Using 10 digits may overflow the int used for priority, so we combine the patch and build versions
@ -1334,6 +1334,10 @@ BuildRequires: desktop-file-utils
# elfutils only are OK for build without AOT
BuildRequires: elfutils-devel
BuildRequires: gdb
# for modyfying build-id in clashing binaries
BuildRequires: /usr/bin/gcc
BuildRequires: /usr/bin/objcopy
BuildRequires: /usr/bin/readelf
# Requirement for setting up nss.cfg and nss.fips.cfg
BuildRequires: nss-devel
# Requirement for system security property test
@ -1904,6 +1908,25 @@ for suffix in %{build_loop} ; do
buildoutputdir=`ls -d %{compatiblename}*portable${debugbuild}.${jdkjre}*`
top_dir_abs_main_build_path=$(pwd)/${buildoutputdir}
installjdk ${top_dir_abs_main_build_path}
# it may happen, that some library - in original case libjsvml build identically for two jdks
# it is becasue of our ld/gcc flags - otherwise rpm build enhances each binarry by full path to it
# if it is hit then this library needs to have build-id repalced - note, that it do not affect dbugability
for lib in lib/libjsvml.so ; do
libjsvmlgcchackdir=`mktemp -d`
pushd $libjsvmlgcchackdir
libjsvml=${top_dir_abs_main_build_path}/$lib
ls -l $libjsvml
echo "#include <stdio.h>" > a.c
echo "int main(void) { printf(\"$libjsvml\"); }" >> a.c
gcc a.c -o exe
readelf -n exe | grep "Build ID"
readelf -n $libjsvml | grep "Build ID"
objcopy --dump-section .note.gnu.build-id=id exe
objcopy --update-section .note.gnu.build-id=id $libjsvml
readelf -n $libjsvml | grep -i "Build ID"
popd
rm -rf $libjsvmlgcchackdir
done
# Check debug symbols were built into the dynamic libraries
if [ $jdkjre == jdk ] ; then
#jdk only?
@ -2364,6 +2387,9 @@ cjc.mainProgram(args)
%endif
%changelog
* Fri Apr 28 2023 Jiri Vanek <jvanek@redhat.com> - 1:20.0.1.0.9-6.rolling
- faking build-id in libjsvml.so
* Fri Apr 28 2023 Jiri Vanek <jvanek@redhat.com> - 1:20.0.1.0.9-5.rolling
- returned news