[PATCH] bug 5543: do not allow register symbols to be global

Nick Clifton nickc@redhat.com
Fri Feb 29 17:46:00 GMT 2008


Hi H.J.,

> We get into trouble only when we try to use bar3. This patch catches
> all cases. But it doesn't report the correct line number. 

I think that we should make an attempt to report the correct line 
number.  If there was code in read.c:s_global() for instance you could 
catch the 'bar2' example in your testcase.


> +void
> +elf_obj_validate_symbol_value (symbolS *symbolP)
> +{
> +  if (!IS_ELF)
> +    return;
> +
> +  if (symbolP->bsym->section == reg_section)
> +    {
> +      const char *name = S_GET_NAME (symbolP);
> +
> +      /* Report error only if we know the symbol name.  */
> +      if (name != reg_section->name)
> +	as_bad (_("Invalid value for symbol `%s'"), name);
> +    }
> +}

I think that it would be better if this function did not emit an error 
message but just instead returned a boolean saying whether the symbol 
was valid or not.  Then the caller the choose how to report the problem 
to the user, if it needs reporting at all.

Cheers
   Nick



More information about the Binutils mailing list