source: rtems-tools/linkers/rld.cpp @ 3f5e31f

4.104.115
Last change on this file since 3f5e31f was a72a9e35, checked in by Chris Johns <chrisj@…>, on 09/06/14 at 10:17:56

Add a path str. Remove the duplicate split call.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16/**
17 * @file
18 *
19 * @ingroup rtems_ld
20 *
21 * @brief RTEMS Linker.
22 *
23 */
24
25#if HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include <iostream>
30
31#include <sys/stat.h>
32
33#include <rld.h>
34
35#define RLD_VERSION_MAJOR   (1)
36#define RLD_VERSION_MINOR   (0)
37#define RLD_VERSION_RELEASE (0)
38
39namespace rld
40{
41  static int verbose_level = 0;
42
43  /**
44   * The option container.
45   */
46  typedef std::vector < std::string > library_container;
47
48  /**
49   * The libraries the user provided on the command line.
50   */
51  static library_container libpaths;
52
53  /**
54   * The libraries pass on the command line.
55   */
56  static library_container libs;
57
58  /**
59   * The libraries.
60   */
61  static library_container libraries;
62
63  /**
64   * The output passed on the command line.
65   */
66  static std::string output;
67
68  void
69  verbose_inc ()
70  {
71    ++verbose_level;
72  }
73
74  int
75  verbose ()
76  {
77    return verbose_level;
78  }
79
80  const std::string
81  version ()
82  {
83    std::string v = (rld::to_string (RLD_VERSION_MAJOR) + '.' +
84                     rld::to_string (RLD_VERSION_MINOR) + '.' +
85                     rld::to_string (RLD_VERSION_RELEASE));
86    return v;
87  }
88
89  const std::string
90  rtems_version ()
91  {
92    return rld::to_string (RTEMS_VERSION);
93  }
94
95  void
96  map (rld::files::cache& cache, rld::symbols::table& symbols)
97  {
98    std::cout << "Archive files    : " << cache.archive_count () << std::endl;
99    std::cout << "Object files     : " << cache.object_count () << std::endl;
100    std::cout << "Exported symbols : " << symbols.size () << std::endl;
101
102    std::cout << "Archives:" << std::endl;
103    cache.output_archive_files (std::cout);
104    std::cout << "Objects:" << std::endl;
105    cache.output_object_files (std::cout);
106
107    std::cout << "Exported symbols:" << std::endl;
108    rld::symbols::output (std::cout, symbols);
109    std::cout << "Unresolved symbols:" << std::endl;
110    cache.output_unresolved_symbols (std::cout);
111  }
112
113  void
114  warn_unused_externals (rld::files::object_list& objects)
115  {
116    bool first = true;
117    for (rld::files::object_list::iterator oli = objects.begin ();
118         oli != objects.end ();
119         ++oli)
120    {
121      rld::files::object&     object = *(*oli);
122      rld::symbols::pointers& externals = object.external_symbols ();
123
124      if (rld::symbols::referenced (externals) != externals.size ())
125      {
126        if (first)
127        {
128          std::cout << "Unreferenced externals in object files:" << std::endl;
129          first = false;
130        }
131
132        std::cout << ' ' << object.name ().basename () << std::endl;
133
134        for (rld::symbols::pointers::iterator sli = externals.begin ();
135             sli != externals.end ();
136             ++sli)
137        {
138          rld::symbols::symbol& sym = *(*sli);
139          if (sym.references () == 0)
140            std::cout << "  " << sym.name () << std::endl;
141        }
142      }
143    }
144  }
145
146}
Note: See TracBrowser for help on using the repository browser.