How-to add custom errata workaround to the assembler?

Nick Clifton nickc@redhat.com
Mon Jul 29 11:15:17 GMT 2024


Hi Sebastian,

> I have a system on a chip with an Armv8-R core (Cortex-R52) which needs an additional load after each load exclusive instruction (ldrex, ...) as a hardware errata workaround. I would like to add a custom assembler option

I assume that this cannot just be a patch to the compiler as you need the workaround to
support hand written assembler files too.  Is that correct ?

> to enable this workaround and then emit for each load exclusive instruction which gets assembled an additional load instruction. It would be great if someone could give me a hint if this sounds feasible 

Yes, it is feasible.  Not sure how much work it will be, but it certainly can be
done.

> and ideally which function or file in binutils could be changed to to do this work.

Pretty much all of the work will be in the gas/config/tc-arm.c file in the binutils
sources.

New command line options should be added to the arm_opts[] array.

Create a new local variable to be enabled/disabled by your new command line option
and then test it in functions like do_ldrex() and do_ldrexd().  (You may need to
scan the tc-arm.c source to find other places that need updating).

You should be able to use emit_insn() to add the extra instruction into the output
stream, if you have a binary form of the instruction available.  (Creating an
expression with the O_constant type and an X_add_number field containing the binary
value).  Otherwise you might have to use md_assemble(), temporarily overriding the
input stream, in order to assemble the new instruction.

I would strongly recommend that you add one or more test files to the
gas/testsuite/gas/arm directory.  The convention is the *.d files are the test
drivers and *.s are the test sources.

It would also be good to update the gas/doc/c-arm.texi file to describe the new option.
(Unless you plan on keeping your update private) and the gas/NEWS file to mention the
new feature.

Cheers
   Nick



More information about the Binutils mailing list