PATCH: Support IMAGE_SCN_ALIGN_XXXXBYTES

Nick Clifton nickc@redhat.com
Wed Aug 1 17:12:00 GMT 2007
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





More information about the Binutils mailing list