On 22/06/23 10:18, zac.walker@linaro.org wrote:
Hi, In binutils I need to write an offset between two symbols shifted right by 2 bits. This offset is written to the xdata section. My code currently looks like this: exp.X_op = O_subtract; exp.X_add_symbol = symbol1; exp.X_op_symbol = symbol2; emit_expr (&exp, 2); This works fine but obviously the result value is not shifted. Anyone have a good option is to shift the output of emit_expr at write time? I cannot use resolve_expression because the symbols do not have correct addresses at the time this code executes.
The 'struct expressionS' has the additional 'X_md' which is used by some targets to add extra rules for the expression. I am not very knowledge on this code, but I would expect that ld has a callback to handle the expressions prior the written.