+2019-07-30 Tom de Vries <tdevries@suse.de>
+
+ PR testsuite/24834
+ * lib/gdb.exp (gdb_compile): Fail if nopie results in PIE executable.
+ (exec_is_pie): New proc.
+
2019-07-29 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
regsub "\[\r\n\]*$" "$result" "" result
regsub "^\[\r\n\]*" "$result" "" result
+ if { $type == "executable" && $result == "" && $nopie != -1 } {
+ if { [exec_is_pie "$dest"] } {
+ set result "nopie failed to prevent PIE executable"
+ }
+ }
+
if {[lsearch $options quiet] < 0} {
# We shall update this on a per language basis, to avoid
# changing the entire testsuite in one go.
return 0
}
+# Return true if EXECUTABLE is a Position Independent Executable.
+
+proc exec_is_pie { executable } {
+ set readelf_program [gdb_find_readelf]
+ set res [catch {exec $readelf_program -d $executable \
+ | grep -E "(FLAGS_1).*Flags:.* PIE($| )" }]
+ if { $res == 0 } {
+ return 1
+ }
+ return 0
+}
+
# Return true if a test should be skipped due to lack of floating
# point support or GDB can't fetch the contents from floating point
# registers.