This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Allow a symbol set to common symbol + value
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Etienne Lorrain <etienne_lorrain at yahoo dot fr>
- Cc: Dave Korn <dave dot korn at artimi dot com>,'Nick Clifton' <nickc at redhat dot com>, binutils at sources dot redhat dot com,drow at false dot org
- Date: Mon, 25 Apr 2005 11:43:34 -0700
- Subject: PATCH: Allow a symbol set to common symbol + value
- References: <20050425162051.86022.qmail@web26910.mail.ukl.yahoo.com>
On Mon, Apr 25, 2005 at 06:20:50PM +0200, Etienne Lorrain wrote:
> --- Dave Korn <dave.korn@artimi.com> wrote:
> > > > asm volatile (" dataPS2 = %c0 ": : "i" (&MOUSE.data.PS2));
> >
> > IIUIC, all you want to do here is initialise an assembler-level variable
> > with the address of MOUSE.data.PS2 at runtime, yes? So why not make your
> > life a load easier, and do it the other way round:
> > void *dataPS2 = NULL;
>
> I do not think my method is that complex, not going through a variable
> pointer but just defining a symbol to write to. With your pointer I would
> have to read the content of the pointer and write to this address - and
> so save another register on the stack to store the address to write to
> in my interrupt treatment.
> This address is known at link time so there is no need to put it in
> a variable pointer.
>
> I can accept the argument of H.J. saying that the behaviour I am waiting
> is not guarantied - but I am sure it was working perfectly in my case,
> with binutils-2.15.
> The address is the same, the PS2 mouse is perfectly working in Gujin,
> and this field is only written under interrupt and only read in C.
>
> That is not a real problem for my application, I will initialise to
> get the MOUSE structure in BSS instead of COMMON.
>
"dataPS2 = MOUSE" != "dataPS2 = MOUSE + 4" when MOUSE is a common
symbol. "dataPS2 = MOUSE" will create a copy of MOUSE and will create
a symbol with value of "MOUSE + 4". Is that intentional? If yes, this
patch will allow "dataPS2 = MOUSE + 4". Can we change "dataPS2 = MOUSE"
to mean the value of MOUSE, not its copy?
H.J.
----
2005-04-25 H.J. Lu <hongjiu.lu@intel.com>
* read.c (pseudo_set): Disallow symbol set to common symbol.
* write.c (write_object_file): Allow a symbol set to common
symbol + value.
--- gas/read.c.set 2005-04-25 09:24:04.000000000 -0700
+++ gas/read.c 2005-04-25 11:30:11.000000000 -0700
@@ -3301,6 +3301,10 @@ pseudo_set (symbolS *symbolP)
{
symbolS *s = exp.X_add_symbol;
+ if (S_IS_COMMON (s) && exp.X_add_number == 0)
+ as_bad (_("`%s' can't be equated to common symbol '%s'"),
+ S_GET_NAME (symbolP), S_GET_NAME (s));
+
S_SET_SEGMENT (symbolP, seg);
S_SET_VALUE (symbolP, exp.X_add_number + S_GET_VALUE (s));
symbol_set_frag (symbolP, symbol_get_frag (s));
--- gas/write.c.set 2005-04-20 11:12:17.000000000 -0700
+++ gas/write.c 2005-04-25 11:34:17.000000000 -0700
@@ -1928,8 +1936,13 @@ write_object_file (void)
if (symbol_equated_reloc_p (symp))
{
if (S_IS_COMMON (symp))
- as_bad (_("`%s' can't be equated to common symbol"),
- S_GET_NAME (symp));
+ {
+ expressionS *e = symbol_get_value_expression (symp);
+ if (e->X_add_number == 0)
+ as_bad (_("`%s' can't be equated to common symbol `%s'"),
+ S_GET_NAME (symp),
+ S_GET_NAME (e->X_add_symbol));
+ }
symbol_remove (symp, &symbol_rootP, &symbol_lastP);
continue;
}