OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 | 6 |
7 from autotest_lib.client.bin import test, utils | 7 from autotest_lib.client.bin import test, utils |
8 from autotest_lib.client.common_lib import error | 8 from autotest_lib.client.common_lib import error |
9 | 9 |
10 class platform_StackProtector(test.test): | 10 class platform_StackProtector(test.test): |
11 version = 2 | 11 version = 2 |
12 | 12 |
13 # http://build.chromium.org/mirror/chromiumos/mirror/distfiles/ | 13 # http://build.chromium.org/mirror/chromiumos/mirror/distfiles/ |
14 # binutils-2.19.1.tar.bz2 | 14 # binutils-2.19.1.tar.bz2 |
15 def setup(self, tarball="binutils-2.19.1.tar.bz2"): | 15 def setup(self, tarball="binutils-2.19.1.tar.bz2"): |
16 # clean | 16 # clean |
17 if os.path.exists(self.srcdir): | 17 if os.path.exists(self.srcdir): |
18 utils.system("rm -rf %s" % self.srcdir) | 18 utils.system("rm -rf %s" % self.srcdir) |
19 | 19 |
20 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) | 20 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) |
21 utils.extract_tarball_to_dir(tarball, self.srcdir) | 21 utils.extract_tarball_to_dir(tarball, self.srcdir) |
22 | 22 |
23 os.chdir(self.srcdir) | 23 os.chdir(self.srcdir) |
24 utils.system("patch -p1 < ../binutils-2.19-arm.patch"); | 24 utils.system("patch -p1 < ../binutils-2.19-arm.patch"); |
25 utils.configure() | 25 utils.configure() |
26 utils.system("make") | 26 utils.make() |
27 | 27 |
28 | 28 |
29 def run_once(self, rootdir="/"): | 29 def run_once(self, rootdir="/"): |
30 """ | 30 """ |
31 Do a find for all files on the system | 31 Do a find for all files on the system |
32 For each one, run objdump on them. We'll get either: | 32 For each one, run objdump on them. We'll get either: |
33 * output containing stack_chk (good) | 33 * output containing stack_chk (good) |
34 * stderr containing 'not recognized' on e.g. shell scripts (ok) | 34 * stderr containing 'not recognized' on e.g. shell scripts (ok) |
35 For those, the egrep -q exit(0)'s and there's no output. | 35 For those, the egrep -q exit(0)'s and there's no output. |
36 But, for files compiled without stack protector, the egrep will | 36 But, for files compiled without stack protector, the egrep will |
(...skipping 20 matching lines...) Expand all Loading... |
57 ) | 57 ) |
58 badfiles = utils.system_output(cmd % (rootdir, libc_glob)) | 58 badfiles = utils.system_output(cmd % (rootdir, libc_glob)) |
59 | 59 |
60 # special case check for libc, needs different objdump flags | 60 # special case check for libc, needs different objdump flags |
61 cmd = "binutils/objdump -D %s | egrep -q stack_chk || echo %s" | 61 cmd = "binutils/objdump -D %s | egrep -q stack_chk || echo %s" |
62 libc_stack_chk = utils.system_output(cmd % (libc_glob, libc_glob)) | 62 libc_stack_chk = utils.system_output(cmd % (libc_glob, libc_glob)) |
63 | 63 |
64 if badfiles or libc_stack_chk: | 64 if badfiles or libc_stack_chk: |
65 raise error.TestFail("Missing -fstack-protector:\n" | 65 raise error.TestFail("Missing -fstack-protector:\n" |
66 + badfiles + libc_stack_chk) | 66 + badfiles + libc_stack_chk) |
OLD | NEW |