This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch 15/14] GDB/GCC compile function pointers [Re: [PATCH v4 00/14] let gdb reuse gcc's C compiler]


Hi,

not sure if it is already approved or under review but here is one fix-up of
the submitted code.  To be integrated during check-in.


Jan
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 6d3d16e..bb6705f 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -636,12 +636,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.  */
diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp
index d0dd791..fb8b390 100644
--- a/gdb/testsuite/gdb.compile/compile.exp
+++ b/gdb/testsuite/gdb.compile/compile.exp
@@ -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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]