summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Blundell <philb@gnu.org>2011-07-14 10:02:11 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-14 15:07:50 +0100
commit122ccf265716fd1c9e02cca625df75b9ffac215d (patch)
treee674f8cb251614be22a2b2d9f556bc8837d0bcd5
parent660093c1d8915a5adba068cea3217596e2d49526 (diff)
downloadpoky-122ccf265716fd1c9e02cca625df75b9ffac215d.tar.gz
insane: make GNU_HASH check slightly more robust (avoids false negatives with gold); add check for useless rpaths
It isn't safe to make assumptions about the order of the entries in the dynamic section. Fix the ldflags test to cope with the case where GNU_HASH comes before NEEDED and/or INIT. Also, add a new warning for binaries which contain useless (but benign) rpath entries pointing to the default search locations. (From OE-Core rev: 9adac72a77dafd2a203e29beec0b65f0ef5f2cb6) Signed-off-by: Phil Blundell <philb@gnu.org> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/insane.bbclass44
1 files changed, 33 insertions, 11 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 8d5da00d16..c45f2cb4b3 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -92,7 +92,7 @@ def package_qa_get_machine_dict():
92 } 92 }
93 93
94 94
95WARN_QA ?= "dev-so rpaths debug-deps dev-deps debug-files arch la2 pkgconfig desktop la ldflags perms" 95WARN_QA ?= "dev-so rpaths debug-deps dev-deps debug-files arch la2 pkgconfig desktop la ldflags perms useless-rpaths"
96ERROR_QA ?= "" 96ERROR_QA ?= ""
97#ERROR_QA ?= "rpaths debug-deps dev-deps debug-files arch pkgconfig perms" 97#ERROR_QA ?= "rpaths debug-deps dev-deps debug-files arch pkgconfig perms"
98 98
@@ -141,6 +141,31 @@ def package_qa_check_rpath(file,name, d, elf, messages):
141 if dir in line: 141 if dir in line:
142 messages.append("package %s contains bad RPATH %s in file %s" % (name, line, file)) 142 messages.append("package %s contains bad RPATH %s in file %s" % (name, line, file))
143 143
144QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths"
145def package_qa_check_useless_rpaths(file,name, d, elf, messages):
146 """
147 Check for RPATHs that are useless but not dangerous
148 """
149 if not elf:
150 return
151
152 objdump = bb.data.getVar('OBJDUMP', d, True)
153 env_path = bb.data.getVar('PATH', d, True)
154
155 libdir = bb.data.getVar("libdir", d, True)
156 base_libdir = bb.data.getVar("base_libdir", d, True)
157
158 import re
159 rpath_re = re.compile("\s+RPATH\s+(.*)")
160 for line in os.popen("LC_ALL=C PATH=%s %s -p '%s' 2> /dev/null" % (env_path, objdump, file), "r"):
161 m = rpath_re.match(line)
162 if m:
163 rpath = m.group(1)
164 if rpath == libdir or rpath == base_libdir:
165 # The dynamic linker searches both these places anyway. There is no point in
166 # looking there again.
167 messages.append("dynamic section contains probably-redundant RPATH %s" % rpath)
168
144QAPATHTEST[dev-so] = "package_qa_check_dev" 169QAPATHTEST[dev-so] = "package_qa_check_dev"
145def package_qa_check_dev(path, name, d, elf, messages): 170def package_qa_check_dev(path, name, d, elf, messages):
146 """ 171 """
@@ -238,22 +263,19 @@ def package_qa_hash_style(path, name, d, elf, messages):
238 objdump = bb.data.getVar('OBJDUMP', d, True) 263 objdump = bb.data.getVar('OBJDUMP', d, True)
239 env_path = bb.data.getVar('PATH', d, True) 264 env_path = bb.data.getVar('PATH', d, True)
240 265
241 sane = True 266 sane = False
242 elf = False 267 has_syms = False
243 # A bit hacky. We do not know if path is an elf binary or not 268
244 # we will search for 'NEEDED' or 'INIT' as this should be printed... 269 # If this binary has symbols, we expect it to have GNU_HASH too.
245 # and come before the HASH section (guess!!!) and works on split out
246 # debug symbols too
247 for line in os.popen("LC_ALL=C PATH=%s %s -p '%s' 2> /dev/null" % (env_path, objdump, path), "r"): 270 for line in os.popen("LC_ALL=C PATH=%s %s -p '%s' 2> /dev/null" % (env_path, objdump, path), "r"):
248 if "NEEDED" in line or "INIT" in line: 271 if "SYMTAB" in line:
249 sane = False 272 has_syms = True
250 elf = True
251 if "GNU_HASH" in line: 273 if "GNU_HASH" in line:
252 sane = True 274 sane = True
253 if "[mips32]" in line or "[mips64]" in line: 275 if "[mips32]" in line or "[mips64]" in line:
254 sane = True 276 sane = True
255 277
256 if elf and not sane: 278 if has_syms and not sane:
257 messages.append("No GNU_HASH in the elf binary: '%s'" % path) 279 messages.append("No GNU_HASH in the elf binary: '%s'" % path)
258 280
259 281