gas/symbols: introduce md_resolve_symbol

Assuming GMSD is a special operand, marked as O_md1, the code:

    .set VREG, GMSD
    .set REG, VREG
    extsw REG, 2

...fails upon attempts to resolve the value of the symbol. This happens
since machine-dependent values are not handled in the giant op switch.
We introduce a custom md_resolve_symbol macro; the ports can use this
macro to customize the behavior when resolve_symbol_value hits O_md
operand.
This commit is contained in:
Dmitry Selyutin
2022-07-18 12:46:53 +03:00
committed by Alan Modra
parent 73d9afb778
commit ffd29c9c21
2 changed files with 45 additions and 0 deletions

View File

@ -1034,6 +1034,12 @@ Predefined symbols with fixed values, such as register names or condition
codes, are typically entered directly into the symbol table when @code{md_begin} codes, are typically entered directly into the symbol table when @code{md_begin}
is called. One argument is passed, a @code{char *} for the symbol. is called. One argument is passed, a @code{char *} for the symbol.
@item md_resolve_symbol
@cindex md_resolve_symbol
If this macro is defined, GAS will call it upon resolving machine-dependent
symbols (that is, for any symbol with operation O_md1..O_md32 inclusively).
If this functions returns zero, then the symbol could not be resolved.
@item md_operand @item md_operand
@cindex md_operand @cindex md_operand
GAS will call this function with one argument, an @code{expressionS} GAS will call this function with one argument, an @code{expressionS}

View File

@ -1408,6 +1408,45 @@ resolve_symbol_value (symbolS *symp)
BAD_CASE (op); BAD_CASE (op);
break; break;
case O_md1:
case O_md2:
case O_md3:
case O_md4:
case O_md5:
case O_md6:
case O_md7:
case O_md8:
case O_md9:
case O_md10:
case O_md11:
case O_md12:
case O_md13:
case O_md14:
case O_md15:
case O_md16:
case O_md17:
case O_md18:
case O_md19:
case O_md20:
case O_md21:
case O_md22:
case O_md23:
case O_md24:
case O_md25:
case O_md26:
case O_md27:
case O_md28:
case O_md29:
case O_md30:
case O_md31:
case O_md32:
#ifdef md_resolve_symbol
resolved = md_resolve_symbol (symp, &final_val, &final_seg);
if (resolved)
break;
#endif
goto exit_dont_set_value;
case O_absent: case O_absent:
final_val = 0; final_val = 0;
/* Fall through. */ /* Fall through. */