Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Waldek Hebisch <hebisch@math.uni.wroc.pl>
To: Pierre Muller <muller@ics.u-strasbg.fr>
Cc: gdb-patches@sourceware.org, gpc@gnu.de
Subject: Re: [RFC] Handle GPC specific name for main function
Date: Thu, 27 Sep 2007 01:58:00 -0000	[thread overview]
Message-ID: <E1Iaie4-0004Wd-00@hera.math.uni.wroc.pl> (raw)
In-Reply-To: <003901c8004b$2f9a55d0$8ecf0170$@u-strasbg.fr>

Pierre Muller wrote:
>   This patch looks up for
> GPC specific minimal symbols
> and assumes that if they are present,
> the executable was compiled by GPC.
>   GPC used 'pascal_main_program' and now
> uses '_p__M0_main_program'.
> 
>   Is there some other way to check that the 
> program was really compiled by GPC?
> (Any C compiled program could have a
> 'pascal_main_program' function...)
> 
>   Maybe by looking up some other symbol?
> I found 'GPC_init' as a possible candidate,
> but I am not sure that this symbol is 
> defined for all versions of GPC, so I did not 
> include it in the present RFC.
> 

I doubt that any simple method will work for "all versions of GPC".
According to change log  'pascal_main_program' was introduced
24 Jun 2000, earler GPC used 'program_Foo' where 'Foo' is program name.
'_p__M0_main_program' appeared in gpc-20050217 (however, there for
a few month the change was available as a patch, so '_p__M0_main_program'
may appear also in earlier versions).

I would say that the most reliable indication that the program 
is GPC compiled is if debug info indicate that language is Pascal
and there are signs that the file is gcc compiled (otherwise the file
is compiled by some other Pascal compiler).  If debug info indicate
other language file is not GPC compiled.  

Concerning 'GPC_init':  it is probably present in all currently
used versions.  It is absent in ancient versions like gpc-1.2-2.7.2.
'GPC_init' may vanish from future versions -- it is one of few
names in GPC runtime which do not use '_p_' prefix.  Also, while
I know of no way to omit 'GPC_init' when using standard runtime
it is possible to use alternative runtime which does not contain
'GPC_init.

When checking if program is GPC compiled one may look at 
'_p_initialize' -- it is present at least from 1993 up to now.
Also current GPC versions use a special symbol to check for
matched runtiome.  This symbol looks like '_p_GPC_RTS_VERSION_20060215'
(where to last part encodes version of the runtime).  Versions
before 2004-02-04 used GPC_RTS_VERSION_YYYYMMDD.  I do not know
when this symbol was introduced -- it is absent in gpc-1.2-2.7.2
but present in gpc-20020510.  Both '_p_initialize' and
'_p_GPC_RTS_VERSION_20060215' are referenced from 'main', so
they must appear even if alternate runtime is in use.

GPC emits '_p__M0_main_program' (or 'pascal_main_program')
in the same file as 'main', and '_p__M0_main_program' is called
from 'main' -- I am not sure if gdb can check this.

Let me remark that it is possible to have '_p__M0_main_program'
without having 'main'.  Namely,  GPC allows to compile Pascal source
like normal program, but replacing main by a differently named function.
One use of such possibility is when making shared libraries.  Another 
is when the main program is not a Pascal program.

-- 
                              Waldek Hebisch
hebisch@math.uni.wroc.pl 


  parent reply	other threads:[~2007-09-27  1:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 14:40 Pierre Muller
2007-09-26 15:03 ` Eli Zaretskii
2007-09-26 15:32   ` Pierre Muller
2007-09-26 17:48     ` Eli Zaretskii
2007-09-26 17:58 ` Joel Brobecker
2007-09-26 19:39   ` Pierre Muller
2007-09-26 19:50     ` Joel Brobecker
2007-09-26 22:06       ` Pierre Muller
2007-09-26 22:39         ` [RFC-2] " Pierre Muller
2007-09-27  6:03           ` Joel Brobecker
2007-09-27  7:29             ` [RFC-3] " Pierre Muller
     [not found]               ` <46FB5E2C.6080606@microbizz.nl>
     [not found]                 ` <46FB5F76.9050501@microbizz.nl>
2007-09-27  7:57                   ` Pierre Muller
2007-09-27 12:11                     ` Daniel Jacobowitz
2007-09-27 12:35                       ` Pierre Muller
2007-09-27 12:40                         ` 'Daniel Jacobowitz'
2007-09-27 16:20                           ` Joel Brobecker
2007-09-27 16:32                             ` Joel Brobecker
2007-09-27 21:36                               ` Pierre Muller
2007-09-28 18:31                                 ` Joel Brobecker
2007-09-27  8:02                 ` Pierre Muller
2007-09-27 13:01                   ` Waldek Hebisch
2007-09-27  7:20           ` [RFC-2] " Eli Zaretskii
2007-09-27  1:58 ` Waldek Hebisch [this message]
2007-09-27  5:52   ` [RFC] " Joel Brobecker
2007-09-27 17:17     ` Thiago Jung Bauermann
2007-09-27 19:50       ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1Iaie4-0004Wd-00@hera.math.uni.wroc.pl \
    --to=hebisch@math.uni.wroc.pl \
    --cc=gdb-patches@sourceware.org \
    --cc=gpc@gnu.de \
    --cc=muller@ics.u-strasbg.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox