[PATCH v4 2/5] CRC64 testsuite

Ulf Samuelsson binutils@emagii.com
Tue Feb 28 13:01:10 GMT 2023


I am considering ”cheating” by always storing the CRC as big endian.
That would simplify the test.
It would also make the CRC readable in the text output.
Drawback is of course that small endian targets would have to swap the CRC before use.

Best Regards
Ulf Samuelsson

> 28 feb. 2023 kl. 13:37 skrev Nick Clifton <nickc@redhat.com>:
> 
> Hi Ulf,
> 
>>  * CRC64-ECMA
>>  * CRC64-ISO
>>  * CRC64-WE
>>  * CRC64-XZ
>>  * CRC64-POLY
>>  * CRC32
>>  * CRC32-POLY
> 
> As a matter of interest, where are these names and algorithms defined ?
> Is there a ISO standard for them, for example ?
> 
>> * Is there a way to select one of two tests within the test framework
>>    based on endianess of the build and target machines?
> 
> Hmm, tricky.  The short answer is "no", as in there is no handy proc
> that you can invoke to determine the endian-ness of the target.
> 
> But, in fact there is a way, it is just a little bit complicated.
> The linker supports two command line options to select the endian-ness
> of the output: -EL and -EB.  So you can run a quick test of the linker
> to see if it accepts one of them:
> 
>  global ld
>  set big_endian 0
>  if { [run_host_cmd_yesno $ld "-EB -e 0 -o /dev/null foo.o"] } {
>     set big_endian 1
>  }
> 
> But - this will not help with targets that support both big- and
> little- endian variations.  So you need to check for those first:
> 
>  global ld
>  set big_endian 0
>  if [string equal [big_or_little_endian] " -EB"] then {
>    set big_endian 1
>  } else {
>        if { [run_host_cmd_yesno $ld "-EB -e 0 -o /dev/null foo.o"] } {
>             set big_endian 1
>        }
>  }
> 
> I have not actually tried this code in practice, but in theory it
> should work.  It does presume that you have a handy "foo.o" available
> which will link without errors so you may need to some code to create
> that in the first place.
> 
> Cheers
>  Nick
> 
> 


More information about the Binutils mailing list