From: Mark Harmstone <mark@harmstone.com>
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org, martin@martin.st
Subject: Re: [PATCH v4 2/2] ld: Add minimal pdb generation
Date: Wed, 12 Oct 2022 01:31:16 +0100 [thread overview]
Message-ID: <6b05f07a-5aca-a32e-604d-01025cdc8115@harmstone.com> (raw)
In-Reply-To: <Y0YKOe6KJ78OeDxH@squeak.grove.modra.org>
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
next prev parent reply other threads:[~2022-10-12 0:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 17:53 [PATCH v4 1/2] ld: Add --pdb option Mark Harmstone
2022-10-11 17:53 ` [PATCH v4 2/2] ld: Add minimal pdb generation Mark Harmstone
2022-10-12 0:28 ` Alan Modra
2022-10-12 0:31 ` Mark Harmstone [this message]
2022-10-11 19:06 ` [PATCH v4 1/2] ld: Add --pdb option Martin Storsjö
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6b05f07a-5aca-a32e-604d-01025cdc8115@harmstone.com \
--to=mark@harmstone.com \
--cc=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=martin@martin.st \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).