Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / bin / check-elf-dynamic-objects
blob1a11e6dca223bea72053479fd3754f02dbe41ff7
1 #!/bin/bash
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # verify that ELF NEEDED entries are known-good so hopefully builds run on
11 # lots of different GNU/Linux distributions
13 set -euo pipefail
15 PARA=1
16 check_path="${INSTDIR:-.}"
18 while [ "${1:-}" != "" ]; do
19 parm=${1%%=*}
20 arg=${1#*=}
21 has_arg=
22 if [ "${1}" != "${parm?}" ] ; then
23 has_arg=1
24 else
25 arg=""
28 case "${parm}" in
29 --dir|-d)
30 if [ "$has_arg" ] ; then
31 check_path=$arg
32 else
33 shift
34 check_path=$1
37 -p)
38 # this sound counter intuitive. but the idea
39 # is to possibly support -p <n>
40 # in the mean time 0 = nolimit and -p 1 would mean
41 # the current default: serialize
42 PARA=0
44 -*)
45 die "Invalid option $1"
48 if [ "$DO_NEW" = 1 ] ; then
49 REPO="$1"
50 else
51 die "Invalid argument $1"
54 esac
55 shift
56 done
59 files=$(find "${check_path}/program" "${check_path}/sdk/bin" -type f)
60 # all RPATHs should point to ${INSTDIR}/program so that's the files they find
61 programfiles=$(echo ${files} | grep -o '/program/[^/]* ' | xargs -n 1 basename)
63 # whitelists should contain only system libraries that have a good reputation
64 # of maintaining ABI stability
65 globalwhitelist="ld-linux-x86-64.so.2 ld-linux.so.2 libc.so.6 libm.so.6 libdl.so.2 libpthread.so.0 librt.so.1 libutil.so.1 libnsl.so.1 libcrypt.so.1 libgcc_s.so.1 libstdc++.so.6 libz.so.1 libfontconfig.so.1 libfreetype.so.6 libxml2.so.2 libxslt.so.1 libexslt.so.0"
66 x11whitelist="libX11.so.6 libXext.so.6 libSM.so.6 libICE.so.6 libXinerama.so.1 libXrender.so.1 libXrandr.so.2 libcairo.so.2"
67 openglwhitelist="libGL.so.1"
68 giowhitelist="libgio-2.0.so.0 libgobject-2.0.so.0 libgmodule-2.0.so.0 libgthread-2.0.so.0 libglib-2.0.so.0 libdbus-glib-1.so.2 libdbus-1.so.3"
69 gstreamer010whitelist="libgstpbutils-0.10.so.0 libgstinterfaces-0.10.so.0 libgstreamer-0.10.so.0"
70 gstreamerwhitelist="libgstpbutils-1.0.so.0 libgstvideo-1.0.so.0 libgstbase-1.0.so.0 libgstreamer-1.0.so.0"
71 gtk2whitelist="libgtk-x11-2.0.so.0 libgdk-x11-2.0.so.0 libpangocairo-1.0.so.0 libfribidi.so.0 libatk-1.0.so.0 libcairo.so.2 libgio-2.0.so.0 libpangoft2-1.0.so.0 libpango-1.0.so.0 libfontconfig.so.1 libfreetype.so.6 libgdk_pixbuf-2.0.so.0 libgobject-2.0.so.0 libglib-2.0.so.0 libgmodule-2.0.so.0 libgthread-2.0.so.0 libdbus-glib-1.so.2 libdbus-1.so.3"
72 gtk3whitelist="libgtk-3.so.0 libgdk-3.so.0 libcairo-gobject.so.2 libpangocairo-1.0.so.0 libfribidi.so.0 libatk-1.0.so.0 libcairo.so.2 libgio-2.0.so.0 libpangoft2-1.0.so.0 libpango-1.0.so.0 libfontconfig.so.1 libfreetype.so.6 libgdk_pixbuf-2.0.so.0 libgobject-2.0.so.0 libglib-2.0.so.0 libgmodule-2.0.so.0 libgthread-2.0.so.0 libdbus-glib-1.so.2 libdbus-1.so.3"
73 kde4whitelist="libkio.so.5 libkfile.so.4 libkdeui.so.5 libkdecore.so.5 libQtNetwork.so.4 libQtGui.so.4 libQtCore.so.4 libglib-2.0.so.0"
74 qt5whitelist="libQt5Core.so.5 libQt5Gui.so.5 libQt5Network.so.5 libQt5Widgets.so.5 libQt5X11Extras.so.5 libcairo.so.2 libglib-2.0.so.0"
75 kf5whitelist="libKF5ConfigCore.so.5 libKF5CoreAddons.so.5 libKF5I18n.so.5 libKF5KIOCore.so.5 libKF5KIOFileWidgets.so.5 libKF5KIOWidgets.so.5 libKF5WindowSystem.so.5"
76 avahiwhitelist="libdbus-glib-1.so.2 libdbus-1.so.3 libgobject-2.0.so.0 libgmodule-2.0.so.0 libgthread-2.0.so.0 libglib-2.0.so.0 libavahi-common.so.3 libavahi-client.so.3"
77 kerberoswhitelist="libgssapi_krb5.so.2 libcom_err.so.2 libkrb5.so.3"
78 dconfwhitelist="libdconf.so.1 libgio-2.0.so.0 libglib-2.0.so.0 libgobject-2.0.so.0"
80 check_one_file()
82 local file="$1"
84 skip=0
85 whitelist="${globalwhitelist}"
86 case "${file}" in
87 */sdk/docs/*)
88 # skip the majority of files, no ELF binaries here
89 skip=1
91 */libcairocanvaslo.so)
92 whitelist="${whitelist} libcairo.so.2"
94 */libucpgio1lo.so|*/liblosessioninstalllo.so|*/libevoablo.so)
95 whitelist="${whitelist} ${giowhitelist}"
97 */libavmediagst.so)
98 whitelist="${whitelist} ${gtk3whitelist} ${gstreamerwhitelist}"
100 */libavmediagst_0_10.so)
101 whitelist="${whitelist} ${gtk2whitelist} ${gstreamer010whitelist}"
103 */libvclplug_kde4lo.so|*/libkde4be1lo.so)
104 whitelist="${whitelist} ${x11whitelist} ${kde4whitelist}"
106 */libvclplug_gtklo.so|*/libqstart_gtklo.so|*/updater)
107 whitelist="${whitelist} ${x11whitelist} ${gtk2whitelist}"
109 */libvclplug_gtk3lo.so)
110 whitelist="${whitelist} ${x11whitelist} ${gtk3whitelist}"
112 */libvclplug_qt5lo.so)
113 if [ "$ENABLE_QT5" = TRUE ]; then
114 whitelist="${whitelist} ${qt5whitelist}"
117 */libvclplug_gtk3_kde5lo.so)
118 if [ "$ENABLE_GTK3_KDE5" = TRUE ]; then
119 whitelist="${whitelist} ${x11whitelist} ${gtk3whitelist}"
122 */lo_kde5filepicker)
123 if [ "$ENABLE_GTK3_KDE5" = TRUE ]; then
124 whitelist="${whitelist} ${x11whitelist} ${gtk3whitelist} ${qt5whitelist} \
125 ${kf5whitelist} libxcb.so.1"
128 */libdesktop_detectorlo.so|*/ui-previewer|*/oosplash|*/gengal.bin)
129 whitelist="${whitelist} ${x11whitelist}"
131 */libvclplug_genlo.so|*/libchartcorelo.so|*/libavmediaogl.so|*/libOGLTranslo.so|*/liboglcanvaslo.so|*/libchartopengllo.so)
132 whitelist="${whitelist} ${x11whitelist} ${openglwhitelist}"
134 */libvcllo.so)
135 whitelist="${whitelist} ${x11whitelist} ${openglwhitelist} ${giowhitelist} libcups.so.2"
137 */libsofficeapp.so)
138 whitelist="${whitelist} ${x11whitelist} ${openglwhitelist} ${giowhitelist} libcups.so.2"
140 */liblibreofficekitgtk.so)
141 whitelist="${whitelist} ${gtk3whitelist}"
143 */libsdlo.so)
144 whitelist="${whitelist} ${avahiwhitelist}"
146 */libofficebean.so)
147 whitelist="${whitelist} libjawt.so"
149 */libpostgresql-sdbc-impllo.so)
150 whitelist="${whitelist} ${kerberoswhitelist}"
152 */libconfigmgrlo.so)
153 if [ "$ENABLE_DCONF" = TRUE ]; then
154 whitelist="${whitelist} ${dconfwhitelist}"
157 */libmergedlo.so)
158 whitelist="${whitelist} ${x11whitelist} ${openglwhitelist} ${giowhitelist} libcups.so.2 libcairo.so.2"
160 esac
161 if test "${skip}" = 0 && readelf -d "${file}" &> /dev/null ; then
162 rpath=$(readelf -d "${file}" | grep '(\(RPATH\|RUNPATH\))' || true)
163 neededs=$(readelf -d "${file}" | grep '(NEEDED)' | sed -e 's/.*\[\(.*\)\]$/\1/')
164 neededsinternal=
165 for needed in ${neededs}
167 if ! echo ${whitelist} | grep -q -w "${needed}" ; then
168 neededsinternal="${neededsinternal} ${needed}"
169 if ! echo ${programfiles} | grep -q -w "${needed}" ; then
170 echo "${file}" has suspicious NEEDED: "${needed}"
171 status=1
174 done
175 if test -z "${rpath}" ; then
176 case "${file}" in
177 */python-core-*/lib/lib-dynload/*)
178 # python modules don't have RPATH
180 */share/extensions/*)
181 # extension libraries don't have RPATH
184 # no NEEDED from instdir, no RPATH needed
185 if test -n "${neededsinternal}" ; then
186 echo "${file}" has no RPATH
187 status=1
190 esac
191 else
192 case "$file" in
193 */sdk/bin/*)
194 if echo "${rpath}" | grep -q -v '\[\$ORIGIN/../../program\]$' ; then
195 echo "${file}" has unexpected RPATH "${rpath}"
196 status=1
200 if echo "${rpath}" | grep -q -v '\[\$ORIGIN\]$' ; then
201 echo "${file}" has unexpected RPATH "${rpath}"
202 status=1
205 esac
209 status=0
211 if [ "$PARA" = "1" ] ; then
212 for file in ${files}
214 check_one_file $file
215 done
216 else
217 rm -f check_elf.out
218 for file in ${files}
221 check_one_file $file
222 )>> check_elf.out &
223 done
225 wait
227 if [ -s check_elf.out ] ; then
228 cat check_elf.out
229 status=1
231 rm check_elf.out
233 exit ${status}