ARM/Thumb padding by gas

Nick Clifton nickc@redhat.com
Tue Feb 3 17:07:00 GMT 2009


Hi Christophe,

> I don't understand why app_func2 is padded with Thumb NOPs while it is 
> written in ARM mode. If I remove the .thumb_func directive (after lab2), 
> then the padding is encoded in ARM.
> 
> I tried to understand where gas does this padding, but I couldn't find it.

Indeed this is most confusing.  The padding bytes are being chosen in 
gas/config/tc-arm:arm_handle_align() where the current output fragment 
is padded up to an alignment boundary.

The choice of ARM or THUMB instruction padding is based on the value of 
the tc_frag_data field which is set to be a copy of the value of the 
thumb_mode variable when the frag is initialised.  The problem is that 
it appears that the ARM code in your .text section appears to have been 
placed into a frag that has tc_frag_data set to 1 (for THUMB no-ops).

Looking into it further it seems that frags can be allocated and used 
*before* the arm_init_frag() routine is called.  (Why this should be I 
do not know).

Anyway this is a bug.  Please could you open a bugzilla PR for it.  I 
have a patch to fix the problem, but I would like the problem to be 
officially recorded.

Cheers
   Nick






More information about the Binutils mailing list