source: rtems-tools/linkers/rld.h @ fe19d06

4.104.115
Last change on this file since fe19d06 was ec24a37, checked in by Chris Johns <chrisj@…>, on 05/06/12 at 22:47:11

Add to git.

  • Property mode set to 100644
File size: 3.4 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 readies the RTEMS object files for dynamic linking.
22 *
23 */
24
25#if !defined (_RLD_H_)
26#define _RLD_H_
27
28#include <iostream>
29#include <sstream>
30#include <string>
31
32/**
33 * Path handling for Windows.
34 */
35#if __WIN32__
36#define RLD_PATH_SEPARATOR        '\\'
37#define RLD_PATHSTR_SEPARATOR     ';'
38#define RLD_PATHSTR_SEPARATOR_STR ";"
39#define RLD_DRIVE_SEPARATOR       (1)
40#else
41#define RLD_PATH_SEPARATOR        '/'
42#define RLD_PATHSTR_SEPARATOR     ':'
43#define RLD_PATHSTR_SEPARATOR_STR ":"
44#define RLD_DRIVE_SEPARATOR       (0)
45#endif
46
47namespace rld
48{
49  /**
50   * Forward declarations.
51   */
52  namespace files
53  {
54    class file;
55    class image;
56    class archive;
57    class object;
58  }
59}
60
61#include <rld-elf-types.h>
62#include <rld-symbols.h>
63#include <rld-elf.h>
64#include <rld-files.h>
65
66/**
67 * The debug levels.
68 */
69#define RLD_VERBOSE_OFF        (0)
70#define RLD_VERBOSE_INFO       (1)
71#define RLD_VERBOSE_DETAILS    (2)
72#define RLD_VERBOSE_TRACE      (3)
73#define RLD_VERBOSE_FULL_DEBUG (4)
74
75namespace rld
76{
77  /**
78   * Convert a supported type to a string.
79   */
80  template <class T>
81  std::string to_string (T t, std::ios_base & (*f)(std::ios_base&) = std::dec)
82  {
83    std::ostringstream oss;
84    oss << f << t;
85    return oss.str();
86  }
87
88  /**
89   * General error.
90   */
91  struct error
92  {
93    const std::string what;
94    const std::string where;
95
96    error (const std::ostringstream& what, const std::string& where) :
97      what (what.str ()), where (where) {
98    }
99
100    error (const std::string& what, const std::string& where) :
101      what (what), where (where) {
102    }
103  };
104
105  /**
106   * A convenience macro to make where a file and line number.
107   */
108  #define rld_error_at(_what) \
109    rld::error (_what, std::string (__FILE__) + ":" + to_string (__LINE__))
110
111  /**
112   * Increment the verbose level.
113   */
114  void verbose_inc ();
115
116  /**
117   * Return the verbose level. Setting the flag more than once raises the
118   * level.
119   */
120  int verbose ();
121
122  /**
123   * The version string.
124   */
125  const std::string version ();
126
127  /**
128   * The RTEMS version string.
129   */
130  const std::string rtems_version ();
131
132  /**
133   * Container of strings to hold the results of a split.
134   */
135  typedef std::vector < std::string > strings;
136
137  /**
138   * Split a string into strings by the separator.
139   */
140  void split (const std::string& str, strings& strs, char separator);
141
142  /**
143   * Map of the symbol table.
144   */
145  void map (rld::files::cache& cache, rld::symbols::table& symbols);
146
147  /**
148   * Warn is externals in referenced object files are not used.
149   */
150  void warn_unused_externals (rld::files::object_list& objects);
151}
152
153#endif
Note: See TracBrowser for help on using the repository browser.