Added a better way to check for -pie default flags.
With gcc-4.6, we'll move to a wrapper script that invokes gcc and adds
default flags so -dumpspecs wont tell you whether the compiler is
hardened or not.
BUG=none
TEST=emerge-$BOARD autotest-deps-iotools w/ gcc-4.6
Change-Id: Ie069ffc9a3ba70ec0f3b9bfee2d5dcce515f4097
Reviewed-on: http://gerrit.chromium.org/gerrit/1469
Tested-by: asharif <asharif@chromium.org>
Reviewed-by: Eric Li <ericli@chromium.org>
diff --git a/client/bin/site_utils.py b/client/bin/site_utils.py
index c17719e..100fe86 100644
--- a/client/bin/site_utils.py
+++ b/client/bin/site_utils.py
@@ -164,3 +164,26 @@
rv.extend(missing_strings)
return '\n'.join(rv)
+
+
+def target_is_x86_pie():
+ """Returns whether the toolchain produces an x86 PIE (position independent
+ executable) by default.
+
+ Arguments:
+ None
+
+ Returns:
+ True if the target toolchain produces an x86 PIE by default.
+ False otherwise.
+ """
+
+
+ command = "echo \"int main(){return 0;}\" | ${CC} -o /tmp/a.out -xc -"
+ command += "&& file /tmp/a.out"
+ result = utils.system_output(command, retain_output=True,
+ ignore_status=True)
+ if re.search("80\d86", result) and re.search("shared object", result):
+ return True
+ else:
+ return False