Commit | Line | Data |
---|---|---|
a6cc6b3b RO |
1 | # This shell script emits a C file. -*- C -*- |
2 | # It does some substitutions. | |
3 | if [ -z "$MACHINE" ]; then | |
4 | OUTPUT_ARCH=${ARCH} | |
5 | else | |
6 | OUTPUT_ARCH=${ARCH}:${MACHINE} | |
7 | fi | |
8 | fragment <<EOF | |
9 | /* This file is generated by a shell script. DO NOT EDIT! */ | |
10 | ||
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> | |
14 | ||
15 | This file is part of the GNU Binutils. | |
16 | ||
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. | |
21 | ||
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. | |
26 | ||
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. */ | |
31 | ||
32 | #define TARGET_IS_${EMULATION_NAME} | |
33 | ||
34 | /* The Solaris 2 ABI requires some symbols to always be bound to the base | |
35 | version in a shared object. | |
36 | ||
37 | Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output | |
38 | File, p.63. */ | |
39 | static void | |
40 | elf_solaris2_before_allocation (void) | |
41 | { | |
42 | /* Symbols required to be bound to the base version. */ | |
43 | static const char *basever_syms[] = { | |
44 | "_DYNAMIC", | |
45 | "_GLOBAL_OFFSET_TABLE_", | |
46 | "_PROCEDURE_LINKAGE_TABLE_", | |
47 | "_edata", | |
48 | "_end", | |
49 | "_etext", | |
50 | NULL | |
51 | }; | |
52 | const char **sym; | |
53 | ||
54 | /* Only do this if emitting a shared object and versioning is in place. */ | |
55 | if (link_info.shared | |
56 | && (lang_elf_version_info != NULL || link_info.create_default_symver)) | |
57 | { | |
58 | struct bfd_elf_version_expr *globals = NULL, *locals = NULL; | |
59 | struct bfd_elf_version_tree *basever; | |
60 | const char *soname; | |
61 | ||
62 | for (sym = basever_syms; *sym != NULL; sym++) | |
63 | { | |
64 | /* Create a version pattern for this symbol. Some of them start | |
65 | off as local, others as global, so try both. */ | |
66 | globals = lang_new_vers_pattern (globals, *sym, NULL, TRUE); | |
67 | locals = lang_new_vers_pattern (locals, *sym, NULL, TRUE); | |
68 | } | |
69 | ||
70 | /* New version node for those symbols. */ | |
71 | basever = lang_new_vers_node (globals, locals); | |
72 | ||
73 | /* The version name matches what bfd_elf_size_dynamic_sections uses | |
74 | for the base version. */ | |
75 | soname = bfd_elf_get_dt_soname (link_info.output_bfd); | |
76 | if (soname == NULL) | |
77 | soname = lbasename (bfd_get_filename (link_info.output_bfd)); | |
78 | ||
79 | /* Register the node. */ | |
80 | lang_register_vers_node (soname, basever, NULL); | |
81 | /* Enforce base version. The encoded vd_ndx is vernum + 1. */ | |
82 | basever->vernum = 0; | |
83 | ||
84 | for (sym = basever_syms; *sym != NULL; sym++) | |
85 | { | |
86 | struct elf_link_hash_entry *h; | |
87 | ||
88 | /* Lookup symbol. */ | |
89 | h = elf_link_hash_lookup (elf_hash_table (&link_info), *sym, | |
90 | FALSE, FALSE, FALSE); | |
91 | if (h == NULL) | |
92 | continue; | |
93 | ||
94 | /* Undo the hiding done by _bfd_elf_define_linkage_sym. */ | |
95 | h->forced_local = 0; | |
96 | h->other &= ~STV_HIDDEN; | |
97 | ||
98 | /* Emit it into the .dynamic section, too. */ | |
99 | bfd_elf_link_record_dynamic_symbol (&link_info, h); | |
100 | } | |
101 | } | |
102 | ||
103 | gld${EMULATION_NAME}_before_allocation (); | |
104 | } | |
105 | ||
106 | EOF | |
107 | ||
108 | LDEMUL_BEFORE_ALLOCATION=elf_solaris2_before_allocation |