[PATCH v2] gas: add .cv_ucomp and .cv_scomp pseudo-directives
Mark Harmstone
mark@harmstone.com
Tue Nov 12 00:43:28 GMT 2024
Thanks Jan.
On 05/11/2024 14:31, Jan Beulich wrote:
> On 04.11.2024 22:21, Mark Harmstone wrote:
>> @@ -5457,6 +5464,166 @@ s_leb128 (int sign)
>> demand_empty_rest_of_line ();
>> }
>>
>> +#ifdef TE_PE
>> +
>> +/* Output a compressed CodeView integer. The return value is the number of
>> + bytes used. */
>> +
>> +unsigned int
>> +output_cv_comp (char *p, offsetT value, int sign)
>> +{
>> + char *orig = p;
>> +
>> + if (sign)
>> + {
>> + if (value >= 0)
>> + value <<= 1;
>> + else
>> + value = (-value << 1) | 1;
>
> This will badly degenerate when the incoming value is the biggest possible
> negative integer. If I'm not mistaken, you'd convert it to -0 here, which
> would then happily be emitted below, rather than triggering the warning.
You're right - this trips up UBSAN.
>> --- /dev/null
>> +++ b/gas/testsuite/gas/pe/cv_comp.d
>> @@ -0,0 +1,14 @@
>> +#objdump: -s -j .text
>> +#name: CodeView compressed integer test
>> +
>> +.*: .*
>> +
>> +Contents of section .text:
>> + 0000 21002101 212a217f 21808021 853921bf .*
>> + 0010 ff21c000 400021c0 0f424021 dfffffff .*
>> + 0020 21002102 21542180 fe218100 218a7221 .*
>> + 0030 c0007ffe 21c00080 0021c01e 848021df .*
>> + 0040 fffffe21 03215521 80ff2181 01218a73 .*
>> + 0050 21c0007f ff21c000 800121c0 1e848121 .*
>> + 0060 dfffffff 21022104 21900421 04210821 .*
>> + 0070 a0082105 210921a0 0921.*
>
> Just to double check - you tested this for all PE-capable targets, and
> it passed everywhere?
Good point, there's an awful lot of them. I'll gate it behind TE_PE && O_secrel, which
is the logic we use in gas/codeview.c, and which covers x86, amd64, and aarch64.
Aarch64 didn't like the hash comments, I'll fix that.
Mark
More information about the Binutils
mailing list