2006-08-05 07:10:59 +08:00
|
|
|
// options.h -- handle command line options for gold -*- C++ -*-
|
|
|
|
|
2008-01-10 03:57:45 +08:00
|
|
|
// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
|
2007-09-23 05:02:10 +08:00
|
|
|
// Written by Ian Lance Taylor <iant@google.com>.
|
|
|
|
|
|
|
|
// This file is part of gold.
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
// MA 02110-1301, USA.
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
// Command_line
|
|
|
|
// Holds everything we get from the command line.
|
|
|
|
// General_options (from Command_line::options())
|
|
|
|
// Options which are not position dependent.
|
|
|
|
// Input_argument (from Command_line::inputs())
|
|
|
|
// The list of input files, including -l options.
|
|
|
|
// Position_dependent_options (from Input_argument::options())
|
|
|
|
// Position dependent options which apply to this argument.
|
|
|
|
|
|
|
|
#ifndef GOLD_OPTIONS_H
|
|
|
|
#define GOLD_OPTIONS_H
|
|
|
|
|
2007-09-21 13:43:33 +08:00
|
|
|
#include <cstdlib>
|
2006-08-05 07:10:59 +08:00
|
|
|
#include <list>
|
2006-09-30 03:58:17 +08:00
|
|
|
#include <string>
|
2006-10-21 04:40:49 +08:00
|
|
|
#include <vector>
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2008-02-13 10:44:50 +08:00
|
|
|
#include "elfcpp.h"
|
2007-10-27 08:29:34 +08:00
|
|
|
#include "script.h"
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
namespace gold
|
|
|
|
{
|
|
|
|
|
|
|
|
class Command_line;
|
2006-11-04 02:26:11 +08:00
|
|
|
class Input_file_group;
|
2007-10-27 08:29:34 +08:00
|
|
|
class Position_dependent_options;
|
2008-02-13 10:44:50 +08:00
|
|
|
class Target;
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2007-11-22 08:05:51 +08:00
|
|
|
namespace options
|
|
|
|
{
|
2006-08-05 07:10:59 +08:00
|
|
|
|
|
|
|
class Command_line_options;
|
|
|
|
struct One_option;
|
2007-10-23 13:05:48 +08:00
|
|
|
struct One_z_option;
|
2007-11-22 08:05:51 +08:00
|
|
|
struct One_debug_option;
|
2006-08-05 07:10:59 +08:00
|
|
|
|
|
|
|
} // End namespace gold::options.
|
|
|
|
|
2007-10-04 13:49:04 +08:00
|
|
|
// A directory to search. For each directory we record whether it is
|
|
|
|
// in the sysroot. We need to know this so that, if a linker script
|
|
|
|
// is found within the sysroot, we will apply the sysroot to any files
|
|
|
|
// named by that script.
|
|
|
|
|
|
|
|
class Search_directory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// We need a default constructor because we put this in a
|
|
|
|
// std::vector.
|
|
|
|
Search_directory()
|
|
|
|
: name_(NULL), put_in_sysroot_(false), is_in_sysroot_(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
// This is the usual constructor.
|
|
|
|
Search_directory(const char* name, bool put_in_sysroot)
|
|
|
|
: name_(name), put_in_sysroot_(put_in_sysroot), is_in_sysroot_(false)
|
2008-02-05 06:44:35 +08:00
|
|
|
{
|
|
|
|
if (this->name_.empty())
|
|
|
|
this->name_ = ".";
|
|
|
|
}
|
2007-10-04 13:49:04 +08:00
|
|
|
|
|
|
|
// This is called if we have a sysroot. The sysroot is prefixed to
|
|
|
|
// any entries for which put_in_sysroot_ is true. is_in_sysroot_ is
|
|
|
|
// set to true for any enries which are in the sysroot (this will
|
|
|
|
// naturally include any entries for which put_in_sysroot_ is true).
|
|
|
|
// SYSROOT is the sysroot, CANONICAL_SYSROOT is the result of
|
|
|
|
// passing SYSROOT to lrealpath.
|
|
|
|
void
|
|
|
|
add_sysroot(const char* sysroot, const char* canonical_sysroot);
|
|
|
|
|
|
|
|
// Get the directory name.
|
|
|
|
const std::string&
|
|
|
|
name() const
|
|
|
|
{ return this->name_; }
|
|
|
|
|
|
|
|
// Return whether this directory is in the sysroot.
|
|
|
|
bool
|
|
|
|
is_in_sysroot() const
|
|
|
|
{ return this->is_in_sysroot_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name_;
|
|
|
|
bool put_in_sysroot_;
|
|
|
|
bool is_in_sysroot_;
|
|
|
|
};
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
// The position independent options which apply to the whole link.
|
|
|
|
// There are a lot of them.
|
|
|
|
|
|
|
|
class General_options
|
|
|
|
{
|
|
|
|
public:
|
2008-02-08 15:06:58 +08:00
|
|
|
enum Object_format
|
|
|
|
{
|
|
|
|
// Ordinary ELF.
|
|
|
|
OBJECT_FORMAT_ELF,
|
|
|
|
// Straight binary format.
|
|
|
|
OBJECT_FORMAT_BINARY
|
|
|
|
};
|
|
|
|
|
2008-02-27 06:48:08 +08:00
|
|
|
General_options();
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2008-02-29 04:35:39 +08:00
|
|
|
// -d: define common symbols.
|
|
|
|
bool
|
|
|
|
define_common() const
|
|
|
|
{ return this->define_common_; }
|
|
|
|
|
2008-01-06 08:47:10 +08:00
|
|
|
// -e: set entry address.
|
|
|
|
const char*
|
|
|
|
entry() const
|
2008-02-27 06:48:08 +08:00
|
|
|
{ return this->entry_; }
|
2008-01-06 08:47:10 +08:00
|
|
|
|
2007-08-22 13:06:38 +08:00
|
|
|
// -E: export dynamic symbols.
|
|
|
|
bool
|
|
|
|
export_dynamic() const
|
|
|
|
{ return this->export_dynamic_; }
|
|
|
|
|
2008-01-04 13:35:24 +08:00
|
|
|
// -h: shared library name.
|
|
|
|
const char*
|
|
|
|
soname() const
|
|
|
|
{ return this->soname_; }
|
|
|
|
|
2006-11-15 03:21:05 +08:00
|
|
|
// -I: dynamic linker name.
|
|
|
|
const char*
|
|
|
|
dynamic_linker() const
|
|
|
|
{ return this->dynamic_linker_; }
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
// -L: Library search path.
|
2007-10-04 13:49:04 +08:00
|
|
|
typedef std::vector<Search_directory> Dir_list;
|
2006-08-05 07:10:59 +08:00
|
|
|
|
|
|
|
const Dir_list&
|
2008-03-05 02:21:43 +08:00
|
|
|
library_path() const
|
2006-08-05 07:10:59 +08:00
|
|
|
{ return this->search_path_; }
|
|
|
|
|
2007-09-21 13:43:33 +08:00
|
|
|
// -O: optimization level (0: don't try to optimize output size).
|
|
|
|
int
|
2008-02-27 05:45:30 +08:00
|
|
|
optimize() const
|
2007-09-21 13:43:33 +08:00
|
|
|
{ return this->optimization_level_; }
|
|
|
|
|
2006-09-30 03:58:17 +08:00
|
|
|
// -o: Output file name.
|
|
|
|
const char*
|
|
|
|
output_file_name() const
|
|
|
|
{ return this->output_file_name_; }
|
|
|
|
|
2008-02-07 15:33:46 +08:00
|
|
|
// --oformat: Output format.
|
2008-02-08 15:06:58 +08:00
|
|
|
Object_format
|
2008-03-05 02:21:43 +08:00
|
|
|
oformat_enum() const
|
2008-02-27 05:45:30 +08:00
|
|
|
{ return this->oformat_; }
|
2008-02-07 15:33:46 +08:00
|
|
|
|
2008-02-28 08:18:24 +08:00
|
|
|
const char*
|
2008-03-05 02:21:43 +08:00
|
|
|
oformat() const
|
2008-02-28 08:18:24 +08:00
|
|
|
{ return this->oformat_string_; }
|
|
|
|
|
2008-02-13 10:44:50 +08:00
|
|
|
// Return the default target.
|
|
|
|
Target*
|
|
|
|
default_target() const;
|
|
|
|
|
2008-02-28 06:38:18 +08:00
|
|
|
// -q: Whether to emit relocations.
|
|
|
|
bool
|
|
|
|
emit_relocs() const
|
|
|
|
{ return this->emit_relocs_; }
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
// -r: Whether we are doing a relocatable link.
|
|
|
|
bool
|
2008-02-27 05:45:30 +08:00
|
|
|
relocatable() const
|
2006-08-05 07:10:59 +08:00
|
|
|
{ return this->is_relocatable_; }
|
|
|
|
|
2007-10-11 03:02:56 +08:00
|
|
|
// -s: Strip all symbols.
|
|
|
|
bool
|
|
|
|
strip_all() const
|
|
|
|
{ return this->strip_ == STRIP_ALL; }
|
|
|
|
|
|
|
|
// -S: Strip debugging information.
|
|
|
|
bool
|
|
|
|
strip_debug() const
|
|
|
|
{ return this->strip_ == STRIP_ALL || this->strip_ == STRIP_DEBUG; }
|
|
|
|
|
2007-11-30 08:35:27 +08:00
|
|
|
// --strip-debug-gdb: strip only debugging information that's not
|
|
|
|
// used by gdb (at least, for gdb versions <= 6.7).
|
2007-11-16 07:03:45 +08:00
|
|
|
bool
|
|
|
|
strip_debug_gdb() const
|
|
|
|
{ return this->strip_debug() || this->strip_ == STRIP_DEBUG_UNUSED_BY_GDB; }
|
|
|
|
|
2007-11-14 15:34:53 +08:00
|
|
|
// --allow-shlib-undefined: do not warn about unresolved symbols in
|
|
|
|
// --shared libraries.
|
|
|
|
bool
|
|
|
|
allow_shlib_undefined() const
|
|
|
|
{ return this->allow_shlib_undefined_; }
|
|
|
|
|
2007-10-19 07:20:53 +08:00
|
|
|
// -Bsymbolic: bind defined symbols locally.
|
|
|
|
bool
|
2008-02-27 05:45:30 +08:00
|
|
|
Bsymbolic() const
|
2007-10-19 07:20:53 +08:00
|
|
|
{ return this->symbolic_; }
|
|
|
|
|
2007-11-30 08:35:27 +08:00
|
|
|
// --compress-debug-sections: compress .debug_* sections in the
|
|
|
|
// output file using the given compression method. This is useful
|
|
|
|
// when the tools (such as gdb) support compressed sections.
|
|
|
|
bool
|
|
|
|
compress_debug_sections() const
|
|
|
|
{ return this->compress_debug_sections_ != NO_COMPRESSION; }
|
|
|
|
|
|
|
|
bool
|
|
|
|
zlib_compress_debug_sections() const
|
|
|
|
{ return this->compress_debug_sections_ == ZLIB_COMPRESSION; }
|
|
|
|
|
2007-11-15 09:12:55 +08:00
|
|
|
// --demangle: demangle C++ symbols in our log messages.
|
|
|
|
bool
|
|
|
|
demangle() const
|
|
|
|
{ return this->demangle_; }
|
|
|
|
|
2007-11-14 09:03:01 +08:00
|
|
|
// --detect-odr-violations: Whether to search for One Defn Rule violations.
|
|
|
|
bool
|
|
|
|
detect_odr_violations() const
|
|
|
|
{ return this->detect_odr_violations_; }
|
|
|
|
|
2007-08-23 01:07:36 +08:00
|
|
|
// --eh-frame-hdr: Whether to generate an exception frame header.
|
|
|
|
bool
|
2008-02-27 05:45:30 +08:00
|
|
|
eh_frame_hdr() const
|
2007-08-23 01:07:36 +08:00
|
|
|
{ return this->create_eh_frame_hdr_; }
|
|
|
|
|
2007-08-22 04:37:32 +08:00
|
|
|
// --rpath: The runtime search path.
|
|
|
|
const Dir_list&
|
|
|
|
rpath() const
|
|
|
|
{ return this->rpath_; }
|
|
|
|
|
2007-09-07 07:37:53 +08:00
|
|
|
// --rpath-link: The link time search patch for shared libraries.
|
|
|
|
const Dir_list&
|
|
|
|
rpath_link() const
|
|
|
|
{ return this->rpath_link_; }
|
|
|
|
|
2006-10-21 04:40:49 +08:00
|
|
|
// --shared: Whether generating a shared object.
|
|
|
|
bool
|
2008-02-27 05:45:30 +08:00
|
|
|
shared() const
|
2006-10-21 04:40:49 +08:00
|
|
|
{ return this->is_shared_; }
|
|
|
|
|
2008-02-28 08:18:24 +08:00
|
|
|
// This is not defined via a flag, but combines flags to say whether
|
|
|
|
// the output is position-independent or not.
|
|
|
|
bool
|
|
|
|
output_is_position_independent() const
|
|
|
|
{ return this->shared(); }
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
// --static: Whether doing a static link.
|
|
|
|
bool
|
|
|
|
is_static() const
|
|
|
|
{ return this->is_static_; }
|
|
|
|
|
2007-10-17 06:38:36 +08:00
|
|
|
// --stats: Print resource usage statistics.
|
2007-10-12 13:51:25 +08:00
|
|
|
bool
|
2008-03-05 02:21:43 +08:00
|
|
|
stats() const
|
2007-10-12 13:51:25 +08:00
|
|
|
{ return this->print_stats_; }
|
|
|
|
|
2007-10-04 13:49:04 +08:00
|
|
|
// --sysroot: The system root of a cross-linker.
|
|
|
|
const std::string&
|
|
|
|
sysroot() const
|
|
|
|
{ return this->sysroot_; }
|
|
|
|
|
2008-02-14 06:47:28 +08:00
|
|
|
// -Tbss: The address of the BSS segment
|
|
|
|
uint64_t
|
2008-02-27 05:45:30 +08:00
|
|
|
Tbss() const
|
2008-02-14 06:47:28 +08:00
|
|
|
{ return this->bss_segment_address_; }
|
|
|
|
|
|
|
|
// Whether -Tbss was used.
|
|
|
|
bool
|
2008-02-27 05:45:30 +08:00
|
|
|
user_set_Tbss() const
|
2008-02-14 06:47:28 +08:00
|
|
|
{ return this->bss_segment_address_ != -1U; }
|
|
|
|
|
|
|
|
// -Tdata: The address of the data segment
|
|
|
|
uint64_t
|
2008-02-27 05:45:30 +08:00
|
|
|
Tdata() const
|
2008-02-14 06:47:28 +08:00
|
|
|
{ return this->data_segment_address_; }
|
|
|
|
|
|
|
|
// Whether -Tdata was used.
|
|
|
|
bool
|
2008-02-27 05:45:30 +08:00
|
|
|
user_set_Tdata() const
|
2008-02-14 06:47:28 +08:00
|
|
|
{ return this->data_segment_address_ != -1U; }
|
|
|
|
|
2007-10-17 06:38:36 +08:00
|
|
|
// -Ttext: The address of the .text section
|
|
|
|
uint64_t
|
2008-02-27 05:45:30 +08:00
|
|
|
Ttext() const
|
2007-10-17 06:38:36 +08:00
|
|
|
{ return this->text_segment_address_; }
|
|
|
|
|
|
|
|
// Whether -Ttext was used.
|
|
|
|
bool
|
2008-02-27 05:45:30 +08:00
|
|
|
user_set_Ttext() const
|
2007-10-17 06:38:36 +08:00
|
|
|
{ return this->text_segment_address_ != -1U; }
|
|
|
|
|
2007-10-17 14:24:50 +08:00
|
|
|
// --threads: Whether to use threads.
|
|
|
|
bool
|
|
|
|
threads() const
|
|
|
|
{ return this->threads_; }
|
|
|
|
|
|
|
|
// --thread-count-initial: Threads to use in initial pass.
|
|
|
|
int
|
|
|
|
thread_count_initial() const
|
|
|
|
{ return this->thread_count_initial_; }
|
|
|
|
|
|
|
|
// --thread-count-middle: Threads to use in middle pass.
|
|
|
|
int
|
|
|
|
thread_count_middle() const
|
|
|
|
{ return this->thread_count_middle_; }
|
|
|
|
|
|
|
|
// --thread-count-final: Threads to use in final pass.
|
|
|
|
int
|
|
|
|
thread_count_final() const
|
|
|
|
{ return this->thread_count_final_; }
|
|
|
|
|
2007-10-23 13:05:48 +08:00
|
|
|
// -z execstack, -z noexecstack
|
|
|
|
bool
|
|
|
|
is_execstack_set() const
|
|
|
|
{ return this->execstack_ != EXECSTACK_FROM_INPUT; }
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_stack_executable() const
|
|
|
|
{ return this->execstack_ == EXECSTACK_YES; }
|
|
|
|
|
2008-02-27 06:10:32 +08:00
|
|
|
// -z max-page-size
|
|
|
|
uint64_t
|
|
|
|
max_page_size() const
|
|
|
|
{ return this->max_page_size_; }
|
|
|
|
|
|
|
|
// -z common-page-size
|
|
|
|
uint64_t
|
|
|
|
common_page_size() const
|
|
|
|
{ return this->common_page_size_; }
|
|
|
|
|
2007-11-22 08:05:51 +08:00
|
|
|
// --debug
|
|
|
|
unsigned int
|
|
|
|
debug() const
|
|
|
|
{ return this->debug_; }
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
private:
|
2006-11-15 03:21:05 +08:00
|
|
|
// Don't copy this structure.
|
|
|
|
General_options(const General_options&);
|
|
|
|
General_options& operator=(const General_options&);
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
friend class Command_line;
|
|
|
|
friend class options::Command_line_options;
|
|
|
|
|
2007-10-11 03:02:56 +08:00
|
|
|
// Which symbols to strip.
|
|
|
|
enum Strip
|
|
|
|
{
|
|
|
|
// Don't strip any symbols.
|
|
|
|
STRIP_NONE,
|
|
|
|
// Strip all symbols.
|
|
|
|
STRIP_ALL,
|
|
|
|
// Strip debugging information.
|
2007-11-16 07:03:45 +08:00
|
|
|
STRIP_DEBUG,
|
|
|
|
// Strip debugging information that's not used by gdb (at least <= 6.7)
|
|
|
|
STRIP_DEBUG_UNUSED_BY_GDB
|
2007-10-11 03:02:56 +08:00
|
|
|
};
|
|
|
|
|
2007-10-23 13:05:48 +08:00
|
|
|
// Whether to mark the stack as executable.
|
|
|
|
enum Execstack
|
|
|
|
{
|
|
|
|
// Not set on command line.
|
|
|
|
EXECSTACK_FROM_INPUT,
|
|
|
|
// Mark the stack as executable.
|
|
|
|
EXECSTACK_YES,
|
|
|
|
// Mark the stack as not executable.
|
|
|
|
EXECSTACK_NO
|
|
|
|
};
|
|
|
|
|
2007-11-30 08:35:27 +08:00
|
|
|
// What compression method to use
|
|
|
|
enum CompressionMethod
|
|
|
|
{
|
|
|
|
NO_COMPRESSION,
|
|
|
|
ZLIB_COMPRESSION,
|
|
|
|
};
|
|
|
|
|
2008-02-29 04:35:39 +08:00
|
|
|
void
|
|
|
|
set_define_common(bool value)
|
|
|
|
{
|
|
|
|
this->define_common_ = value;
|
|
|
|
this->user_set_define_common_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_no_define_common(bool value)
|
|
|
|
{ this->set_define_common(!value); }
|
|
|
|
|
|
|
|
bool
|
|
|
|
user_set_define_common() const
|
|
|
|
{ return this->user_set_define_common_; }
|
|
|
|
|
2008-01-06 08:47:10 +08:00
|
|
|
void
|
|
|
|
set_entry(const char* arg)
|
2008-02-27 06:48:08 +08:00
|
|
|
{ this->entry_ = arg; }
|
2008-01-06 08:47:10 +08:00
|
|
|
|
2007-08-22 13:06:38 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_export_dynamic(bool value)
|
|
|
|
{ this->export_dynamic_ = value; }
|
2007-08-22 13:06:38 +08:00
|
|
|
|
2008-01-04 13:35:24 +08:00
|
|
|
void
|
|
|
|
set_soname(const char* arg)
|
|
|
|
{ this->soname_ = arg; }
|
|
|
|
|
2006-11-15 03:21:05 +08:00
|
|
|
void
|
|
|
|
set_dynamic_linker(const char* arg)
|
|
|
|
{ this->dynamic_linker_ = arg; }
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
void
|
|
|
|
add_to_search_path(const char* arg)
|
2007-10-04 13:49:04 +08:00
|
|
|
{ this->search_path_.push_back(Search_directory(arg, false)); }
|
|
|
|
|
|
|
|
void
|
|
|
|
add_to_search_path_with_sysroot(const char* arg)
|
|
|
|
{ this->search_path_.push_back(Search_directory(arg, true)); }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2007-09-21 13:43:33 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_optimize(const char* arg)
|
2007-12-04 09:30:46 +08:00
|
|
|
{
|
|
|
|
char* endptr;
|
|
|
|
this->optimization_level_ = strtol(arg, &endptr, 0);
|
|
|
|
if (*endptr != '\0' || this->optimization_level_ < 0)
|
|
|
|
gold_fatal(_("invalid optimization level: %s"), arg);
|
|
|
|
}
|
2007-09-21 13:43:33 +08:00
|
|
|
|
2006-09-30 03:58:17 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_output(const char* arg)
|
2006-09-30 03:58:17 +08:00
|
|
|
{ this->output_file_name_ = arg; }
|
|
|
|
|
2008-02-07 15:33:46 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_oformat(const char*);
|
2008-02-07 15:33:46 +08:00
|
|
|
|
2008-02-28 06:38:18 +08:00
|
|
|
void
|
|
|
|
set_emit_relocs(bool value)
|
|
|
|
{ this->emit_relocs_ = value; }
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_relocatable(bool value)
|
|
|
|
{ this->is_relocatable_ = value; }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2007-10-11 03:02:56 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_strip_all(bool)
|
2007-10-11 03:02:56 +08:00
|
|
|
{ this->strip_ = STRIP_ALL; }
|
|
|
|
|
2007-10-11 03:30:39 +08:00
|
|
|
// Note: normalize_options() depends on the fact that this turns off
|
|
|
|
// STRIP_ALL if it were already set.
|
2007-10-11 03:02:56 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_strip_debug(bool)
|
2007-10-11 03:02:56 +08:00
|
|
|
{ this->strip_ = STRIP_DEBUG; }
|
|
|
|
|
2007-11-16 07:03:45 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_strip_debug_gdb(bool)
|
2007-11-16 07:03:45 +08:00
|
|
|
{ this->strip_ = STRIP_DEBUG_UNUSED_BY_GDB; }
|
|
|
|
|
2007-11-14 15:34:53 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_allow_shlib_undefined(bool value)
|
|
|
|
{ this->allow_shlib_undefined_ = value; }
|
2007-11-14 15:34:53 +08:00
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_no_allow_shlib_undefined(bool value)
|
|
|
|
{ this->set_allow_shlib_undefined(!value); }
|
2007-11-14 15:34:53 +08:00
|
|
|
|
2007-10-19 07:20:53 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_Bsymbolic(bool value)
|
|
|
|
{ this->symbolic_ = value; }
|
2007-10-19 07:20:53 +08:00
|
|
|
|
2007-12-08 11:05:27 +08:00
|
|
|
void set_compress_debug_sections(const char* arg)
|
2007-11-30 08:35:27 +08:00
|
|
|
{
|
|
|
|
if (strcmp(arg, "none") == 0)
|
|
|
|
this->compress_debug_sections_ = NO_COMPRESSION;
|
|
|
|
#ifdef HAVE_ZLIB_H
|
|
|
|
else if (strcmp(arg, "zlib") == 0)
|
|
|
|
this->compress_debug_sections_ = ZLIB_COMPRESSION;
|
|
|
|
#endif
|
|
|
|
else
|
2007-12-08 11:05:27 +08:00
|
|
|
gold_fatal(_("unsupported argument to --compress-debug-sections: %s"),
|
2007-11-30 08:35:27 +08:00
|
|
|
arg);
|
|
|
|
}
|
|
|
|
|
2008-01-10 03:57:45 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
add_to_defsym(const char* arg);
|
2008-01-10 03:57:45 +08:00
|
|
|
|
2007-11-15 09:12:55 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_demangle(bool value)
|
|
|
|
{ this->demangle_ = value; }
|
2007-11-15 09:12:55 +08:00
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_no_demangle(bool value)
|
|
|
|
{ this->set_demangle(!value); }
|
2007-11-15 09:12:55 +08:00
|
|
|
|
2007-11-14 09:03:01 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_detect_odr_violations(bool value)
|
|
|
|
{ this->detect_odr_violations_ = value; }
|
2007-11-14 09:03:01 +08:00
|
|
|
|
2007-08-23 01:07:36 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_eh_frame_hdr(bool value)
|
|
|
|
{ this->create_eh_frame_hdr_ = value; }
|
2007-08-23 01:07:36 +08:00
|
|
|
|
2007-08-22 04:37:32 +08:00
|
|
|
void
|
|
|
|
add_to_rpath(const char* arg)
|
2007-10-04 13:49:04 +08:00
|
|
|
{ this->rpath_.push_back(Search_directory(arg, false)); }
|
2007-08-22 04:37:32 +08:00
|
|
|
|
2007-09-07 07:37:53 +08:00
|
|
|
void
|
|
|
|
add_to_rpath_link(const char* arg)
|
2007-10-04 13:49:04 +08:00
|
|
|
{ this->rpath_link_.push_back(Search_directory(arg, false)); }
|
2007-09-07 07:37:53 +08:00
|
|
|
|
2006-10-21 04:40:49 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_shared(bool value)
|
|
|
|
{ this->is_shared_ = value; }
|
2006-10-21 04:40:49 +08:00
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_static(bool value)
|
|
|
|
{ this->is_static_ = value; }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2007-10-12 13:51:25 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_stats(bool value)
|
|
|
|
{ this->print_stats_ = value; }
|
2007-10-12 13:51:25 +08:00
|
|
|
|
2007-10-04 13:49:04 +08:00
|
|
|
void
|
|
|
|
set_sysroot(const char* arg)
|
|
|
|
{ this->sysroot_ = arg; }
|
|
|
|
|
2007-10-17 06:38:36 +08:00
|
|
|
void
|
2008-02-14 06:47:28 +08:00
|
|
|
set_segment_address(const char* name, const char* arg, uint64_t* val)
|
2007-10-17 06:38:36 +08:00
|
|
|
{
|
|
|
|
char* endptr;
|
2008-02-14 06:47:28 +08:00
|
|
|
*val = strtoull(arg, &endptr, 0);
|
|
|
|
if (*endptr != '\0' || *val == -1U)
|
|
|
|
gold_fatal(_("invalid argument to %s: %s"), name, arg);
|
2007-10-17 06:38:36 +08:00
|
|
|
}
|
|
|
|
|
2008-02-14 06:47:28 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_Tbss(const char* arg)
|
2008-02-14 06:47:28 +08:00
|
|
|
{ this->set_segment_address("-Tbss", arg, &this->bss_segment_address_); }
|
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_Tdata(const char* arg)
|
2008-02-14 06:47:28 +08:00
|
|
|
{ this->set_segment_address("-Tdata", arg, &this->data_segment_address_); }
|
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_Ttext(const char* arg)
|
2008-02-14 06:47:28 +08:00
|
|
|
{ this->set_segment_address("-Ttext", arg, &this->text_segment_address_); }
|
|
|
|
|
2007-10-17 14:24:50 +08:00
|
|
|
int
|
|
|
|
parse_thread_count(const char* arg)
|
|
|
|
{
|
|
|
|
char* endptr;
|
2007-12-04 09:30:46 +08:00
|
|
|
const int count = strtol(arg, &endptr, 0);
|
2007-10-17 14:24:50 +08:00
|
|
|
if (*endptr != '\0' || count < 0)
|
2007-12-04 09:30:46 +08:00
|
|
|
gold_fatal(_("invalid thread count: %s"), arg);
|
2007-10-17 14:24:50 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_threads(bool value)
|
2007-12-04 09:30:46 +08:00
|
|
|
{
|
|
|
|
#ifndef ENABLE_THREADS
|
2008-02-27 05:45:30 +08:00
|
|
|
if (value)
|
|
|
|
gold_fatal(_("--threads not supported"));
|
2007-12-04 09:30:46 +08:00
|
|
|
#endif
|
2008-02-27 05:45:30 +08:00
|
|
|
this->threads_ = value;
|
2007-12-04 09:30:46 +08:00
|
|
|
}
|
2007-10-17 14:24:50 +08:00
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_no_threads(bool value)
|
|
|
|
{ this->set_threads(!value); }
|
2007-10-17 14:24:50 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
set_thread_count(const char* arg)
|
|
|
|
{
|
|
|
|
int count = this->parse_thread_count(arg);
|
|
|
|
this->thread_count_initial_ = count;
|
|
|
|
this->thread_count_middle_ = count;
|
|
|
|
this->thread_count_final_ = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_thread_count_initial(const char* arg)
|
|
|
|
{ this->thread_count_initial_ = this->parse_thread_count(arg); }
|
|
|
|
|
|
|
|
void
|
|
|
|
set_thread_count_middle(const char* arg)
|
2007-12-14 12:53:22 +08:00
|
|
|
{ this->thread_count_middle_ = this->parse_thread_count(arg); }
|
2007-10-17 14:24:50 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
set_thread_count_final(const char* arg)
|
2007-12-14 12:53:22 +08:00
|
|
|
{ this->thread_count_final_ = this->parse_thread_count(arg); }
|
2007-10-17 14:24:50 +08:00
|
|
|
|
2006-11-04 02:48:03 +08:00
|
|
|
void
|
|
|
|
ignore(const char*)
|
|
|
|
{ }
|
|
|
|
|
2007-10-23 13:05:48 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_execstack(bool)
|
2007-10-23 13:05:48 +08:00
|
|
|
{ this->execstack_ = EXECSTACK_YES; }
|
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_noexecstack(bool)
|
2007-10-23 13:05:48 +08:00
|
|
|
{ this->execstack_ = EXECSTACK_NO; }
|
|
|
|
|
2008-02-27 06:10:32 +08:00
|
|
|
void
|
|
|
|
set_max_page_size(const char* arg)
|
|
|
|
{
|
|
|
|
char* endptr;
|
|
|
|
this->max_page_size_ = strtoull(arg, &endptr, 0);
|
|
|
|
if (*endptr != '\0' || this->max_page_size_ == 0)
|
|
|
|
gold_fatal(_("invalid max-page-size: %s"), arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_common_page_size(const char* arg)
|
|
|
|
{
|
|
|
|
char* endptr;
|
|
|
|
this->common_page_size_ = strtoull(arg, &endptr, 0);
|
|
|
|
if (*endptr != '\0' || this->common_page_size_ == 0)
|
|
|
|
gold_fatal(_("invalid common-page-size: %s"), arg);
|
|
|
|
}
|
|
|
|
|
2007-11-22 08:05:51 +08:00
|
|
|
void
|
|
|
|
set_debug(unsigned int flags)
|
|
|
|
{ this->debug_ = flags; }
|
|
|
|
|
2007-10-23 13:05:48 +08:00
|
|
|
// Handle the -z option.
|
|
|
|
void
|
|
|
|
handle_z_option(const char*);
|
|
|
|
|
2007-11-22 08:05:51 +08:00
|
|
|
// Handle the --debug option.
|
|
|
|
void
|
|
|
|
handle_debug_option(const char*);
|
|
|
|
|
2007-10-04 13:49:04 +08:00
|
|
|
// Apply any sysroot to the directory lists.
|
|
|
|
void
|
|
|
|
add_sysroot();
|
|
|
|
|
2008-02-29 04:35:39 +08:00
|
|
|
bool define_common_;
|
|
|
|
bool user_set_define_common_;
|
2008-02-27 06:48:08 +08:00
|
|
|
const char* entry_;
|
2007-08-22 13:06:38 +08:00
|
|
|
bool export_dynamic_;
|
2008-01-04 13:35:24 +08:00
|
|
|
const char* soname_;
|
2006-11-15 03:21:05 +08:00
|
|
|
const char* dynamic_linker_;
|
2006-08-05 07:10:59 +08:00
|
|
|
Dir_list search_path_;
|
2007-09-21 13:43:33 +08:00
|
|
|
int optimization_level_;
|
2006-09-30 03:58:17 +08:00
|
|
|
const char* output_file_name_;
|
2008-02-27 05:45:30 +08:00
|
|
|
Object_format oformat_;
|
|
|
|
const char* oformat_string_;
|
2008-02-28 06:38:18 +08:00
|
|
|
bool emit_relocs_;
|
2006-08-05 07:10:59 +08:00
|
|
|
bool is_relocatable_;
|
2007-10-11 03:02:56 +08:00
|
|
|
Strip strip_;
|
2007-11-14 15:34:53 +08:00
|
|
|
bool allow_shlib_undefined_;
|
2007-10-19 07:20:53 +08:00
|
|
|
bool symbolic_;
|
2007-11-30 08:35:27 +08:00
|
|
|
CompressionMethod compress_debug_sections_;
|
2007-11-15 09:12:55 +08:00
|
|
|
bool demangle_;
|
2007-11-14 09:03:01 +08:00
|
|
|
bool detect_odr_violations_;
|
2007-08-23 01:07:36 +08:00
|
|
|
bool create_eh_frame_hdr_;
|
2007-08-22 04:37:32 +08:00
|
|
|
Dir_list rpath_;
|
2007-09-07 07:37:53 +08:00
|
|
|
Dir_list rpath_link_;
|
2006-10-21 04:40:49 +08:00
|
|
|
bool is_shared_;
|
2006-08-05 07:10:59 +08:00
|
|
|
bool is_static_;
|
2007-10-12 13:51:25 +08:00
|
|
|
bool print_stats_;
|
2007-10-04 13:49:04 +08:00
|
|
|
std::string sysroot_;
|
2008-02-14 06:47:28 +08:00
|
|
|
uint64_t bss_segment_address_;
|
|
|
|
uint64_t data_segment_address_;
|
2007-10-17 06:38:36 +08:00
|
|
|
uint64_t text_segment_address_;
|
2007-10-17 14:24:50 +08:00
|
|
|
bool threads_;
|
|
|
|
int thread_count_initial_;
|
|
|
|
int thread_count_middle_;
|
|
|
|
int thread_count_final_;
|
2007-10-23 13:05:48 +08:00
|
|
|
Execstack execstack_;
|
2008-02-27 06:10:32 +08:00
|
|
|
uint64_t max_page_size_;
|
|
|
|
uint64_t common_page_size_;
|
2007-11-22 08:05:51 +08:00
|
|
|
unsigned int debug_;
|
2006-08-05 07:10:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// The current state of the position dependent options.
|
|
|
|
|
|
|
|
class Position_dependent_options
|
|
|
|
{
|
|
|
|
public:
|
2008-02-08 15:06:58 +08:00
|
|
|
typedef General_options::Object_format Object_format;
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
Position_dependent_options();
|
|
|
|
|
2007-10-23 02:04:43 +08:00
|
|
|
// -Bdynamic/-Bstatic: Whether we are searching for a static archive
|
|
|
|
// -rather than a shared object.
|
2006-08-05 07:10:59 +08:00
|
|
|
bool
|
2008-03-05 02:21:43 +08:00
|
|
|
Bdynamic() const
|
|
|
|
{ return !this->do_static_search_; }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2006-11-15 03:21:05 +08:00
|
|
|
// --as-needed: Whether to add a DT_NEEDED argument only if the
|
|
|
|
// dynamic object is used.
|
|
|
|
bool
|
|
|
|
as_needed() const
|
|
|
|
{ return this->as_needed_; }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2007-08-22 07:37:56 +08:00
|
|
|
// --whole-archive: Whether to include the entire contents of an
|
|
|
|
// --archive.
|
|
|
|
bool
|
2008-02-27 05:45:30 +08:00
|
|
|
whole_archive() const
|
2007-08-22 07:37:56 +08:00
|
|
|
{ return this->include_whole_archive_; }
|
|
|
|
|
2008-02-08 15:06:58 +08:00
|
|
|
// --format: The format of the input file.
|
|
|
|
Object_format
|
2008-03-05 02:21:43 +08:00
|
|
|
format_enum() const
|
2008-02-08 15:06:58 +08:00
|
|
|
{ return this->input_format_; }
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_Bstatic(bool value)
|
|
|
|
{ this->do_static_search_ = value; }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_Bdynamic(bool value)
|
|
|
|
{ this->set_Bstatic(!value); }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2006-11-15 03:21:05 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_as_needed(bool value)
|
|
|
|
{ this->as_needed_ = value; }
|
2006-11-15 03:21:05 +08:00
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_no_as_needed(bool value)
|
|
|
|
{ this->set_as_needed(!value); }
|
2006-11-15 03:21:05 +08:00
|
|
|
|
2007-08-22 07:37:56 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_whole_archive(bool value)
|
|
|
|
{ this->include_whole_archive_ = value; }
|
2007-08-22 07:37:56 +08:00
|
|
|
|
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_no_whole_archive(bool value)
|
|
|
|
{ this->set_whole_archive(!value); }
|
2007-08-22 07:37:56 +08:00
|
|
|
|
2008-02-08 15:06:58 +08:00
|
|
|
void
|
2008-02-27 05:45:30 +08:00
|
|
|
set_format(const char*);
|
2008-02-08 15:06:58 +08:00
|
|
|
|
2008-03-05 02:21:43 +08:00
|
|
|
void
|
|
|
|
set_format_enum(Object_format value)
|
|
|
|
{ this->input_format_ = value; }
|
|
|
|
|
2006-11-15 03:21:05 +08:00
|
|
|
private:
|
2006-08-05 07:10:59 +08:00
|
|
|
bool do_static_search_;
|
2006-11-15 03:21:05 +08:00
|
|
|
bool as_needed_;
|
2007-08-22 07:37:56 +08:00
|
|
|
bool include_whole_archive_;
|
2008-02-08 15:06:58 +08:00
|
|
|
Object_format input_format_;
|
2006-08-05 07:10:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// A single file or library argument from the command line.
|
|
|
|
|
2006-11-04 02:26:11 +08:00
|
|
|
class Input_file_argument
|
2006-08-05 07:10:59 +08:00
|
|
|
{
|
|
|
|
public:
|
2007-10-03 05:24:41 +08:00
|
|
|
// name: file name or library name
|
|
|
|
// is_lib: true if name is a library name: that is, emits the leading
|
|
|
|
// "lib" and trailing ".so"/".a" from the name
|
|
|
|
// extra_search_path: an extra directory to look for the file, prior
|
|
|
|
// to checking the normal library search path. If this is "",
|
|
|
|
// then no extra directory is added.
|
2008-02-07 09:51:25 +08:00
|
|
|
// just_symbols: whether this file only defines symbols.
|
2007-10-03 05:24:41 +08:00
|
|
|
// options: The position dependent options at this point in the
|
2007-10-04 13:49:04 +08:00
|
|
|
// command line, such as --whole-archive.
|
2006-11-04 02:26:11 +08:00
|
|
|
Input_file_argument()
|
2008-02-07 09:51:25 +08:00
|
|
|
: name_(), is_lib_(false), extra_search_path_(""), just_symbols_(false),
|
|
|
|
options_()
|
2006-11-04 02:26:11 +08:00
|
|
|
{ }
|
|
|
|
|
|
|
|
Input_file_argument(const char* name, bool is_lib,
|
2007-10-03 05:24:41 +08:00
|
|
|
const char* extra_search_path,
|
2008-02-07 09:51:25 +08:00
|
|
|
bool just_symbols,
|
2006-11-04 02:26:11 +08:00
|
|
|
const Position_dependent_options& options)
|
2007-10-03 05:24:41 +08:00
|
|
|
: name_(name), is_lib_(is_lib), extra_search_path_(extra_search_path),
|
2008-02-07 09:51:25 +08:00
|
|
|
just_symbols_(just_symbols), options_(options)
|
2006-08-05 07:10:59 +08:00
|
|
|
{ }
|
|
|
|
|
|
|
|
const char*
|
|
|
|
name() const
|
2006-11-15 03:21:05 +08:00
|
|
|
{ return this->name_.c_str(); }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
|
|
|
const Position_dependent_options&
|
|
|
|
options() const
|
|
|
|
{ return this->options_; }
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_lib() const
|
2006-09-30 03:58:17 +08:00
|
|
|
{ return this->is_lib_; }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2007-10-03 05:24:41 +08:00
|
|
|
const char*
|
|
|
|
extra_search_path() const
|
|
|
|
{
|
|
|
|
return (this->extra_search_path_.empty()
|
|
|
|
? NULL
|
|
|
|
: this->extra_search_path_.c_str());
|
|
|
|
}
|
|
|
|
|
2008-02-07 09:51:25 +08:00
|
|
|
// Return whether we should only read symbols from this file.
|
|
|
|
bool
|
|
|
|
just_symbols() const
|
|
|
|
{ return this->just_symbols_; }
|
|
|
|
|
2007-10-03 05:24:41 +08:00
|
|
|
// Return whether this file may require a search using the -L
|
|
|
|
// options.
|
|
|
|
bool
|
|
|
|
may_need_search() const
|
|
|
|
{ return this->is_lib_ || !this->extra_search_path_.empty(); }
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
private:
|
2006-11-15 03:21:05 +08:00
|
|
|
// We use std::string, not const char*, here for convenience when
|
|
|
|
// using script files, so that we do not have to preserve the string
|
|
|
|
// in that case.
|
|
|
|
std::string name_;
|
2006-09-30 03:58:17 +08:00
|
|
|
bool is_lib_;
|
2007-10-03 05:24:41 +08:00
|
|
|
std::string extra_search_path_;
|
2008-02-07 09:51:25 +08:00
|
|
|
bool just_symbols_;
|
2006-08-05 07:10:59 +08:00
|
|
|
Position_dependent_options options_;
|
|
|
|
};
|
|
|
|
|
2006-11-04 02:26:11 +08:00
|
|
|
// A file or library, or a group, from the command line.
|
|
|
|
|
|
|
|
class Input_argument
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Create a file or library argument.
|
|
|
|
explicit Input_argument(Input_file_argument file)
|
|
|
|
: is_file_(true), file_(file), group_(NULL)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
// Create a group argument.
|
|
|
|
explicit Input_argument(Input_file_group* group)
|
|
|
|
: is_file_(false), group_(group)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
// Return whether this is a file.
|
|
|
|
bool
|
|
|
|
is_file() const
|
|
|
|
{ return this->is_file_; }
|
|
|
|
|
|
|
|
// Return whether this is a group.
|
|
|
|
bool
|
|
|
|
is_group() const
|
|
|
|
{ return !this->is_file_; }
|
|
|
|
|
|
|
|
// Return the information about the file.
|
|
|
|
const Input_file_argument&
|
|
|
|
file() const
|
|
|
|
{
|
2006-11-30 01:56:40 +08:00
|
|
|
gold_assert(this->is_file_);
|
2006-11-04 02:26:11 +08:00
|
|
|
return this->file_;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the information about the group.
|
|
|
|
const Input_file_group*
|
|
|
|
group() const
|
|
|
|
{
|
2006-11-30 01:56:40 +08:00
|
|
|
gold_assert(!this->is_file_);
|
2006-11-04 02:26:11 +08:00
|
|
|
return this->group_;
|
|
|
|
}
|
|
|
|
|
|
|
|
Input_file_group*
|
|
|
|
group()
|
|
|
|
{
|
2006-11-30 01:56:40 +08:00
|
|
|
gold_assert(!this->is_file_);
|
2006-11-04 02:26:11 +08:00
|
|
|
return this->group_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool is_file_;
|
|
|
|
Input_file_argument file_;
|
|
|
|
Input_file_group* group_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// A group from the command line. This is a set of arguments within
|
|
|
|
// --start-group ... --end-group.
|
|
|
|
|
|
|
|
class Input_file_group
|
2006-10-21 04:40:49 +08:00
|
|
|
{
|
2006-11-04 02:26:11 +08:00
|
|
|
public:
|
|
|
|
typedef std::vector<Input_argument> Files;
|
|
|
|
typedef Files::const_iterator const_iterator;
|
|
|
|
|
|
|
|
Input_file_group()
|
|
|
|
: files_()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
// Add a file to the end of the group.
|
|
|
|
void
|
|
|
|
add_file(const Input_file_argument& arg)
|
|
|
|
{ this->files_.push_back(Input_argument(arg)); }
|
|
|
|
|
|
|
|
// Iterators to iterate over the group contents.
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
begin() const
|
|
|
|
{ return this->files_.begin(); }
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
end() const
|
|
|
|
{ return this->files_.end(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Files files_;
|
2006-10-21 04:40:49 +08:00
|
|
|
};
|
|
|
|
|
2006-11-15 03:21:05 +08:00
|
|
|
// A list of files from the command line or a script.
|
|
|
|
|
|
|
|
class Input_arguments
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef std::vector<Input_argument> Input_argument_list;
|
|
|
|
typedef Input_argument_list::const_iterator const_iterator;
|
|
|
|
|
|
|
|
Input_arguments()
|
|
|
|
: input_argument_list_(), in_group_(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
// Add a file.
|
|
|
|
void
|
|
|
|
add_file(const Input_file_argument& arg);
|
|
|
|
|
|
|
|
// Start a group (the --start-group option).
|
|
|
|
void
|
|
|
|
start_group();
|
|
|
|
|
|
|
|
// End a group (the --end-group option).
|
|
|
|
void
|
|
|
|
end_group();
|
|
|
|
|
|
|
|
// Return whether we are currently in a group.
|
|
|
|
bool
|
|
|
|
in_group() const
|
|
|
|
{ return this->in_group_; }
|
|
|
|
|
2007-10-17 14:24:50 +08:00
|
|
|
// The number of entries in the list.
|
|
|
|
int
|
|
|
|
size() const
|
|
|
|
{ return this->input_argument_list_.size(); }
|
|
|
|
|
2006-11-15 03:21:05 +08:00
|
|
|
// Iterators to iterate over the list of input files.
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
begin() const
|
|
|
|
{ return this->input_argument_list_.begin(); }
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
end() const
|
|
|
|
{ return this->input_argument_list_.end(); }
|
|
|
|
|
|
|
|
// Return whether the list is empty.
|
|
|
|
bool
|
|
|
|
empty() const
|
|
|
|
{ return this->input_argument_list_.empty(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Input_argument_list input_argument_list_;
|
|
|
|
bool in_group_;
|
|
|
|
};
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
// All the information read from the command line.
|
|
|
|
|
|
|
|
class Command_line
|
|
|
|
{
|
|
|
|
public:
|
2006-11-04 02:26:11 +08:00
|
|
|
typedef Input_arguments::const_iterator const_iterator;
|
|
|
|
|
2008-02-27 06:48:08 +08:00
|
|
|
Command_line();
|
2006-08-05 07:10:59 +08:00
|
|
|
|
|
|
|
// Process the command line options. This will exit with an
|
|
|
|
// appropriate error message if an unrecognized option is seen.
|
|
|
|
void
|
|
|
|
process(int argc, char** argv);
|
|
|
|
|
2007-10-30 14:27:03 +08:00
|
|
|
// Process one command-line option. This takes the index of argv to
|
|
|
|
// process, and returns the index for the next option.
|
|
|
|
int
|
|
|
|
process_one_option(int argc, char** argv, int i, bool* no_more_options);
|
|
|
|
|
2006-09-30 03:58:17 +08:00
|
|
|
// Handle a -l option.
|
|
|
|
int
|
2007-10-27 08:29:34 +08:00
|
|
|
process_l_option(int, char**, char*, bool);
|
2006-09-30 03:58:17 +08:00
|
|
|
|
2008-02-07 09:51:25 +08:00
|
|
|
// Handle a -R option when it means --rpath.
|
|
|
|
void
|
|
|
|
add_to_rpath(const char* arg)
|
|
|
|
{ this->options_.add_to_rpath(arg); }
|
|
|
|
|
|
|
|
// Add a file for which we just read the symbols.
|
|
|
|
void
|
|
|
|
add_just_symbols_file(const char* arg)
|
|
|
|
{
|
|
|
|
this->inputs_.add_file(Input_file_argument(arg, false, "", true,
|
|
|
|
this->position_options_));
|
|
|
|
}
|
|
|
|
|
2006-11-04 02:26:11 +08:00
|
|
|
// Handle a --start-group option.
|
|
|
|
void
|
|
|
|
start_group(const char* arg);
|
|
|
|
|
|
|
|
// Handle a --end-group option.
|
|
|
|
void
|
|
|
|
end_group(const char* arg);
|
|
|
|
|
2007-10-27 08:29:34 +08:00
|
|
|
// Get an option argument--a helper function for special processing.
|
|
|
|
const char*
|
|
|
|
get_special_argument(const char* longname, int argc, char** argv,
|
|
|
|
const char* arg, bool long_option,
|
|
|
|
int *pret);
|
|
|
|
|
2006-09-30 03:58:17 +08:00
|
|
|
// Get the general options.
|
2006-08-05 07:10:59 +08:00
|
|
|
const General_options&
|
|
|
|
options() const
|
|
|
|
{ return this->options_; }
|
|
|
|
|
2007-10-27 08:29:34 +08:00
|
|
|
// Get the position dependent options.
|
|
|
|
const Position_dependent_options&
|
|
|
|
position_dependent_options() const
|
|
|
|
{ return this->position_options_; }
|
|
|
|
|
2008-02-27 06:48:08 +08:00
|
|
|
// Get the linker-script options.
|
|
|
|
Script_options&
|
2008-01-10 03:57:45 +08:00
|
|
|
script_options()
|
2008-02-27 06:48:08 +08:00
|
|
|
{ return this->script_options_; }
|
2008-01-10 03:57:45 +08:00
|
|
|
|
2008-02-27 06:48:08 +08:00
|
|
|
// Get the version-script options: a convenience routine.
|
|
|
|
const Version_script_info&
|
|
|
|
version_script() const
|
|
|
|
{ return *this->script_options_.version_script_info(); }
|
2008-01-10 03:57:45 +08:00
|
|
|
|
2007-10-17 14:24:50 +08:00
|
|
|
// The number of input files.
|
|
|
|
int
|
|
|
|
number_of_input_files() const
|
|
|
|
{ return this->inputs_.size(); }
|
|
|
|
|
2006-11-04 02:26:11 +08:00
|
|
|
// Iterators to iterate over the list of input files.
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
begin() const
|
|
|
|
{ return this->inputs_.begin(); }
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
end() const
|
|
|
|
{ return this->inputs_.end(); }
|
2006-08-05 07:10:59 +08:00
|
|
|
|
|
|
|
private:
|
2006-11-04 02:26:11 +08:00
|
|
|
Command_line(const Command_line&);
|
|
|
|
Command_line& operator=(const Command_line&);
|
|
|
|
|
|
|
|
// Report usage error.
|
|
|
|
void
|
|
|
|
usage() ATTRIBUTE_NORETURN;
|
|
|
|
void
|
|
|
|
usage(const char* msg, const char* opt) ATTRIBUTE_NORETURN;
|
|
|
|
void
|
|
|
|
usage(const char* msg, char opt) ATTRIBUTE_NORETURN;
|
|
|
|
|
|
|
|
// Apply a command line option.
|
|
|
|
void
|
|
|
|
apply_option(const gold::options::One_option&, const char*);
|
|
|
|
|
|
|
|
// Add a file.
|
|
|
|
void
|
|
|
|
add_file(const char* name, bool is_lib);
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2007-10-11 03:30:39 +08:00
|
|
|
// Examine the result of processing the command-line, and verify
|
|
|
|
// the flags do not contradict each other or are otherwise illegal.
|
|
|
|
void
|
|
|
|
normalize_options();
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
General_options options_;
|
|
|
|
Position_dependent_options position_options_;
|
2008-02-27 06:48:08 +08:00
|
|
|
Script_options script_options_;
|
2006-11-04 02:26:11 +08:00
|
|
|
Input_arguments inputs_;
|
2006-08-05 07:10:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End namespace gold.
|
|
|
|
|
|
|
|
#endif // !defined(GOLD_OPTIONS_H)
|