m68k: Simple loop compiles into boundless recursion with -O2

Fredrik Noring noring@nocrew.org
Wed Jan 13 16:30:35 GMT 2021


Many thanks, Alexander,

> Please invoke objdump with -dr instead to see the relocations.

Indeed:

  1a:	4eb9 0000 0000 	jsr 0 <memset2>
			1c: R_68K_32	memset

> The relocation associated with this instruction should point to memset.
> Most likely the compiler is optimizing your memset2 function to call
> the standard function 'memset'.
> 
> When implementing memset itself you need to pass -ffreestanding to GCC,
> which will disable this optimization.

Yes, I had -nostdlib but -ffreestanding is apparently needed as well. Thanks
again.

Fredrik


More information about the Gcc-help mailing list