gnupic: Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch)


Previous by date: 19 Dec 2005 21:47:48 +0000 Re: [gnupic] gplink throws away configuration (PIC18F458), Craig Franklin
Next by date: 19 Dec 2005 21:47:48 +0000 popt and gpsim-0.21.11 CLI on Debian, Martin McCormick
Previous in thread: 19 Dec 2005 21:47:48 +0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Scott Dattalo
Next in thread: 19 Dec 2005 21:47:48 +0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Chen Xiao Fan

Subject: Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch)
From: Craig Franklin ####@####.####
Date: 19 Dec 2005 21:47:48 +0000
Message-Id: <43A72AD7.9020905@users.sourceforge.net>

Ian Jackson wrote:

>In April, I wrote:
>  
>
>>I found it inconvenient that when defining a global symbol (one with
>>`external linkage' in C parlance, although there is of course no C
>>here) in gpasm I have to say `global', but when I'm referring to it I
>>have to say `extern'.  That means I can't have one include file with a
>>list of all of the global symbols.
>>    
>>
>
>And in October I wrote:
>  
>
>>So, after some head-scratching, I came up with an alternative - see
>>below.  With this new patch you have to say `extern' _after_ the
>>definition.  If you do, it treats the `extern' more or less as if it
>>was `global'.
>>
>>This is a less friendly version of the patch than the previous one,
>>IMO, but the way the coff symbol number calculation is done makes it
>>impractical do it it another way.
>>    
>>
>
>I've been using my patched 0.13.3-1 gputils for the past few months
>and this has been working well.  I would like to suggest that my
>patch, or something like it, be included in the next gputils release.
>
>  
>

Please post a project that uses the new feature.  I want to make sure I 
understand how you are using it.

Microchip may have improved things in the last year, but IMHO they don't 
do enough to enforce symbol types and check for name space collisions.  
Back when I wrote gplink, I found out all sorts of neat things about 
mpasm.  They allowed the same symbol name to be local and static and 
also be extern (might have the details wrong, but you get the idea).  
Never figured out how they resolved which one would be used.  I sent 
several bug reports, but I don't think anything came of it.  Many hacks 
were added to gputils to work around the problems.

This history has me more than a little cautious about this change.  It 
looks innocent enough.  If this feature is added, there will have to be 
a command line option to enable it.  Another option is to create a new 
direction, unique to gpasm, to prevent confusion.  Regardless, I will 
wait to see your project before deciding on incorporating your patch.

I did add a feature to gpvo to help with this problem.  Don't remember 
if I told anyone.  There is a symbol export feature on gpvo.  It reads 
an object file and exports all the global symbols to a test file.  Of 
course you still have to include that file, but most of the hard work is 
done.  Should be simple enough to add to automate.  Circular references 
might be a problem.

>Thanks,
>Ian.
>
>diff -ru orig/gputils-0.13.3/debian/changelog gputils-0.13.3/debian/changelog
>--- orig/gputils-0.13.3/debian/changelog	2005-10-28 00:02:21.754919510 +0100
>+++ gputils-0.13.3/debian/changelog	2005-10-29 17:24:17.498756153 +0100
>@@ -1,3 +1,13 @@
>+gputils (0.13.3-1.0iwj2) unstable; urgency=low
>+
>+  * extern/global feature for labels:
>+    If we encounter `extern' for a label which is already defined
>+    as gvt_static or gvt_address, we change it to gvt_global.
>+    This means that `extern' after a label definition is much like
>+    `global'.
>+
>+ -- Ian Jackson ####@####.####  Sat, 29 Oct 2005 17:24:12 +0100
>+
> gputils (0.13.3-1) unstable; urgency=low
> 
>   * New upstream version. 
>Only in gputils-0.13.3/debian: changelog~
>diff -ru orig/gputils-0.13.3/gpasm/coff.c gputils-0.13.3/gpasm/coff.c
>--- orig/gputils-0.13.3/gpasm/coff.c	2005-01-03 22:21:04.000000000 +0000
>+++ gputils-0.13.3/gpasm/coff.c	2005-10-29 15:59:18.913415094 +0100
>@@ -447,7 +447,7 @@
>     if ((new->type != class) || 
>         (new->section_number != section_number)) {
>       snprintf(message, sizeof(message),
>-               "Duplicate label or redefining symbol that cannot be redefined. (%s)",
>+               "Duplicate extern label or redefining symbol that cannot be redefined. (%s)",
>                name);    
>       gperror(GPE_UNKNOWN, message);
>     }
>@@ -455,7 +455,7 @@
> 
>   if ((new != NULL) && (type != gvt_extern) && (type != gvt_debug))  {
>     snprintf(message, sizeof(message),
>-             "Duplicate label or redefining symbol that cannot be redefined. (%s)",
>+             "Duplicate non-extern label or redefining symbol that cannot be redefined. (%s)",
>              name);    
>     gperror(GPE_DUPLAB, message);
>   } else {
>diff -ru orig/gputils-0.13.3/gpasm/directive.c gputils-0.13.3/gpasm/directive.c
>--- orig/gputils-0.13.3/gpasm/directive.c	2005-07-02 18:10:13.000000000 +0100
>+++ gputils-0.13.3/gpasm/directive.c	2005-10-29 17:06:08.431816728 +0100
>@@ -1342,6 +1342,8 @@
> 		          struct pnode *parms)
> {
>   char *p;
>+  struct symbol *s;
>+  struct variable *var;
>   state.lst.line.linetype = dir;
>   
>   if (state.mode == absolute) {
>@@ -1350,7 +1352,15 @@
>     for (; parms; parms = TAIL(parms)) {
>       p = maybe_evaluate_concat(HEAD(parms));
>       if (p) {
>-        set_global(p, 0, PERMANENT, gvt_extern);
>+	s = get_symbol(state.stTop, p);
>+	var = s ? get_symbol_annotation(s) : NULL;
>+	if (var &&
>+	    (var->previous_type == gvt_static || 
>+	     var->previous_type == gvt_address)) {
>+	  var->type = gvt_global;
>+	} else {
>+	  set_global(p, 0, PERMANENT, gvt_extern);
>+	}
>       }
>     }
>   }
>
>  
>


Previous by date: 19 Dec 2005 21:47:48 +0000 Re: [gnupic] gplink throws away configuration (PIC18F458), Craig Franklin
Next by date: 19 Dec 2005 21:47:48 +0000 popt and gpsim-0.21.11 CLI on Debian, Martin McCormick
Previous in thread: 19 Dec 2005 21:47:48 +0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Scott Dattalo
Next in thread: 19 Dec 2005 21:47:48 +0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Chen Xiao Fan


Powered by ezmlm-browse 0.20.