diff options
author | Nick Clifton <nickc@redhat.com> | 2017-05-03 09:52:01 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2017-05-03 09:52:01 +0100 |
commit | e78bb25cb636a331f27e9cc4cba5522939567695 (patch) | |
tree | 71730c6b9aba064d7a2bd1eeea5110afde5ee351 /gas/symbols.c | |
parent | 35387fdec5e10b281c218c9dc4f3dc33c3fcc522 (diff) | |
download | gdb-e78bb25cb636a331f27e9cc4cba5522939567695.zip gdb-e78bb25cb636a331f27e9cc4cba5522939567695.tar.gz gdb-e78bb25cb636a331f27e9cc4cba5522939567695.tar.bz2 |
Prevent a seg-fault in the assembler when provided with a bogus input source file.
PR gas/20941
* symbols.c (snapshot_symbol): Handle the case where
resolve_expression returns a local symbol.
Diffstat (limited to 'gas/symbols.c')
-rw-r--r-- | gas/symbols.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gas/symbols.c b/gas/symbols.c index 7146c7d..19a1fa5 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -1561,9 +1561,23 @@ snapshot_symbol (symbolS **symbolPP, valueT *valueP, segT *segP, fragS **fragPP) } *symbolPP = symbolP; - *valueP = exp.X_add_number; - *segP = symbolP->bsym->section; - *fragPP = symbolP->sy_frag; + + /* A bogus input file can result in resolve_expression() + generating a local symbol, so we have to check again. */ + if (LOCAL_SYMBOL_CHECK (symbolP)) + { + struct local_symbol *locsym = (struct local_symbol *) symbolP; + + *valueP = locsym->lsy_value; + *segP = locsym->lsy_section; + *fragPP = local_symbol_get_frag (locsym); + } + else + { + *valueP = exp.X_add_number; + *segP = symbolP->bsym->section; + *fragPP = symbolP->sy_frag; + } if (*segP == expr_section) switch (exp.X_op) |