Advertisement

このページを編集する際は,編集に関する方針に従ってください.

概要

4861 /* Emit an assembler directive to make the symbol for DECL an alias to
4862    the symbol for TARGET.  */

引数

実装

4864 void
4865 assemble_alias (tree decl, tree target)
4866 {
4867   tree target_decl;
4868   bool is_weakref = false;
4869 
4870   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
4871     {
4872       tree alias = DECL_ASSEMBLER_NAME (decl);
4873 
4874       is_weakref = true;
4875 
4876       ultimate_transparent_alias_target (&target);
4877 
4878       if (alias == target)
4879         error ("weakref %q+D ultimately targets itself", decl);
4880       else
4881         {
4882 #ifndef ASM_OUTPUT_WEAKREF
4883           IDENTIFIER_TRANSPARENT_ALIAS (alias) = 1;
4884           TREE_CHAIN (alias) = target;
4885 #endif
4886         }
4887     }
4888   else
4889     {
4890 #if !defined (ASM_OUTPUT_DEF)
4891 # if !defined(ASM_OUTPUT_WEAK_ALIAS) && !defined (ASM_WEAKEN_DECL)
4892       error ("%Jalias definitions not supported in this configuration", decl);
4893       return;
4894 # else
4895       if (!DECL_WEAK (decl))
4896         {
4897           error ("%Jonly weak aliases are supported in this configuration", decl);
4898           return;
4899         }
4900 # endif
4901 #endif
4902     }
4903 
4904   /* We must force creation of DECL_RTL for debug info generation, even though
4905      we don't use it here.  */
4906   make_decl_rtl (decl);
4907   TREE_USED (decl) = 1;
4908 
4909   /* A quirk of the initial implementation of aliases required that the user
4910      add "extern" to all of them.  Which is silly, but now historical.  Do
4911      note that the symbol is in fact locally defined.  */
4912   if (! is_weakref)
4913     DECL_EXTERNAL (decl) = 0;
4914 
4915   /* Allow aliases to aliases.  */
4916   if (TREE_CODE (decl) == FUNCTION_DECL)
4917     cgraph_node (decl)->alias = true;
4918   else
4919     cgraph_varpool_node (decl)->alias = true;
4920 
4921   /* If the target has already been emitted, we don't have to queue the
4922      alias.  This saves a tad o memory.  */
4923   target_decl = find_decl_and_mark_needed (decl, target);
4924   if (target_decl && TREE_ASM_WRITTEN (target_decl))
4925     do_assemble_alias (decl, target);
4926   else
4927     {
4928       alias_pair *p = VEC_safe_push (alias_pair, gc, alias_pairs, NULL);
4929       p->decl = decl;
4930       p->target = target;
4931     }
4932 }
4933 
4934 /* Emit an assembler directive to set symbol for DECL visibility to
4935    the visibility type VIS, which must not be VISIBILITY_DEFAULT.  */
4936 
4937 void
4938 default_assemble_visibility (tree decl, int vis)
4939 {
4940   static const char * const visibility_types[] = {
4941     NULL, "internal", "hidden", "protected"
4942   };
4943 
4944   const char *name, *type;
4945 
4946   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
4947   type = visibility_types[vis];
4948 
4949 #ifdef HAVE_GAS_HIDDEN
4950   fprintf (asm_out_file, "\t.%s\t", type);
4951   assemble_name (asm_out_file, name);
4952   fprintf (asm_out_file, "\n");
4953 #else
4954   warning (OPT_Wattributes, "visibility attribute not supported "
4955            "in this configuration; ignored");
4956 #endif
4957 }


リンク元

特に記載のない限り、コミュニティのコンテンツはCC-BY-SAライセンスの下で利用可能です。