1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- V X L I N K . M A I N --
9 -- Copyright (C) 2018, AdaCore --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- VxLink is a helper tool used as a wrapper around g++/gcc to build VxWorks
27 -- DKM (Downloadable Kernel Modules).
28 -- Such DKM is a partially linked object that contains entry points for
29 -- constructors and destructors. This tool thus uses g++ to generate an
30 -- intermediate partially linked object, retrieves the list of constructors
31 -- and destructors in it and produces a C file that lists those ctors/dtors
32 -- in a way that is understood be VxWorks kernel. It then links this file
33 -- with the intermediate object to produce a valid DKM.
37 with GNAT
.OS_Lib
; use GNAT
.OS_Lib
;
39 with VxLink
.Link
; use VxLink
.Link
;
40 with VxLink
.Bind
; use VxLink
.Bind
;
42 procedure VxLink
.Main
is
43 Linker
: VxLink_Linker
;
44 Binder
: VxLink_Binder
;
45 VSB_Dir
: String_Access
:= Getenv
("VSB_DIR");
49 if Is_Error_State
then
53 Do_Initial_Link
(Linker
);
55 if Is_Error_State
then
59 if not Needs_CDtor
(Linker
) then
60 -- Initial link is enough, let's return
64 if VSB_Dir
/= null and then VSB_Dir
'Length > 0 then
66 DKM_Tag_File
: constant String :=
68 ("krnl/tags/dkm.tags", VSB_Dir
.all);
70 if Is_Regular_File
(DKM_Tag_File
) then
71 Parse_Tag_File
(Binder
, DKM_Tag_File
);
76 Initialize
(Binder
, Object_File
=> Partial_Object
(Linker
));
77 Emit_CTDT
(Binder
, Namespace
=> Namespace
(Linker
));
79 Do_Final_Link
(Linker
, CTDT_File
(Binder
));