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 (C) 2010-2024 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 The Solaris 2 ABI also requires two local symbols to be emitted for
39 every executable and shared object.
41 Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output
45 elf_solaris2_before_allocation (void)
47 /* Global symbols required by the Solaris 2 ABI. */
48 static const char *global_syms[] = {
50 "_GLOBAL_OFFSET_TABLE_",
51 "_PROCEDURE_LINKAGE_TABLE_",
57 /* Local symbols required by the Solaris 2 ABI. Already emitted by
58 emulparams/solaris2.sh. */
59 static const char *local_syms[] = {
66 /* Do this for both executables and shared objects. */
67 if (!bfd_link_relocatable (&link_info)
68 && is_elf_hash_table (link_info.hash))
70 for (sym = global_syms; *sym != NULL; sym++)
72 struct elf_link_hash_entry *h;
75 h = elf_link_hash_lookup (elf_hash_table (&link_info), *sym,
80 /* Undo the hiding done by _bfd_elf_define_linkage_sym. */
82 h->other &= ~STV_HIDDEN;
84 /* Emit it into the .dynamic section, too. */
85 bfd_elf_link_record_dynamic_symbol (&link_info, h);
88 for (sym = local_syms; *sym != NULL; sym++)
90 struct elf_link_hash_entry *h;
93 h = elf_link_hash_lookup (elf_hash_table (&link_info), *sym,
100 /* Type should be STT_OBJECT, not STT_NOTYPE. */
101 h->type = STT_OBJECT;
105 /* Only do this if emitting a shared object and versioning is in place. */
106 if (bfd_link_dll (&link_info)
107 && ((link_info.version_info != NULL
108 && link_info.version_info->name[0] != '\0')
109 || link_info.create_default_symver))
111 struct bfd_elf_version_expr *globals = NULL, *locals = NULL;
112 struct bfd_elf_version_tree *basever;
115 for (sym = global_syms; *sym != NULL; sym++)
117 /* Create a version pattern for this symbol. Some of them start
118 off as local, others as global, so try both. */
119 globals = lang_new_vers_pattern (globals, *sym, NULL, true);
120 locals = lang_new_vers_pattern (locals, *sym, NULL, true);
123 /* New version node for those symbols. */
124 basever = lang_new_vers_node (globals, locals);
126 /* The version name matches what bfd_elf_size_dynamic_sections uses
127 for the base version. */
128 soname = bfd_elf_get_dt_soname (link_info.output_bfd);
130 soname = lbasename (bfd_get_filename (link_info.output_bfd));
132 /* Register the node. */
133 lang_register_vers_node (soname, basever, NULL);
134 /* Enforce base version. The encoded vd_ndx is vernum + 1. */
138 gld${EMULATION_NAME}_before_allocation ();
143 LDEMUL_BEFORE_ALLOCATION=elf_solaris2_before_allocation