P.S. Follow up to my last post

jacob navia jacob@jacob.remcomp.fr
Mon Aug 28 07:04:53 GMT 2023


OK

Just do nothing. It is the best solution.

The assembler doesn’t assemble instructions recognized by the machine it is running on?

The user should use the undocumented march=xxx option. And if he doesn’t read the inexistent documentation, that’s his/her fault.

Thank you very much for your attention

Jacob


> Le 28 août 2023 à 08:17, Jan Beulich <jbeulich@suse.com> a écrit :
> 
> On 25.08.2023 21:44, jacob navia wrote:
>> I am just invoking the assembler with its default settings:
>> 
>> ~/star64 $ as -o test.o test.s
>> 
>> The assembler is testing the default architecture here:
>> Function: riscv_ip
>> 
>> 	for (; insn && insn->name && strcmp(insn->name,str) == 0; insn++) {
>> #if 0
>> 		if ((insn->xlen_requirement != 0) && (xlen != insn->xlen_requirement))
>> 			continue;
>> 
>> 		if (!riscv_multi_subset_supports(&riscv_rps_as,insn->insn_class)) {
>> 			error.missing_ext = riscv_multi_subset_supports_ext(&riscv_rps_as,
>> 							    insn->insn_class);
>> 			continue;
>> 		}
>> #endif
>> 
>> The #if 0/#endif were added by me. I think those tests do not belong here. The assembler should assemble and not test if the instruction is legal. If the instruction is illegal the program will crash at run-time, something not that unusual if you are programming in assembler!
> 
> Having a program crash at runtime when this can be avoided at build time is
> deemed undesirable by many people, including me. I did point out before that
> there are two approaches for assemblers - default-enabling everything and
> default-disabling everything except the base architecture insns. To a large
> part this is a decision to be taken by the people writing an assembler. But
> there are technical constraints as well: As soon as you have two conflicting
> extensions (which RISC-V was always allowing for, and which it now actively
> has), the former model won't work very well anymore.
> 
> Of course you're free to propose a patch allowing the alternative model (via
> command line option and/or directive). Obviously whether that'll be approved
> is unknown up front.
> 
>> And if you are assembling compiler output, it is up to the compiler to furnish the correct instructions.
> 
> Yes. Plus, with an assembler following the former model, the necessary
> directives. (As an aside, compilers aren't bug-free, and hence the assembler
> still applying some sanity checks makes some sense.)
> 
>> Tiny-asm doesn’t test any instruction compliance and that is why it works out of the box!
> 
> As said, which model to use is up to the writers of any particular assembler.
> 
> Jan



More information about the Binutils mailing list