[PATCH] doc - document how gcc relies on the length of an asm

Richard Earnshaw rearnsha@arm.com
Thu Oct 2 11:35:00 GMT 2003


> Richard Earnshaw <rearnsha@arm.com> writes:
> 
> > This is a documentation update in response to PR 11442 where the
> > user had put a .skip directive in an ASM statement and this broke
> > GCC's asm size estimation rules.  It tries to make it clear that
> > this is a user error that will only be detected by the assembler.
> 
> It should be mentioned that this might not only lead to assembler
> errors, but also to silently generated bad code (PR 12108).

I don't think this is a limitation that is coming from the size estimation 
routines.  It's more fundamental than that in nature.  Can the compiler 
assume that an ASM statement can be suppressed by a single instruction?

> Also, I
> don't understand what you mean with "compiler directives that can
> expand to a large amount of space in the object file".
> 

Gak!  that should of course be "assembler directives".

> By the way, would it be possible to assert gcc's guess for the size of
> an asm by putting a label before and after it and emitting an
> ".assert" directive or something? That might avoid such errors.

I don't think gas has support for .assert (can't find anything in the 
manual under that heading).  It would be a neat idea, though, if we could 
put

L<asm_instance>:
	body of asm
	.assert "GCC asm size estimate " . - L<asm_instance> <= <size>

But you'd need to convince the gas maintainers to add the requisite 
support in the assembler first, and you might also need to suppress this 
on architectures that don't really care about instruction lengths.

R.



More information about the Gcc-patches mailing list