aboutsummaryrefslogtreecommitdiff
path: root/gas/symbols.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2022-10-11 15:28:10 +0100
committerNick Clifton <nickc@redhat.com>2022-10-11 15:29:03 +0100
commit12509439a1844a1f1095ac4e9d70b59b539e952c (patch)
tree19b6c3b392ad3770de159024fe8668a81ebc9a9f /gas/symbols.c
parentbabcfd75883790c13de37c86f15de7d4bca582de (diff)
downloadgdb-12509439a1844a1f1095ac4e9d70b59b539e952c.zip
gdb-12509439a1844a1f1095ac4e9d70b59b539e952c.tar.gz
gdb-12509439a1844a1f1095ac4e9d70b59b539e952c.tar.bz2
Re: Error: attempt to get value of unresolved symbol `L0'
* symbols.c (S_GET_VALUE): If the unresolved symbol is the fake label provide a more helpful error message to the user. (S_GET_VALUE_WHERE): Like S_GET_VALUE, but includes a file/line number for error reporting purposes. * symbols.h (S_GET_VALUE_WHERE): Prototype. * write.c (fixup_segment): Use S_GET_VALUE_WHERE.
Diffstat (limited to 'gas/symbols.c')
-rw-r--r--gas/symbols.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gas/symbols.c b/gas/symbols.c
index 0aac3a43..59358c1 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -2217,7 +2217,7 @@ decode_local_label_name (char *s)
/* Get the value of a symbol. */
valueT
-S_GET_VALUE (symbolS *s)
+S_GET_VALUE_WHERE (symbolS *s, const char * file, unsigned int line)
{
if (s->flags.local_symbol)
return resolve_symbol_value (s);
@@ -2238,7 +2238,10 @@ S_GET_VALUE (symbolS *s)
|| (S_IS_DEFINED (s) && ! S_IS_COMMON (s)))
{
if (strcmp (S_GET_NAME (s), FAKE_LABEL_NAME) == 0)
- as_bad (_("expression is too complex to be resolved"));
+ as_bad_where (file, line, _("expression is too complex to be resolved or converted into relocations"));
+ else if (file != NULL)
+ as_bad_where (file, line, _("attempt to get value of unresolved symbol `%s'"),
+ S_GET_NAME (s));
else
as_bad (_("attempt to get value of unresolved symbol `%s'"),
S_GET_NAME (s));
@@ -2247,6 +2250,12 @@ S_GET_VALUE (symbolS *s)
return (valueT) s->x->value.X_add_number;
}
+valueT
+S_GET_VALUE (symbolS *s)
+{
+ return S_GET_VALUE_WHERE (s, NULL, 0);
+}
+
/* Set the value of a symbol. */
void