diff options
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index 512bc33..ac53521 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1040,6 +1040,34 @@ default_ctor_section_asm_out_constructor (rtx symbol, #define CONSTANT_POOL_BEFORE_FUNCTION 1 #endif +/* DECL is an object (either VAR_DECL or FUNCTION_DECL) which is going + to be output to assembler. + Set first_global_object_name and weak_global_object_name as appropriate. */ + +void +notice_global_symbol (tree decl) +{ + if ((!first_global_object_name || !weak_global_object_name) + && TREE_PUBLIC (decl) + && (TREE_CODE (decl) == FUNCTION_DECL + || ! (DECL_COMMON (decl) + && (DECL_INITIAL (decl) == 0 + || DECL_INITIAL (decl) == error_mark_node)))) + { + const char *p; + char *name; + rtx decl_rtl = DECL_RTL (decl); + + p = (* targetm.strip_name_encoding) (XSTR (XEXP (decl_rtl, 0), 0)); + name = xstrdup (p); + + if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl)) + first_global_object_name = name; + else + weak_global_object_name = name; + } +} + /* Output assembler code for the constant pool of a function and associated with defining the name of the function. DECL describes the function. NAME is the function's name. For the constant pool, we use the current @@ -1093,19 +1121,7 @@ assemble_start_function (tree decl, const char *fnname) if (TREE_PUBLIC (decl)) { - if (! first_global_object_name) - { - const char *p; - char *name; - - p = (* targetm.strip_name_encoding) (fnname); - name = xstrdup (p); - - if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl)) - first_global_object_name = name; - else - weak_global_object_name = name; - } + notice_global_symbol (decl); globalize_decl (decl); @@ -1400,20 +1416,8 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, } name = XSTR (XEXP (decl_rtl, 0), 0); - if (TREE_PUBLIC (decl) && DECL_NAME (decl) - && ! first_global_object_name - && ! (DECL_COMMON (decl) && (DECL_INITIAL (decl) == 0 - || DECL_INITIAL (decl) == error_mark_node)) - && ! DECL_WEAK (decl) - && ! DECL_ONE_ONLY (decl)) - { - const char *p; - char *xname; - - p = (* targetm.strip_name_encoding) (name); - xname = xstrdup (p); - first_global_object_name = xname; - } + if (TREE_PUBLIC (decl) && DECL_NAME (decl)) + notice_global_symbol (decl); /* Compute the alignment of this data. */ |