public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] compile: Fix function pointers
@ 2014-12-12 21:51 Jan Kratochvil
  2015-01-16 22:52 ` ping: " Jan Kratochvil
  2015-01-22 12:18 ` Pedro Alves
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Kratochvil @ 2014-12-12 21:51 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 591 bytes --]

Hi,

originally posted in the same form as:
	[patch 15/14] GDB/GCC compile function pointers [Re: [PATCH v4 00/14] let gdb reuse gcc's C compiler]
	https://sourceware.org/ml/gdb-patches/2014-12/msg00148.html
	Message-ID: <20141205182925.GA25151@host2.jankratochvil.net>

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.

So this is a formal request for review/approval as the main patchset is now
checked in.


Thanks,
Jan

[-- Attachment #2: jitgot.patch --]
[-- Type: text/plain, Size: 1951 bytes --]

gdb/ChangeLog
2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

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

gdb/testsuite/ChangeLog
2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

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

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* ping: [patch] compile: Fix function pointers
  2014-12-12 21:51 [patch] compile: Fix function pointers Jan Kratochvil
@ 2015-01-16 22:52 ` Jan Kratochvil
  2015-01-22 12:18 ` Pedro Alves
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Kratochvil @ 2015-01-16 22:52 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

On Fri, 12 Dec 2014 22:50:56 +0100, Jan Kratochvil wrote:
Hi,

originally posted in the same form as:
	[patch 15/14] GDB/GCC compile function pointers [Re: [PATCH v4 00/14] let gdb reuse gcc's C compiler]
	https://sourceware.org/ml/gdb-patches/2014-12/msg00148.html
	Message-ID: <20141205182925.GA25151@host2.jankratochvil.net>

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.

So this is a formal request for review/approval as the main patchset is now
checked in.


Thanks,
Jan

[-- Attachment #2: jitgot.patch --]
[-- Type: text/plain, Size: 1951 bytes --]

gdb/ChangeLog
2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

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

gdb/testsuite/ChangeLog
2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

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

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] compile: Fix function pointers
  2014-12-12 21:51 [patch] compile: Fix function pointers Jan Kratochvil
  2015-01-16 22:52 ` ping: " Jan Kratochvil
@ 2015-01-22 12:18 ` Pedro Alves
  2015-01-22 18:23   ` Jan Kratochvil
  1 sibling, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2015-01-22 12:18 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] compile: Fix function pointers
  2015-01-22 12:18 ` Pedro Alves
@ 2015-01-22 18:23   ` Jan Kratochvil
  2015-01-23  7:52     ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2015-01-22 18:23 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, Pedro Alves

On Thu, 22 Jan 2015 13:18:40 +0100, Pedro Alves wrote:
> OK.

Checked in:
	4b62a76e0cd716407859077467fddbb66b715a43

Joel:
OK for 7.9?  It is definitely not regression-safe but I do not think it matter
for the new 'compile' feature, it was broken anyway etc.


Jan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] compile: Fix function pointers
  2015-01-22 18:23   ` Jan Kratochvil
@ 2015-01-23  7:52     ` Joel Brobecker
  2015-01-23 10:45       ` [7.9 commit] " Jan Kratochvil
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2015-01-23  7:52 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Pedro Alves

> Checked in:
> 	4b62a76e0cd716407859077467fddbb66b715a43
> 
> Joel:
> OK for 7.9?  It is definitely not regression-safe but I do not think
> it matter for the new 'compile' feature, it was broken anyway etc.

OK!

-- 
Joel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [7.9 commit] [patch] compile: Fix function pointers
  2015-01-23  7:52     ` Joel Brobecker
@ 2015-01-23 10:45       ` Jan Kratochvil
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kratochvil @ 2015-01-23 10:45 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, Pedro Alves

On Fri, 23 Jan 2015 08:30:00 +0100, Joel Brobecker wrote:
> > Joel:
> > OK for 7.9?  It is definitely not regression-safe but I do not think
> > it matter for the new 'compile' feature, it was broken anyway etc.
> 
> OK!

Checked in:
	cef1719ed36a945f263d1d1605af7046e9b18b84


Jan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-23 10:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-12 21:51 [patch] compile: Fix function pointers Jan Kratochvil
2015-01-16 22:52 ` ping: " Jan Kratochvil
2015-01-22 12:18 ` Pedro Alves
2015-01-22 18:23   ` Jan Kratochvil
2015-01-23  7:52     ` Joel Brobecker
2015-01-23 10:45       ` [7.9 commit] " Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).