PR sanitizer/80403
[official-gcc.git] / gcc / ada / mlib-tgt-specific-solaris.adb
blobd7cdfcc49afaeb3eda2c56d38db6fc412da3d6e1
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M L I B . T G T . S P E C I F I C --
6 -- (Solaris Version) --
7 -- --
8 -- B o d y --
9 -- --
10 -- Copyright (C) 2002-2008, Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 3, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
20 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- This is the Solaris version of the body
29 with MLib.Fil;
30 with MLib.Utl;
31 with Opt;
32 with Output; use Output;
34 package body MLib.Tgt.Specific is
36 -- Non default subprograms
38 procedure Build_Dynamic_Library
39 (Ofiles : Argument_List;
40 Options : Argument_List;
41 Interfaces : Argument_List;
42 Lib_Filename : String;
43 Lib_Dir : String;
44 Symbol_Data : Symbol_Record;
45 Driver_Name : Name_Id := No_Name;
46 Lib_Version : String := "";
47 Auto_Init : Boolean := False);
49 function Is_Archive_Ext (Ext : String) return Boolean;
51 ---------------------------
52 -- Build_Dynamic_Library --
53 ---------------------------
55 procedure Build_Dynamic_Library
56 (Ofiles : Argument_List;
57 Options : Argument_List;
58 Interfaces : Argument_List;
59 Lib_Filename : String;
60 Lib_Dir : String;
61 Symbol_Data : Symbol_Record;
62 Driver_Name : Name_Id := No_Name;
63 Lib_Version : String := "";
64 Auto_Init : Boolean := False)
66 pragma Unreferenced (Interfaces);
67 pragma Unreferenced (Symbol_Data);
68 pragma Unreferenced (Auto_Init);
70 Lib_File : constant String :=
71 "lib" & Fil.Append_To (Lib_Filename, DLL_Ext);
73 Lib_Path : constant String :=
74 Lib_Dir & Directory_Separator & Lib_File;
76 Version_Arg : String_Access;
77 Symbolic_Link_Needed : Boolean := False;
79 begin
80 if Opt.Verbose_Mode then
81 Write_Str ("building relocatable shared library ");
82 Write_Line (Lib_Path);
83 end if;
85 if Lib_Version = "" then
86 Utl.Gcc
87 (Output_File => Lib_Path,
88 Objects => Ofiles,
89 Options => Options,
90 Options_2 => No_Argument_List,
91 Driver_Name => Driver_Name);
93 else
94 declare
95 Maj_Version : constant String :=
96 Major_Id_Name (Lib_File, Lib_Version);
97 begin
98 if Maj_Version'Length /= 0 then
99 Version_Arg := new String'("-Wl,-h," & Maj_Version);
101 else
102 Version_Arg := new String'("-Wl,-h," & Lib_Version);
103 end if;
105 if Is_Absolute_Path (Lib_Version) then
106 Utl.Gcc
107 (Output_File => Lib_Version,
108 Objects => Ofiles,
109 Options => Options & Version_Arg,
110 Options_2 => No_Argument_List,
111 Driver_Name => Driver_Name);
112 Symbolic_Link_Needed := Lib_Version /= Lib_Path;
114 else
115 Utl.Gcc
116 (Output_File => Lib_Dir & Directory_Separator & Lib_Version,
117 Objects => Ofiles,
118 Options => Options & Version_Arg,
119 Options_2 => No_Argument_List,
120 Driver_Name => Driver_Name);
121 Symbolic_Link_Needed :=
122 Lib_Dir & Directory_Separator & Lib_Version /= Lib_Path;
123 end if;
125 if Symbolic_Link_Needed then
126 Create_Sym_Links
127 (Lib_Path, Lib_Version, Lib_Dir, Maj_Version);
128 end if;
129 end;
130 end if;
131 end Build_Dynamic_Library;
133 --------------------
134 -- Is_Archive_Ext --
135 --------------------
137 function Is_Archive_Ext (Ext : String) return Boolean is
138 begin
139 return Ext = ".a" or else Ext = ".so";
140 end Is_Archive_Ext;
142 begin
143 Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
144 Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
145 end MLib.Tgt.Specific;