[PATCH v4 2/2] ld: Add minimal pdb generation
Mark Harmstone
mark@harmstone.com
Wed Oct 12 00:31:16 GMT 2022
On 12/10/22 01:28, Alan Modra wrote:
> On Tue, Oct 11, 2022 at 06:53:32PM +0100, Mark Harmstone wrote:
>> +/* Calculate the hash of a given string. */
>> +static uint32_t
>> +calc_hash (const char *data, size_t len)
>> +{
>> + uint32_t hash = 0;
>> +
>> + while (len >= 4)
>> + {
>> + hash ^= *(uint32_t *) data;
>> + data += 4;
>> + len -= 4;
>> + }
>> +
>> + if (len >= 2)
>> + {
>> + hash ^= *(uint16_t *) data;
>> + data += 2;
>> + len -= 2;
>> + }
>> +
>> + if (len != 0)
>> + hash ^= *data;
>> +
>> + hash |= 0x20202020;
>> + hash ^= (hash >> 11);
>> +
>> + return hash ^ (hash >> 16);
>> +}
> I think the above code will calculate different hash values on
> big-endian machines to little-endian. Also, unless "data" is aligned
> as for uint32_t you run the risk of alignment traps on machines with
> strict alignment requirements.
>
Okay, thanks Alan. Can we get the first patch accepted while I investigate this?
Mark
More information about the Binutils
mailing list