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]

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


On Fri, 21 Jul 2000, Serge Nikulin wrote:

> I found the bug in frags.c file in frag_align function.
> 
>       new_off = ((abs_section_offset + alignment - 1)
>    &~ ((1 << alignment) - 1));

Yes, that's broken.  I'm checking in the following to fix it.

Thanks, Alan Modra
-- 
Linuxcare.  Support for the Revolution.


gas/ChangeLog
	* frags.c (frag_align): Correct absolute section alignment.

Index: frags.c
===================================================================
RCS file: /cvs/src/src/gas/frags.c,v
retrieving revision 1.5
diff -u -p -r1.5 frags.c
--- frags.c	2000/05/23 05:07:47	1.5
+++ frags.c	2000/07/22 04:11:36
@@ -303,9 +303,10 @@ frag_align (alignment, fill_character, m
   if (now_seg == absolute_section)
     {
       addressT new_off;
+      addressT mask;
 
-      new_off = ((abs_section_offset + alignment - 1)
-		 &~ ((1 << alignment) - 1));
+      mask = (~ (addressT) 0) << alignment;
+      new_off = (abs_section_offset + ~ mask) & mask;
       if (max == 0 || new_off - abs_section_offset <= (addressT) max)
 	abs_section_offset = new_off;
     }


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