This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Support IMAGE_SCN_ALIGN_XXXXBYTES


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]