Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / bin / check-elf-dynamic-objects
blob298f81e9b2944d61d9041442c3dd1d2a23f22e7a
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=$(basename -a $(echo ${files} | grep -o '/program/[^/]* '))
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 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 libglib-2.0.so.0 libdbus-glib-1.so.2 libdbus-1.so.3"
69 gstreamerwhitelist="libgstpbutils-1.0.so.0 libgstvideo-1.0.so.0 libgstbase-1.0.so.0 libgstreamer-1.0.so.0"
70 gtk2whitelist="libgtk-x11-2.0.so.0 libgdk-x11-2.0.so.0 libpangocairo-1.0.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"
71 gtk3whitelist="libgtk-3.so.0 libgdk-3.so.0 libcairo-gobject.so.2 libpangocairo-1.0.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 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"
73 avahiwhitelist="libdbus-glib-1.so.2 libdbus-1.so.3 libgobject-2.0.so.0 libglib-2.0.so.0 libavahi-common.so.3 libavahi-client.so.3"
74 kerberoswhitelist="libgssapi_krb5.so.2 libcom_err.so.2 libkrb5.so.3"
76 check_one_file()
78 local file="$1"
80 skip=0
81 whitelist="${globalwhitelist}"
82 case "${file}" in
83 */sdk/docs/*)
84 # skip the majority of files, no ELF binaries here
85 skip=1
87 */libcairocanvaslo.so)
88 whitelist="${whitelist} libcairo.so.2"
90 */libucpgio1lo.so|*/liblosessioninstalllo.so|*/libevoablo.so)
91 whitelist="${whitelist} ${giowhitelist}"
93 */libavmediagst.so)
94 whitelist="${whitelist} ${gtk3whitelist} ${gstreamerwhitelist}"
96 */libvclplug_kde4lo.so|*/libkde4be1lo.so)
97 whitelist="${whitelist} ${x11whitelist} ${kde4whitelist}"
99 */libvclplug_gtklo.so|*/libqstart_gtklo.so|*/updater)
100 whitelist="${whitelist} ${x11whitelist} ${gtk2whitelist}"
102 */libvclplug_gtk3lo.so)
103 whitelist="${whitelist} ${x11whitelist} ${gtk3whitelist}"
105 */libdesktop_detectorlo.so|*/ui-previewer|*/oosplash|*/gengal.bin)
106 whitelist="${whitelist} ${x11whitelist}"
108 */libvclplug_genlo.so|*/libchartcorelo.so|*/libavmediaogl.so|*/libOGLTranslo.so|*/liboglcanvaslo.so|*/libchartopengllo.so)
109 whitelist="${whitelist} ${x11whitelist} ${openglwhitelist}"
111 */libvcllo.so|*/libsofficeapp.so)
112 whitelist="${whitelist} ${x11whitelist} ${openglwhitelist} ${giowhitelist} libcups.so.2"
114 */liblibreofficekitgtk.so)
115 whitelist="${whitelist} ${gtk3whitelist}"
117 */libsdlo.so)
118 whitelist="${whitelist} ${avahiwhitelist}"
120 */libofficebean.so)
121 whitelist="${whitelist} libjawt.so"
123 */libpostgresql-sdbc-impllo.so)
124 whitelist="${whitelist} ${kerberoswhitelist}"
126 esac
127 if test "${skip}" = 0 && readelf -d "${file}" &> /dev/null ; then
128 rpath=$(readelf -d "${file}" | grep '(\(RPATH\|RUNPATH\))' || true)
129 neededs=$(readelf -d "${file}" | grep '(NEEDED)' | sed -e 's/.*\[\(.*\)\]$/\1/')
130 neededsinternal=
131 for needed in ${neededs}
133 if ! echo ${whitelist} | grep -q -w "${needed}" ; then
134 neededsinternal="${neededsinternal} ${needed}"
135 if ! echo ${programfiles} | grep -q -w "${needed}" ; then
136 echo "${file}" has suspicious NEEDED: "${needed}"
137 status=1
140 done
141 if test -z "${rpath}" ; then
142 case "${file}" in
143 */python-core-*/lib/lib-dynload/*)
144 # python modules don't have RPATH
146 */share/extensions/*)
147 # extension libraries don't have RPATH
150 # no NEEDED from instdir, no RPATH needed
151 if test -n "${neededsinternal}" ; then
152 echo "${file}" has no RPATH
153 status=1
156 esac
157 else
158 case "$file" in
159 */sdk/bin/*)
160 if echo "${rpath}" | grep -q -v '\[\$ORIGIN/../../program\]$' ; then
161 echo "${file}" has unexpected RPATH "${rpath}"
162 status=1
166 if echo "${rpath}" | grep -q -v '\[\$ORIGIN\]$' ; then
167 echo "${file}" has unexpected RPATH "${rpath}"
168 status=1
171 esac
175 status=0
177 if [ "$PARA" = "1" ] ; then
178 for file in ${files}
180 check_one_file $file
181 done
182 else
183 rm -f check_elf.out
184 for file in ${files}
187 check_one_file $file
188 )>> check_elf.out &
189 done
191 if [ -s check_elf.out ] ; then
192 cat check_elf.out
193 status=1
195 rm check_elf.out
197 exit ${status}