Esempio n. 1
0
static void
i386_pe_mark_dllimport (tree decl)
{
  const char *oldname;
  char  *newname;
  tree idp;
  rtx rtlname, newrtl;
  rtx symref;

  rtlname = XEXP (DECL_RTL (decl), 0);
  if (GET_CODE (rtlname) == SYMBOL_REF)
    oldname = XSTR (rtlname, 0);
  else if (GET_CODE (rtlname) == MEM
	   && GET_CODE (XEXP (rtlname, 0)) == SYMBOL_REF)
    oldname = XSTR (XEXP (rtlname, 0), 0);
  else
    abort ();
  if (i386_pe_dllexport_name_p (oldname))
    {
      error ("%qs declared as both exported to and imported from a DLL",
             IDENTIFIER_POINTER (DECL_NAME (decl)));
      return;
    }
  else if (i386_pe_dllimport_name_p (oldname))
    {
      /* Already done, but do a sanity check to prevent assembler errors.  */
 /* APPLE LOCAL begin mainline 2005-10-12 */
      if (!DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl)
          || !DECL_DLLIMPORT_P (decl))
        {
          error ("%Jfailure in redeclaration of '%D': dllimport'd "
                 "symbol lacks external linkage.", decl, decl);
          abort();
        }
 /* APPLE LOCAL end mainline 2005-10-12 */
      return;
    }

  newname = alloca (strlen (DLL_IMPORT_PREFIX) + strlen (oldname) + 1);
  sprintf (newname, "%s%s", DLL_IMPORT_PREFIX, oldname);

  /* We pass newname through get_identifier to ensure it has a unique
     address.  RTL processing can sometimes peek inside the symbol ref
     and compare the string's addresses to see if two symbols are
     identical.  */
  idp = get_identifier (newname);

  symref = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp));
  SYMBOL_REF_DECL (symref) = decl;
  newrtl = gen_rtx_MEM (Pmode,symref);
  XEXP (DECL_RTL (decl), 0) = newrtl;

 /* APPLE LOCAL begin mainline 2005-10-12 */
  DECL_DLLIMPORT_P (decl) = 1;
 /* APPLE LOCAL end mainline 2005-10-12 */
}
Esempio n. 2
0
static void
i386_pe_mark_dllimport (tree decl)
{
    const char *oldname;
    char  *newname;
    tree idp;
    rtx rtlname, newrtl;
    rtx symref;

    rtlname = XEXP (DECL_RTL (decl), 0);
    if (GET_CODE (rtlname) == MEM)
        rtlname = XEXP (rtlname, 0);
    gcc_assert (GET_CODE (rtlname) == SYMBOL_REF);
    oldname = XSTR (rtlname, 0);
    if (i386_pe_dllexport_name_p (oldname))
    {
        error ("%qs declared as both exported to and imported from a DLL",
               IDENTIFIER_POINTER (DECL_NAME (decl)));
        return;
    }
    else if (i386_pe_dllimport_name_p (oldname))
    {
        /* Already done, but do a sanity check to prevent assembler
        errors.  */
        gcc_assert (DECL_EXTERNAL (decl) && TREE_PUBLIC (decl)
                    && DECL_DLLIMPORT_P (decl));
        return;
    }

    newname = alloca (strlen (DLL_IMPORT_PREFIX) + strlen (oldname) + 1);
    sprintf (newname, "%s%s", DLL_IMPORT_PREFIX, oldname);

    /* We pass newname through get_identifier to ensure it has a unique
       address.  RTL processing can sometimes peek inside the symbol ref
       and compare the string's addresses to see if two symbols are
       identical.  */
    idp = get_identifier (newname);

    symref = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp));
    SET_SYMBOL_REF_DECL (symref, decl);
    newrtl = gen_rtx_MEM (Pmode,symref);
    XEXP (DECL_RTL (decl), 0) = newrtl;

    DECL_DLLIMPORT_P (decl) = 1;
}
Esempio n. 3
0
static void
i386_pe_mark_dllexport (tree decl)
{
  const char *oldname;
  char  *newname;
  rtx rtlname;
  rtx symref;
  tree idp;

  rtlname = XEXP (DECL_RTL (decl), 0);
  if (GET_CODE (rtlname) == SYMBOL_REF)
    oldname = XSTR (rtlname, 0);
  else if (GET_CODE (rtlname) == MEM
	   && GET_CODE (XEXP (rtlname, 0)) == SYMBOL_REF)
    oldname = XSTR (XEXP (rtlname, 0), 0);
  else
    abort ();
  if (i386_pe_dllimport_name_p (oldname))
    {
      warning ("%Jinconsistent dll linkage for '%D', dllexport assumed.",
	       decl, decl);
     /* Remove DLL_IMPORT_PREFIX.  */
      oldname += strlen (DLL_IMPORT_PREFIX);
      DECL_NON_ADDR_CONST_P (decl) = 0;
    }
  else if (i386_pe_dllexport_name_p (oldname))
    return;  /*  already done  */

  newname = alloca (strlen (DLL_EXPORT_PREFIX) + strlen (oldname) + 1);
  sprintf (newname, "%s%s", DLL_EXPORT_PREFIX, oldname);

  /* We pass newname through get_identifier to ensure it has a unique
     address.  RTL processing can sometimes peek inside the symbol ref
     and compare the string's addresses to see if two symbols are
     identical.  */
  idp = get_identifier (newname);

  symref = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp));
  SYMBOL_REF_DECL (symref) = decl;
  XEXP (DECL_RTL (decl), 0) = symref;
}