This is the mail archive of the binutils@sources.redhat.com 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]

Bug (and fix) in gas: frags.c @ frag_align


Hi,

As I have reported already, I had a problem with alignment in absolute
section.
I found the bug in frags.c file in frag_align function.

Old code:
---------
      new_off = ((abs_section_offset + alignment - 1)
   &~ ((1 << alignment) - 1));
---------

When abs_section_offset == 1 and alignment == 1 then new_off should be == 2

In the above code new_off == 0

The proposed new code:
-------------------
if ((abs_section_offset & ((1 << alignment) - 1)) != 0)
    new_off = ((abs_section_offset  >> alignment) + 1) << alignment;
else
    new_off = abs_section_offset;    /* aligned already */
-------------------

Serge






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