From 058430b4a1ed7441dfc2e167bfdb9dc89ea9a209 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 17 Nov 2020 12:41:36 +1030 Subject: Re: Stop Gas from generating line info or address ranges * doc/as.texi (.nop): Document optional size arg. * dwarf2dbg.c (dwarf2_gen_line_info_1): Only check SEC_ALLOC when ELF. Warn whenever dwarf line number information is ignored. * frags.c (frag_offset_ignore_align_p): New function. * frags.h (frag_offset_ignore_align_p): Declare. * read.c (s_nop): Extend to support optional size arg. * testsuite/gas/elf/dwarf2-20.d: Expect warnings, and exact range. * testsuite/gas/elf/dwarf2-20.s: Emit 16 bytes worth of nops. * testsuite/gas/m68hc11/indexed12.d: Expect warnings. --- gas/frags.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'gas/frags.c') diff --git a/gas/frags.c b/gas/frags.c index c926ec3..9ed4d7b 100644 --- a/gas/frags.c +++ b/gas/frags.c @@ -468,6 +468,48 @@ frag_offset_fixed_p (const fragS *frag1, const fragS *frag2, offsetT *offset) return FALSE; } +/* Return TRUE if FRAG2 follows FRAG1 with a fixed relationship + between the two assuming alignment frags do nothing. Set OFFSET to + the difference in address not already accounted for in the frag + FR_ADDRESS. */ + +bfd_boolean +frag_offset_ignore_align_p (const fragS *frag1, const fragS *frag2, + offsetT *offset) +{ + const fragS *frag; + offsetT off; + + /* Start with offset initialised to difference between the two frags. + Prior to assigning frag addresses this will be zero. */ + off = frag1->fr_address - frag2->fr_address; + if (frag1 == frag2) + { + *offset = off; + return TRUE; + } + + frag = frag1; + while (frag->fr_type == rs_fill + || frag->fr_type == rs_align + || frag->fr_type == rs_align_code + || frag->fr_type == rs_align_test) + { + if (frag->fr_type == rs_fill) + off += frag->fr_fix + frag->fr_offset * frag->fr_var; + frag = frag->fr_next; + if (frag == NULL) + break; + if (frag == frag2) + { + *offset = off; + return TRUE; + } + } + + return FALSE; +} + /* Return TRUE if we can determine whether FRAG2 OFF2 appears after (strict >, not >=) FRAG1 OFF1, assuming it is not before. Set *OFFSET so that resolve_expression will resolve an O_gt operation -- cgit v1.1