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: Fix code alignment for mixed mips16/nomips16 files


Richard Sandiford wrote:
> At the moment, ".align x" always fills with 0s on MIPS.  This is a
> problem if, for example, you're writing MIPS16 assembly code in which
> a function has multiple entry points, and in which one entry point falls
> through to another.  The natural thing would be to insert ".align 2"
> before each entry point, but 0 is not a nop in MIPS16 code.
> 
> This patch adjusts mips_align's prototype so that the function can tell
> if the default fill pattern is being used.  If so, it uses code alignment
> for code segments (just like the standard .align does) otherwise it
> continues to behave as it does now.  I think all callers of mips_align
> besides s_align should be treated as wanting the default fill sequence
> rather than a zero fill sequence.  (The choice is equivalent for
> non-code segments.)
> 
> Also, mips_handle_align currently uses the final MIPS16 setting for
> all code fills.  For .aligns, we should instead use whatever mode was
> in effect at the time the .align was assembled, and for end-of-file
> aligmments, we should use whatever mode was in effect when a .align
> or instruction was last assembled in that segment.
> 
> The patch records the last .align or instruction ISA mode for
> a segment by adding a "mips16?" field to tc_segment_info_data.
> It allows a per-relaxation choice of ISA mode by defining NOP_OPCODE
> as a "mips16?" value.  mips_handle_align can then check the first
> variable byte instead of mips_opts.mips16.
> 
> Tested on mips64-linux-gnu.  OK to install?
> 
> Richard
> 
> 
> gas/
> 	* config/tc-mips.h (mips_nop_opcode): Declare.
> 	(NOP_OPCODE): Define.
> 	(mips_segment_info): New structure.
> 	(TC_SEGMENT_INFO_TYPE): Use it instead of insn_label_list.
> 	* config/tc-mips.c (label_list): Adjust for new TC_SEGMENT_INFO_TYPE.
> 	(mips_record_mips16_mode): New function.
> 	(install_insn): Call it.
> 	(mips_align): Likewise.  Turn the fill argument into an "int *".
> 	Use frag_align_code for code segments if no fill data is given.
> 	(s_align): Adjust call accordingly.
> 	(mips_nop_opcode): New function.
> 	(mips_handle_align): Use the first variable byte to decide which
> 	nop sequence is needed.  Use md_number_to_chars and mips16_nop_insn.
> 
> gas/testsuite/
> 	* gas/mips/align2.s, gas/mips/align2.d, gas/mips/align2-el.d: New
> 	tests.
> 	* gas/mips/mips.exp: Run them.

Ok.


Thiemo


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