1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 if [ -z "$MACHINE" ]; then
6 OUTPUT_ARCH=${ARCH}:${MACHINE}
9 /* This file is generated by a shell script. DO NOT EDIT! */
11 /* Solaris 2 emulation code for ${EMULATION_NAME}
12 Copyright 2010 Free Software Foundation, Inc.
13 Written by Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
15 This file is part of the GNU Binutils.
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation; either version 3 of the License, or
20 (at your option) any later version.
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
30 MA 02110-1301, USA. */
32 #define TARGET_IS_${EMULATION_NAME}
34 /* The Solaris 2 ABI requires some global symbols to be present in the
35 .dynsym table of executables and shared objects. If generating a
36 versioned shared object, they must always be bound to the base version.
38 Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output
41 elf_solaris2_before_allocation (void)
43 /* Global symbols required by the Solaris 2 ABI. */
44 static const char *global_syms[] = {
46 "_GLOBAL_OFFSET_TABLE_",
47 "_PROCEDURE_LINKAGE_TABLE_",
55 /* Do this for both executables and shared objects. */
56 if (!link_info.relocatable)
58 for (sym = global_syms; *sym != NULL; sym++)
60 struct elf_link_hash_entry *h;
63 h = elf_link_hash_lookup (elf_hash_table (&link_info), *sym,
68 /* Undo the hiding done by _bfd_elf_define_linkage_sym. */
70 h->other &= ~STV_HIDDEN;
72 /* Emit it into the .dynamic section, too. */
73 bfd_elf_link_record_dynamic_symbol (&link_info, h);
77 /* Only do this if emitting a shared object and versioning is in place. */
79 && (link_info.version_info != NULL
80 || link_info.create_default_symver))
82 struct bfd_elf_version_expr *globals = NULL, *locals = NULL;
83 struct bfd_elf_version_tree *basever;
86 for (sym = global_syms; *sym != NULL; sym++)
88 /* Create a version pattern for this symbol. Some of them start
89 off as local, others as global, so try both. */
90 globals = lang_new_vers_pattern (globals, *sym, NULL, TRUE);
91 locals = lang_new_vers_pattern (locals, *sym, NULL, TRUE);
94 /* New version node for those symbols. */
95 basever = lang_new_vers_node (globals, locals);
97 /* The version name matches what bfd_elf_size_dynamic_sections uses
98 for the base version. */
99 soname = bfd_elf_get_dt_soname (link_info.output_bfd);
101 soname = lbasename (bfd_get_filename (link_info.output_bfd));
103 /* Register the node. */
104 lang_register_vers_node (soname, basever, NULL);
105 /* Enforce base version. The encoded vd_ndx is vernum + 1. */
109 gld${EMULATION_NAME}_before_allocation ();
112 /* The Solaris 2 ABI requires two local symbols to be emitted for every
113 executable and shared object.
115 Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output
118 elf_solaris2_after_allocation (void)
120 /* Local symbols required by the Solaris 2 ABI. Already emitted by
121 emulparams/solaris2.sh. */
122 static const char *local_syms[] = {
129 /* Do this for both executables and shared objects. */
130 if (!link_info.relocatable)
132 for (sym = local_syms; *sym != NULL; sym++)
134 struct elf_link_hash_entry *h;
137 h = elf_link_hash_lookup (elf_hash_table (&link_info), *sym,
138 FALSE, FALSE, FALSE);
144 /* Type should be STT_OBJECT, not STT_NOTYPE. */
145 h->type = STT_OBJECT;
149 gld${EMULATION_NAME}_after_allocation ();
154 LDEMUL_BEFORE_ALLOCATION=elf_solaris2_before_allocation
155 LDEMUL_AFTER_ALLOCATION=elf_solaris2_after_allocation