From 40fbfbea4895951571325e3f83acb6d0251fde04 Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Fri, 8 Oct 1993 19:15:55 +0000 Subject: Make ROSE shared library profiling work; Use GOTOFF if possible for ELF. From-SVN: r5684 --- gcc/config/i386/osfrose.h | 46 ++++++++++++++++++++++++++++++++++++++++++---- gcc/halfpic.c | 24 ++++++++++++++++++++++++ gcc/halfpic.h | 2 ++ 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/gcc/config/i386/osfrose.h b/gcc/config/i386/osfrose.h index 524b541..3ac9211 100644 --- a/gcc/config/i386/osfrose.h +++ b/gcc/config/i386/osfrose.h @@ -182,11 +182,27 @@ do \ \ if (profile_flag && OSF_PROFILE_BEFORE_PROLOGUE) \ { \ - if (!flag_pic) \ + if (!flag_pic && !HALF_PIC_P ()) \ { \ - fprintf (FILE, "\tleal %sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ fprintf (FILE, "\tcall *%s_mcount_ptr\n", prefix); \ } \ + \ + else if (HALF_PIC_P ()) \ + { \ + rtx symref; \ + \ + HALF_PIC_EXTERNAL ("_mcount_ptr"); \ + symref = HALF_PIC_PTR (gen_rtx (SYMBOL_REF, Pmode, \ + "_mcount_ptr")); \ + \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tmovl %s%s,%%eax\n", prefix, \ + XSTR (symref, 0)); \ + fprintf (FILE, "\tmovl (%%eax),%%eax\n"); \ + fprintf (FILE, "\tcall *%%eax\n"); \ + } \ + \ else \ { \ static int call_no = 0; \ @@ -199,6 +215,7 @@ do \ lprefix, labelno); \ fprintf (FILE, "\tmovl %s_mcount_ptr@GOT(%%eax),%%eax\n", \ prefix); \ + fprintf (FILE, "\tmovl (%%eax),%%eax\n"); \ fprintf (FILE, "\tcall *%%eax\n"); \ } \ } \ @@ -246,6 +263,17 @@ do \ fprintf (FILE, "\tcall *%smcount@GOT(%%ebx)\n", prefix); \ } \ \ + else if (TARGET_MCOUNT && HALF_PIC_P ()) \ + { \ + rtx symdef; \ + \ + HALF_PIC_EXTERNAL ("mcount"); \ + symdef = HALF_PIC_PTR (gen_rtx (SYMBOL_REF, Pmode, "mcount")); \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tmovl %s%s,%%eax\n", prefix, XSTR (symdef, 0)); \ + fprintf (FILE, "\tcall *%%eax\n"); \ + } \ + \ else if (TARGET_MCOUNT) \ { \ fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ @@ -259,6 +287,7 @@ do \ fprintf (FILE, "\tleal $%sP%d@GOTOFF(%%ebx),%%edx\n", \ lprefix, labelno); \ fprintf (FILE, "\tmovl _mcount_ptr@GOT(%%eax),%%eax\n"); \ + fprintf (FILE, "\tmovl (%%eax),%%eax\n"); \ fprintf (FILE, "\tcall *%%eax\n"); \ fprintf (FILE, "\tpopl %%eax\n"); \ } \ @@ -267,7 +296,7 @@ do \ { \ fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n"); \ fprintf (FILE, "\tpushl %%ecx\n"); \ - fprintf (FILE, "\tleal $%sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ fprintf (FILE, "\tcall *_mcount_ptr\n"); \ fprintf (FILE, "\tpopl %%eax\n"); \ } \ @@ -565,8 +594,17 @@ while (0) #define ENCODE_SECTION_INFO(DECL) \ do \ { \ - if (HALF_PIC_P ()) \ + if (HALF_PIC_P ()) \ HALF_PIC_ENCODE (DECL); \ + \ + else if (flag_pic) \ + { \ + rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ + ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \ + SYMBOL_REF_FLAG (XEXP (rtl, 0)) \ + = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ + || ! TREE_PUBLIC (DECL)); \ + } \ } \ while (0) diff --git a/gcc/halfpic.c b/gcc/halfpic.c index 6447539..53ba12f 100644 --- a/gcc/halfpic.c +++ b/gcc/halfpic.c @@ -268,6 +268,30 @@ half_pic_declare (name) } +/* Mark that an object is explicitly external. */ + +void +half_pic_external (name) + char *name; +{ + struct all_refs *ptr; + + if (!flag_half_pic) + return; + + ptr = half_pic_hash (name, 0, TRUE); + if (!ptr) + return; + + ptr->external_p = TRUE; + +#ifdef HALF_PIC_DEBUG + if (HALF_PIC_DEBUG) + fprintf (stderr, "\n========== Half_pic_external %s\n", name); +#endif +} + + /* Return whether an address is half-pic. */ int diff --git a/gcc/halfpic.h b/gcc/halfpic.h index f251371..7e274d3 100644 --- a/gcc/halfpic.h +++ b/gcc/halfpic.h @@ -57,6 +57,7 @@ extern int half_pic_number_ptrs; /* # distinct pointers found */ extern int half_pic_number_refs; /* # half-pic references */ extern void half_pic_encode PROTO((union tree_node *)); /* encode whether half-pic */ extern void half_pic_declare PROTO((char *)); /* declare object local */ +extern void half_pic_external PROTO((char *)); /* declare object external */ extern void half_pic_init PROTO((void)); /* half_pic initialization */ extern void half_pic_finish STDIO_PROTO((FILE *)); /* half_pic termination */ extern int half_pic_address_p PROTO((struct rtx_def *)); /* true if an address is half-pic */ @@ -71,6 +72,7 @@ extern struct rtx_def *half_pic_ptr PROTO((struct rtx_def *)); /* return RTX for #define HALF_PIC_ENCODE(DECL) half_pic_encode (DECL) #define HALF_PIC_DECLARE(NAME) half_pic_declare (NAME) +#define HALF_PIC_EXTERNAL(NAME) half_pic_external (NAME) #define HALF_PIC_INIT() half_pic_init () #define HALF_PIC_FINISH(STREAM) half_pic_finish (STREAM) #define HALF_PIC_ADDRESS_P(X) ((*ptr_half_pic_address_p) (X)) -- cgit v1.1