View | Details | Return to bug 46770
Collapse All | Expand All

(-)a/gcc/config.gcc (+11 lines)
Lines 2698-2703 esac Link Here
2698
case ${target} in
2698
case ${target} in
2699
i[34567]86-*-linux* | x86_64-*-linux*)
2699
i[34567]86-*-linux* | x86_64-*-linux*)
2700
	tmake_file="${tmake_file} i386/t-pmm_malloc i386/t-i386"
2700
	tmake_file="${tmake_file} i386/t-pmm_malloc i386/t-i386"
2701
	use_initfini_array=yes
2701
	;;
2702
	;;
2702
i[34567]86-*-* | x86_64-*-*)
2703
i[34567]86-*-* | x86_64-*-*)
2703
	tmake_file="${tmake_file} i386/t-gmm_malloc i386/t-i386"
2704
	tmake_file="${tmake_file} i386/t-gmm_malloc i386/t-i386"
Lines 3050-3055 if test x$with_schedule = x; then Link Here
3050
	esac
3051
	esac
3051
fi
3052
fi
3052
3053
3054
# Support --enable-initfini-array.  Use initfini-array.h only if
3055
# use_initfini_array is also set to yes.  Some platforms don't need it
3056
# even if enable_initfini_array is yes.
3057
if test x$enable_initfini_array$use_initfini_array = xyesyes; then
3058
  tm_file="${tm_file} initfini-array.h"
3059
  tmake_file="${tmake_file} t-initfini-array"
3060
  extra_objs="$extra_objs initfini-array.o"
3061
  target_gtfiles="$target_gtfiles \$(srcdir)/config/initfini-array.c"
3062
fi
3063
3053
# Validate and mark as valid any --with options supported
3064
# Validate and mark as valid any --with options supported
3054
# by this target.  In order to use a particular --with option
3065
# by this target.  In order to use a particular --with option
3055
# you must list it in supported_defaults; validating the value
3066
# you must list it in supported_defaults; validating the value
(-)a/gcc/config/initfini-array.c (+79 lines)
Line 0 Link Here
1
/* Definitions for ELF systems with .init_array/.fini_array section
2
   Copyright (C) 2010
3
   Free Software Foundation, Inc.
4
5
This file is part of GCC.
6
7
GCC is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free
9
Software Foundation; either version 3, or (at your option) any later
10
version.
11
12
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13
WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15
for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
<http://www.gnu.org/licenses/>.  */
20
21
#include "config.h"
22
#include "system.h"
23
#include "coretypes.h"
24
#include "target.h"
25
#include "output.h"
26
#include "tree.h"
27
#include "ggc.h"
28
29
static GTY(()) section *init_array_section;
30
static GTY(()) section *fini_array_section;
31
32
void
33
elf_initfini_array_init_sections (void)
34
{
35
  init_array_section = get_unnamed_section (0, output_section_asm_op,
36
					    "\t.section\t.init_array");
37
  fini_array_section = get_unnamed_section (0, output_section_asm_op,
38
					    "\t.section\t.fini_array");
39
}
40
41
static section *
42
get_elf_initfini_array_priority_section (int priority,
43
					 bool constructor_p)
44
{
45
  section *sec;
46
  if (priority != DEFAULT_INIT_PRIORITY)
47
    {
48
      char buf[18];
49
      sprintf (buf, "%s.%.5u", 
50
	       constructor_p ? ".init_array" : ".fini_array",
51
	       priority);
52
      sec = get_section (buf, SECTION_WRITE, NULL_TREE);
53
    }
54
  else
55
    sec = constructor_p ? init_array_section : fini_array_section;
56
  return sec;
57
}
58
59
/* Use .init_array section for constructors. */
60
61
void
62
elf_init_array_asm_out_constructor (rtx symbol, int priority)
63
{
64
  section *sec = get_elf_initfini_array_priority_section (priority,
65
							  true);
66
  assemble_addr_to_section (symbol, sec);
67
}
68
69
/* Use .fini_array section for destructors. */
70
71
void
72
elf_fini_array_asm_out_destructor (rtx symbol, int priority)
73
{
74
  section *sec = get_elf_initfini_array_priority_section (priority,
75
							  false);
76
  assemble_addr_to_section (symbol, sec);
77
}
78
79
#include "gt-initfini-array.h"
(-)a/gcc/config/initfini-array.h (+33 lines)
Line 0 Link Here
1
/* Definitions for ELF systems with .init_array/.fini_array section
2
   support.
3
   Copyright (C) 2010
4
   Free Software Foundation, Inc.
5
6
   This file is part of GCC.
7
8
   GCC is free software; you can redistribute it and/or modify it
9
   under the terms of the GNU General Public License as published
10
   by the Free Software Foundation; either version 3, or (at your
11
   option) any later version.
12
13
   GCC is distributed in the hope that it will be useful, but WITHOUT
14
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16
   License for more details.
17
18
   You should have received a copy of the GNU General Public License
19
   along with GCC; see the file COPYING3.  If not see
20
   <http://www.gnu.org/licenses/>.  */
21
22
#ifndef TARGET_ASM_INIT_SECTIONS
23
#define TARGET_ASM_INIT_SECTIONS elf_initfini_array_init_sections
24
#endif
25
extern void elf_initfini_array_init_sections (void);
26
27
/* Use .init_array/.fini_array section for constructors and destructors. */
28
#undef TARGET_ASM_CONSTRUCTOR
29
#define TARGET_ASM_CONSTRUCTOR elf_init_array_asm_out_constructor
30
#undef TARGET_ASM_DESTRUCTOR
31
#define TARGET_ASM_DESTRUCTOR elf_fini_array_asm_out_destructor
32
extern void elf_init_array_asm_out_constructor (rtx, int);
33
extern void elf_fini_array_asm_out_destructor (rtx, int);
(-)a/gcc/config/t-initfini-array (+23 lines)
Line 0 Link Here
1
# Copyright (C) 2010
2
# 2009 Free Software Foundation, Inc.
3
#
4
# This file is part of GCC.
5
#
6
# GCC is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3, or (at your option)
9
# any later version.
10
#
11
# GCC is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with GCC; see the file COPYING3.  If not see
18
# <http://www.gnu.org/licenses/>.
19
20
initfini-array.o: $(srcdir)/config/initfini-array.c gt-initfini-array.h \
21
	$(CONFIG_H) $(SYSTEM_H) coretypes.h $(TARGET_H) output.h \
22
	$(TREE_H) $(GCC_H)
23
	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<

Return to bug 46770