Port-mips archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mcount.c / profile.h and fatal assembler warnings



On Mon, Jul 28, 2008 at 11:42:34AM +0200, Havard Eidnes wrote:
  | as should be well-known by now, the compilation of mcount.c now
  | fails on all our mips ports.  The reason this has recently
  | started happning is that assembler warnings have were recently
  | made fatal errors, through a change to <bsd.sys.mk>.  The warning
  | emitted is:
  | 
  | /var/tmp//ccXs67rq.s: Assembler messages:
  | /var/tmp//ccXs67rq.s:9: Warning: No .cprestore pseudo-op used in PIC code
  | /var/tmp//ccXs67rq.s:219: Error: 1 warnings, treating warnings as errors
  | --- mcount.o ---

I discussed your proposal with Simon, and he wasn't 100% sure that
your suggested fix is correct.

I've committed a workaround to gmon/Makefile.inc to disable assembler
warnings for mcount.c on mips.

Once a fix is available that the MIPS gurus are happy with,
we can remove the workaround.

I apologise for taking so long to getting to this workaround,
and appreciate your effort in trying to fix it despite my slackness.

cheers,
Luke.


  | 
  | This traces back to the assembly code in the MCOUNT macro in
  | sys/arch/mips/include/profile.h, which defines the _mcount symbol
  | and which calls the __mcount function, which is implemented in C,
  | and which is in common/lib/libc/gmon/mcount.c.
  | 
  | Now, if one were to just blindly follow the warnings from the
  | assembler, one would quickly discover that once you insert
  | ".cprestore 24" into the assembly code, it next complains there
  | is no ".frame", and then that there is no ".ent", and lastly that
  | there is no ".end".
  | 
  | I have "fixed" all those things in my local source tree, but
  | since I'm no MIPS assembly expert, I suspect that _mcount() is no
  | longer working as it should, as it is now more or less a full-
  | fledged function, and I think the point of the assembly code is
  | to *not* be a full-fledged function.
  | 
  | Can anyone please tell me if it's possible to implement _mcount()
  | on MIPS without getting assembly warnings?
  | 
  | My feeble and most likely faulty attempt follows attached below.
  | 
  | Regards,
  | 
  | - H?vard

  | Index: profile.h
  | ===================================================================
  | RCS file: /u/nb/src/sys/arch/mips/include/profile.h,v
  | retrieving revision 1.20
  | diff -u -p -r1.20 profile.h
  | --- profile.h   24 Dec 2005 23:24:01 -0000      1.20
  | +++ profile.h   28 Jul 2008 08:45:32 -0000
  | @@ -52,8 +52,18 @@
  |  
  |  #ifdef _KERNEL
  |  # define _PROF_CPLOAD  ""
  | +# define _PROF_CPRESTORE ""
  | +# define _PROF_FRAME   ""
  | +# define _PROF_ENT     ""
  | +# define _PROF_END     ""
  |  #else
  |  # define _PROF_CPLOAD  ".cpload $25;"
  | +/* 24 is the next free slot on the stack (sp=$29), ref. code below */
  | +# define _PROF_CPRESTORE ".cprestore 24;"
  | +/* 40 = 6 regs (=24), 2 args (=8), and 8(?) bytes for gp */
  | +# define _PROF_FRAME   ".frame $sp,40,$31;"
  | +# define _PROF_ENT     ".ent _mcount;"
  | +# define _PROF_END     ".end _mcount; .size _mcount, .-_mcount;"
  |  #endif
  |  
  |  
  | @@ -64,7 +74,9 @@
  |  #define        MCOUNT \
  |         __asm(".globl _mcount;" \
  |         ".type _mcount,@function;" \
  | +       _PROF_ENT \
  |         "_mcount:;" \
  | +       _PROF_FRAME \
  |         ".set noreorder;" \
  |         ".set noat;" \
  |         _PROF_CPLOAD \
  | @@ -75,6 +87,7 @@
  |         "sw $7,20($29);" \
  |         "sw $1,0($29);" \
  |         "sw $31,4($29);" \
  | +       _PROF_CPRESTORE \
  |         "move $5,$31;" \
  |         "move $4,$1;" \
  |         "jal __mcount;" \
  | @@ -89,7 +102,9 @@
  |         "j $31;" \
  |         "move $31,$1;" \
  |         ".set reorder;" \
  | -       ".set at");
  | +       ".set at;" \
  | +       _PROF_END \
  | +       );
  |  
  |  #ifdef _KERNEL
  |  /*

Attachment: pgpHtUuBxqaWW.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index