Re: "pagesel $" dup error
"David Barnett" <[email protected]> Fri, 15 Dec 2006 13:51:19 -0600
| Newsgroups | gmane.comp.hardware.microcontrollers.gnupic |
|---|---|
| Organization | EDT |
| Message-ID | <01c801c72082$63e15ea0$0401a8c0@barnett2> |
----- Original Message ----- From: "David Barnett" <[email protected]> To: <[email protected]> Sent: Friday, November 17, 2006 9:48 AM Subject: Re: [gnupic] "pagesel $" dup error > ----- Original Message ----- > From: "David Barnett" <[email protected]> > To: <[email protected]> > Sent: Wednesday, November 15, 2006 11:40 AM > Subject: [gnupic] "pagesel $" dup error > > >> I got a "duplicate label (_$_000088)" message from gpasm on a "pagesel $" >> instruction. I commented it out and it works fine. It even works when >> assembling for a different PIC (16F73 instead of 16F876A). The code in >> question goes through several levels of include/macro-type indirection. >> >> Can anyone shed some light on this error? > > I found the problem. It's a bug in gpasm. I attached a simple asm file > that exploits the bug. > > The code is relocatable. gpasm generates the relocatable symbol for '$' > as > ('_$_' + line offset). There was a coincidence here that two code > sections > referred to '$' at the same offset and created a duplicate label. To fix > this, we could add the code section name into the label or add in some > kind > of global counter. Scott, MPASM uses the name of the code section in the relocatable label. It generated '_sec1_0000' and '_sec2_0000' for the problem code I attached previously. I patched gpasm to do exactly that (except gpasm still uses 6 digits instead of 4). I tested it and it seems to work great, so here's the patch. BTW, I'd forgotten how much of a pain CVS is to work with... David --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
dup$.patch
(application/octet-stream, 935 B)
Index: gpasm/evaluate.c
===================================================================
RCS file: /cvsroot/gputils/gputils/gpasm/evaluate.c,v
retrieving revision 1.20
diff -u -8 -r1.20 evaluate.c
--- gpasm/evaluate.c 19 Aug 2006 21:57:42 -0000 1.20
+++ gpasm/evaluate.c 15 Dec 2006 19:39:16 -0000
@@ -428,17 +428,18 @@
}
return;
}
switch (p->tag) {
case symbol:
if (strcmp(p->value.symbol, "$") == 0) {
char buffer[BUFSIZ];
- snprintf(buffer, sizeof(buffer), "_$_%06x", state.org << _16bit_core);
+ snprintf(buffer, sizeof(buffer), "_%s_%06x", state.obj.new_sec_name,
+ state.org << _16bit_core);
set_global(buffer, state.org << _16bit_core, PERMANENT, gvt_static);
s = get_symbol(state.stTop, buffer);
} else {
s = get_symbol(state.stTop, p->value.symbol);
}
if (s != NULL) {
var = get_symbol_annotation(s);
if (var != NULL) {