]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
compile: Fix function pointers
authorJan Kratochvil <jan.kratochvil@redhat.com>
Fri, 23 Jan 2015 09:52:55 +0000 (10:52 +0100)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Fri, 23 Jan 2015 09:52:55 +0000 (10:52 +0100)
TBH while I always comment reasons for each of the compilation options in
reality I tried them all and chose that combination that needs the most simple
compile/compile-object-load.c (ld.so emulation) implementation.

gdb/ChangeLog
2015-01-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile.c (_initialize_compile): Use -fPIE for compile_args.

gdb/testsuite/ChangeLog
2015-01-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.compile/compile.exp (pointer to jit function): New test.

gdb/ChangeLog
gdb/compile/compile.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.compile/compile.exp

index 1e0b3ece6676f55e588232748072a7c66d469845..4a9c7e177f1fbbaeea17a8ac57956d08a70e24a6 100644 (file)
@@ -1,3 +1,7 @@
+2015-01-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * compile/compile.c (_initialize_compile): Use -fPIE for compile_args.
+
 2015-01-22  Pedro Alves  <palves@redhat.com>
 
        * configure.ac [*mingw32*]: Check $curses_found instead of
index ccac49dd1729bd5b4bf8c5f3ec6fd8e583dd177b..70b6d44cd20b2a6b5205e2293e09f2ea47828963 100644 (file)
@@ -645,12 +645,13 @@ String quoting is parsed like in shell, for example:\n\
 
   /* Override flags possibly coming from DW_AT_producer.  */
   compile_args = xstrdup ("-O0 -gdwarf-4"
-  /* We use -fPIC Otherwise GDB would need to reserve space large enough for
+  /* We use -fPIE Otherwise GDB would need to reserve space large enough for
      any object file in the inferior in advance to get the final address when
      to link the object file to and additionally the default system linker
      script would need to be modified so that one can specify there the
-     absolute target address.  */
-                        " -fPIC"
+     absolute target address.
+     -fPIC is not used at is would require from GDB to generate .got.  */
+                        " -fPIE"
   /* We don't want warnings.  */
                         " -w"
   /* Override CU's possible -fstack-protector-strong.  */
index 107a383b02ac6fc8001c3595a4db1b02c2ffa101..8675b0f321ebfa2cbcc093f9993a98c27489a72e 100644 (file)
@@ -1,3 +1,7 @@
+2015-01-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.compile/compile.exp (pointer to jit function): New test.
+
 2015-01-14  Pedro Alves  <palves@redhat.com>
            Joel Brobecker  <brobecker@adacore.com>
 
index e426cc116e0293b41e50d0c43cb306c712564d43..dc09770133a8c3ad95661806fa9d318f9616a906 100644 (file)
@@ -259,6 +259,11 @@ gdb_test_no_output "end" "compile code -r multiline 4"
 gdb_test "print 'compile.c'::globalshadow" " = 77000" \
     "check globalshadow with -r"
 
+# Test GOT vs. resolving jit function pointers.
+
+gdb_test_no_output "compile -raw -- int func(){return 21;} _gdb_expr(){int (*funcp)()=func; if (funcp()!=21) abort();}" \
+    "pointer to jit function"
+
 #
 # Test the case where the registers structure would not normally have
 # any fields.