diff options
author | Hans-Peter Nilsson <hp@axis.com> | 2008-09-22 01:54:03 +0000 |
---|---|---|
committer | Hans-Peter Nilsson <hp@gcc.gnu.org> | 2008-09-22 01:54:03 +0000 |
commit | c70d0414afa803f535420815116971725933234c (patch) | |
tree | dacbdaca2921aa2efeafb9bf75733643142af3ea /gcc/config/darwin.c | |
parent | df969fc7a3004d812d22a9855283e2f7cf7cf96a (diff) | |
download | gcc-c70d0414afa803f535420815116971725933234c.zip gcc-c70d0414afa803f535420815116971725933234c.tar.gz gcc-c70d0414afa803f535420815116971725933234c.tar.bz2 |
re PR target/37170 (gcc.dg/weak/weak-1.c)
PR middle-end/37170
PR middle-end/37280
* final.c (mark_symbol_ref_as_used): New helper function.
(output_operand): Instead of just looking inside MEMs for
SYMBOL_REFs, use new helper function and for_each_rtx.
* varasm.c (assemble_external): Move #ifndef ASM_OUTPUT_EXTERNAL
to after weak-handling. Don't mark decls with TREE_STATIC as weak.
Make head comment more general.
* config/darwin.c (machopic_output_indirection): Handle weak
references here, like in assemble_external.
From-SVN: r140539
Diffstat (limited to 'gcc/config/darwin.c')
-rw-r--r-- | gcc/config/darwin.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 20cce26..fe33273 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1002,6 +1002,30 @@ machopic_output_indirection (void **slot, void *data) rtx init = const0_rtx; switch_to_section (darwin_sections[machopic_nl_symbol_ptr_section]); + + /* Mach-O symbols are passed around in code through indirect + references and the original symbol_ref hasn't passed through + the generic handling and reference-catching in + output_operand, so we need to manually mark weak references + as such. */ + if (SYMBOL_REF_WEAK (symbol)) + { + tree decl = SYMBOL_REF_DECL (symbol); + gcc_assert (DECL_P (decl)); + + if (decl != NULL_TREE + && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl) + /* Handle only actual external-only definitions, not + e.g. extern inline code or variables for which + storage has been allocated. */ + && !TREE_STATIC (decl)) + { + fputs ("\t.weak_reference ", asm_out_file); + assemble_name (asm_out_file, sym_name); + fputc ('\n', asm_out_file); + } + } + assemble_name (asm_out_file, ptr_name); fprintf (asm_out_file, ":\n"); |