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


Previous by date: 31 Oct 2010 21:57:03 -0000 Re: MPLAB X IDE beta under Linux and Mac OS X, Xiaofan Chen
Next by date: 31 Oct 2010 21:57:03 -0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Ian Jackson
Previous in thread: 31 Oct 2010 21:57:03 -0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Ian Jackson
Next in thread: 31 Oct 2010 21:57:03 -0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Ian Jackson

Subject: Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch)
From: Ian Jackson ####@####.####
Date: 31 Oct 2010 21:57:03 -0000
Message-Id: <19661.58907.66122.251587@davenant.relativity.greenend.org.uk>

In January 2006 I proposed a patch to gpasm to allow "extern" to work
like "global" for labels which have already been defined, rather than
giving an error.  This allows all the intentionall external symbols to
be collected together in one .inc file, as C programmers are used to.

The previous conversation ought to be archived here etc.:
  http://linuxhacker.org/cgi-bin/ezmlm-cgi?1:msp:4097:dlbeedhmomchhgdonnak
  http://linuxhacker.org/cgi-bin/ezmlm-cgi?1:ddn:4872:200512#b
see the thread
  gpasm `extern' vs `global' (new feature patch)
but currently that list archive seems partially broken.

> Craig Franklin wrote:
> > Please post a project that uses the new feature.  I want to make sure I 
> > understand how you are using it.
> 
> http://www.chiark.greenend.org.uk/ucgi/~ijackson/cvsweb/trains/
> http://www.chiark.greenend.org.uk/~ian/d/trains-snapshot-2006-01-17.tar.gz

The latter link is still valid although the project is no longer in
CVS.

> > [...]  Regardless, I will wait to see your project before deciding
> > on incorporating your patch.
> 
> I have no objection to a new directive.  That would solve the problem
> just as well.  But, note that this feature only applies new semantics
> to what was previously an error so there is no need for an option to
> turn it on (unless you think people will accidentally glue together
> identically-named symbols in different files).

I didn't hear any more about this.

I have just upgraded the host where I build my project to lenny and I
see that lenny's gpasm still does not support this feature.  I've once
again patched my copy.  Patch attached.

Aurelien, would you consider applying this change to squeeze's gpasm
in due course ?  If so I will file a wishlist bug.

Ian.


diff -ru orig/gputils-0.13.7/debian/changelog gputils-0.13.7/debian/changelog
--- orig/gputils-0.13.7/debian/changelog	2010-10-31 21:35:27.000000000 +0000
+++ gputils-0.13.7/debian/changelog	2010-10-31 21:36:39.000000000 +0000
@@ -1,3 +1,13 @@
+gputils (0.13.7-2.0iwj1) 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 ####@####.####  Sun, 31 Oct 2010 21:36:39 +0000
+
 gputils (0.13.7-1) unstable; urgency=low
 
   * New upstream release.
Only in gputils-0.13.7/debian: changelog.orig
Only in gputils-0.13.7/debian: changelog~
diff -ru orig/gputils-0.13.7/gpasm/coff.c gputils-0.13.7/gpasm/coff.c
--- orig/gputils-0.13.7/gpasm/coff.c	2009-03-13 18:15:30.000000000 +0000
+++ gputils-0.13.7/gpasm/coff.c	2010-10-31 21:35:53.000000000 +0000
@@ -458,7 +458,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);
     }
@@ -466,7 +466,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 {
Only in gputils-0.13.7/gpasm: coff.c.orig
diff -ru orig/gputils-0.13.7/gpasm/directive.c gputils-0.13.7/gpasm/directive.c
--- orig/gputils-0.13.7/gpasm/directive.c	2009-03-13 18:15:30.000000000 +0000
+++ gputils-0.13.7/gpasm/directive.c	2010-10-31 21:35:53.000000000 +0000
@@ -1660,6 +1660,8 @@
 		          struct pnode *parms)
 {
   char *p;
+  struct symbol *s;
+  struct variable *var;
   state.lst.line.linetype = dir;
   
   if (state.mode == absolute) {
@@ -1668,7 +1670,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);
+	}
       }
     }
   }
Only in gputils-0.13.7/gpasm: directive.c.orig

Previous by date: 31 Oct 2010 21:57:03 -0000 Re: MPLAB X IDE beta under Linux and Mac OS X, Xiaofan Chen
Next by date: 31 Oct 2010 21:57:03 -0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Ian Jackson
Previous in thread: 31 Oct 2010 21:57:03 -0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Ian Jackson
Next in thread: 31 Oct 2010 21:57:03 -0000 Re: [gnupic] Re: gpasm `extern' vs `global' (new feature patch), Ian Jackson


Powered by ezmlm-browse 0.20.