Port-powerpc archive

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

powerpc-elf-netbsd patch for gcc-2.8.0



I made a "powerpc-elf-netbsd" patch for gcc-2.8.0
to get kernel's and userland's profile in powerpc-world.

But, this is really experimental.
Please let me know what is wrong with these patches.

# I am not successful in still taking profile of kernel...
# kgmon -b ... kernel stall ...


userland's profiling:

1. patch and make gcc-2.8.0 with --target=powerpc-elf-netbsd.
2. copy profile.h DESTDIR/usr/include/machine.
3. patch DESTDIR/usr/share/mk/bsd.own.mk.
4. make library (libc.a, libc_p.a, and so on) and install to DESTDIR.

   we must change lib/libc/arch/powerpc/sys/brk.S to use minbrk.
   I haven't been changed yet...

5. make gprof
 cd gnu/dist/gprof
 cp ns532.c powerpc.c
 cp ns532.h powerpc.h
 cd ../../usr.bin/gprof
 make

6. powerpc-elf-netbsd-gcc -pg foo.c and gprof.

Kazuki Sakamoto
sakamoto%cec.co.jp@localhost

---cut here---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#       bsd.own.mk-diffs
#       gcc-2.8.0-diffs
#       profile.h
#
echo x - bsd.own.mk-diffs
sed 's/^X//' >bsd.own.mk-diffs << 'END-of-bsd.own.mk-diffs'
X*** bsd.own.mk.orig    Mon Feb 23 12:34:54 1998
X--- bsd.own.mk Mon Feb 23 12:35:06 1998
X***************
X*** 78,86 ****
X  .endif
X  
X  # Profiling doesn't work on PowerPC yet.
X! .if (${MACHINE_ARCH} == "powerpc")
X! NOPROFILE=
X! .endif
X  
X  TARGETS+=    all clean cleandir depend includes install lint obj regress \
X               tags
X--- 78,86 ----
X  .endif
X  
X  # Profiling doesn't work on PowerPC yet.
X! #.if (${MACHINE_ARCH} == "powerpc")
X! #NOPROFILE=
X! #.endif
X  
X  TARGETS+=    all clean cleandir depend includes install lint obj regress \
X               tags
END-of-bsd.own.mk-diffs
echo x - gcc-2.8.0-diffs
sed 's/^X//' >gcc-2.8.0-diffs << 'END-of-gcc-2.8.0-diffs'
X*** configure.orig     Tue Dec 23 20:19:51 1997
X--- configure  Sun Feb 22 21:42:15 1998
X***************
X*** 4517,4522 ****
X--- 4517,4529 ----
X               fi
X               xmake_file=rs6000/x-sysv4
X               ;;
X+      powerpc-elf-netbsd*)
X+              tm_file=rs6000/netbsd.h
X+              xm_file=rs6000/xm-netbsd.h
X+              fixincludes=Makefile.in
X+              tmake_file=t-libc-ok
X+              xmake_file=x-netbsd
X+              ;;
X       powerpc-*-eabiaix*)
X               tm_file=rs6000/eabiaix.h
X               tmake_file="rs6000/t-ppcgas rs6000/t-ppccomm"
X*** /dev/null  Sun Feb 22 21:40:42 1998
X--- config/rs6000/netbsd.h     Sun Feb 22 21:40:27 1998
X***************
X*** 0 ****
X--- 1,72 ----
X+ #include <rs6000/sysv4.h>
X+ 
X+ /* Get generic NetBSD definitions.  */
X+ 
X+ #include <netbsd.h>
X+ 
X+ /* Use bcopy etc. instead of memcpy etc. */
X+ #undef       TARGET_MEM_FUNCTIONS
X+ 
X+ /* Names to predefine in the preprocessor for this target machine.  */
X+ #undef       CPP_PREDEFINES
X+ #define CPP_PREDEFINES "-D__powerpc__ -D__PPC__ -D__NetBSD__ -Asystem(unix) 
-Asystem(NetBSD) -Acpu(powerpc) -Amachine(powerpc)"
X+ 
X+ /* Make gcc agree with <machine/ansi.h> */
X+ 
X+ #undef SIZE_TYPE
X+ #define SIZE_TYPE "unsigned int"
X+ 
X+ #undef PTRDIFF_TYPE
X+ #define PTRDIFF_TYPE "int"
X+ 
X+ #undef WCHAR_TYPE
X+ #define WCHAR_TYPE "int"
X+ 
X+ #undef WCHAR_TYPE_SIZE
X+ #define WCHAR_TYPE_SIZE 32
X+ 
X+ /* Don't default to pcc-struct-return, because gcc is the only compiler, and
X+    we want to retain compatibility with older gcc versions.  */
X+ #define DEFAULT_PCC_STRUCT_RETURN 0
X+ 
X+ /* Until gcc uses fixed functions on procedure entry, -mmultiple is probably
X+    more efficient due to smaller code and less cache thrashing.  */
X+ #undef       CC1_SPEC
X+ #define      CC1_SPEC        "-mmultiple"
X+ 
X+ /* We want a implemetation reserved symbol for the entry point! */
X+ #undef       LINK_SPEC
X+ #define      LINK_SPEC       "%{!nostdlib:%{!r*:%{!e*:-e _start}}} -dc -dp 
%{static:-Bstatic} %{assert*}"
X+ 
X+ /* Provide a STARTFILE_SPEC appropriate for NetBSD.  Here we add
X+    the crtbegin.o file (see crtstuff.c) which provides part of the
X+    support for getting C++ file-scope static object constructed
X+    before entering `main'. */
X+    
X+ #undef       STARTFILE_SPEC
X+ #define STARTFILE_SPEC \
X+  "%{!shared: \
X+      %{pg:gcrt0.o%s} \
X+      %{!pg: \
X+      %{p:gcrt0.o%s} \
X+      %{!p:crt0.o%s}}} \
X+    %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
X+ 
X+ /* Provide a ENDFILE_SPEC appropriate for NetBSD.  Here we tack on
X+    the file which provides part of the support for getting C++
X+    file-scope static object deconstructed after exiting `main' */
X+ 
X+ #undef       ENDFILE_SPEC
X+ #define ENDFILE_SPEC \
X+   "%{!shared:crtend.o%s} %{shared:crtendS.o%s}"
X+ 
X+ #undef       FUNCTION_PROFILER
X+ #define FUNCTION_PROFILER(FILE, LABELNO) \
X+ {                                                                    \
X+      fprintf (FILE, "\tmflr %s\n", reg_names[0]);                    \
X+      fprintf (FILE, "\tstw %s,4(%s)\n", reg_names[0], reg_names[1]); \
X+ /* XXX PIC?? */                                                              
\
X+      fprintf (FILE, "\tbl _mcount\n");                               \
X+      fprintf (FILE, "\tlwz %s,4(%s)\n", reg_names[0], reg_names[1]); \
X+      fprintf (FILE, "\tmtlr %s\n", reg_names[0]);                    \
X+ }
X*** /dev/null  Sun Feb 22 21:40:42 1998
X--- config/rs6000/xm-netbsd.h  Fri Feb 20 19:08:02 1998
X***************
X*** 0 ****
X--- 1,9 ----
X+ /* Configuration for GCC for PowerPC running NetBSD as host.  */
X+ 
X+ #include <rs6000/xm-rs6000.h>
X+ 
X+ /* NetBSD isn't SysV */
X+ #undef       USG
X+ 
X+ /* Not needed on NetBSD (really?) */
X+ #undef       COLLECT_EXPORT_LIST
END-of-gcc-2.8.0-diffs
echo x - profile.h
sed 's/^X//' >profile.h << 'END-of-profile.h'
X/*     $NetBSD: profile.h,v 1.1 1997/10/14 06:48:35 sakamoto Exp $     */
X
X/*
X * Copyright (c) 1992, 1993
X *     The Regents of the University of California.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *     This product includes software developed by the University of
X *     California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X *     @(#)profile.h   8.1 (Berkeley) 6/11/93
X */
X
X#define        _MCOUNT_DECL    void mcount
X
X#define        MCOUNT __asm__ ("
X       .globl  _mcount;
X_mcount:;
X       mflr    0;
X       stwu    1, -48(1);      /* save register */
X       stw     0, 44(1);
X       stw     3, 40(1);
X       stw     4, 36(1);
X       stw     5, 32(1);
X       stw     6, 28(1);
X       stw     7, 24(1);
X       stw     8, 20(1);
X       stw     9, 16(1);
X       stw     10, 12(1);
X       stw     11, 8(1);
X       stw     12, 4(1);
X
X       mr      3, 0;           /* selfpc */
X       lwz     4, 52(1);       /* frompc */
X       bl      mcount;
X
X       lwz     0, 44(1);       /* restore register */
X       lwz     3, 40(1);
X       lwz     4, 36(1);
X       lwz     5, 32(1);
X       lwz     6, 28(1);
X       lwz     7, 24(1);
X       lwz     8, 20(1);
X       lwz     9, 16(1);
X       lwz     10, 12(1);
X       lwz     11, 8(1);
X       lwz     12, 4(1);
X       mtlr    0;
X       lwz     1, 0(1);
X       blr;
X");
X
X#ifdef _KERNEL
X#define        MCOUNT_ENTER    s = splhigh()
X#define        MCOUNT_EXIT     splx(s)
X#endif
END-of-profile.h
exit



Home | Main Index | Thread Index | Old Index