This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Support IMAGE_SCN_ALIGN_XXXXBYTES
- From: Nick Clifton <nickc at redhat dot com>
- To: "H.J. Lu" <hjl at lucon dot org>
- Cc: binutils at sources dot redhat dot com, cgf at redhat dot com
- Date: Wed, 01 Aug 2007 18:12:09 +0100
- Subject: Re: PATCH: Support IMAGE_SCN_ALIGN_XXXXBYTES
- References: <20070726213010.GA11828@lucon.org>
Hi H.J.
This patch supports IMAGE_SCN_ALIGN_XXXXBYTES. OK to install?
Not quite...
+ case IMAGE_SCN_ALIGN_4BYTES:
+ case IMAGE_SCN_ALIGN_2BYTES:
+ case IMAGE_SCN_ALIGN_1BYTES:
+ section->alignment_power = (alignment_power >> 20) - 1;
I like this, but I do not like the presence of the magic number 20.
I think that using a macro would be better. eg:
section->alignment_power = IMAGE_SCN_ALIGN_NUMBER (alignment_power) - 1;
And then in pe.h....
/* Bit position in the s_flags field where the alignment values start. */
#define IMAGE_SCN_ALIGN_BIT_POS 20
#define IMAGE_SCN_ALIGN_NUMBER(val) ((val) >> IMAGE_SCN_ALIGN_BIT_POS)
#define IMAGE_SCN_ALIGN_CONSTANT(val) ((val) << IMAGE_SCN_ALIGN_BIT_POS)
#define IMAGE_SCN_ALIGN_1BYTES IMAGE_SCN_ALIGN_CONSTANT(1)
#define IMAGE_SCN_ALIGN_2BYTES IMAGE_SCN_ALIGN_CONSTANT(2)
...
#define IMAGE_SCN_ALIGN_8129BYTES IMAGE_SCN_ALIGN_CONSTANT(15)
Cheers
Nick