How-to add custom errata workaround to the assembler?
Sebastian Huber
sebastian.huber@embedded-brains.de
Tue Aug 13 12:55:26 GMT 2024
Hello Nick,
----- Am 29. Jul 2024 um 13:15 schrieb Nick Clifton nickc@redhat.com:
> 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 ?
yes, the workaround needs to cover also hand written assembler files.
>
>> 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.
Thanks for the valuable hints. It turned out to be pretty simple. I just added something similar to output_inst() after this call in md_assemble(). The additional work is guarded by a new option. I added a GCC multilib for this as well. Overall, I guess it is quite a hack, but works well.
With respect to making it public, I have the issue that the hardware manufacturer wants to keep it private for now.
--
embedded brains GmbH & Co. KG
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
More information about the Binutils
mailing list