daily update
[binutils-gdb.git] / gold / options.h
index dbfb3bd15adda9e41932f081a8b82454b9336db4..ef8e26fa6ad1bd0ef648766e511ec1e6864f835b 100644 (file)
@@ -37,6 +37,7 @@
 #include <string>
 #include <vector>
 
+#include "elfcpp.h"
 #include "script.h"
 
 namespace gold
@@ -45,6 +46,7 @@ namespace gold
 class Command_line;
 class Input_file_group;
 class Position_dependent_options;
+class Target;
 
 namespace options
 {
@@ -109,6 +111,14 @@ class Search_directory
 class General_options
 {
  public:
+  enum Object_format
+  {
+    // Ordinary ELF.
+    OBJECT_FORMAT_ELF,
+    // Straight binary format.
+    OBJECT_FORMAT_BINARY
+  };
+
   General_options(Script_options*);
 
   // -e: set entry address.
@@ -148,6 +158,15 @@ class General_options
   output_file_name() const
   { return this->output_file_name_; }
 
+  // --oformat: Output format.
+  Object_format
+  output_format() const
+  { return this->output_format_; }
+
+  // Return the default target.
+  Target*
+  default_target() const;
+
   // -r: Whether we are doing a relocatable link.
   bool
   is_relocatable() const
@@ -241,6 +260,26 @@ class General_options
   version_script() const
   { return *this->script_options_->version_script_info(); }
 
+  // -Tbss: The address of the BSS segment
+  uint64_t
+  bss_segment_address() const
+  { return this->bss_segment_address_; }
+
+  // Whether -Tbss was used.
+  bool
+  user_set_bss_segment_address() const
+  { return this->bss_segment_address_ != -1U; }
+
+  // -Tdata: The address of the data segment
+  uint64_t
+  data_segment_address() const
+  { return this->data_segment_address_; }
+
+  // Whether -Tdata was used.
+  bool
+  user_set_data_segment_address() const
+  { return this->data_segment_address_ != -1U; }
+
   // -Ttext: The address of the .text section
   uint64_t
   text_segment_address() const
@@ -370,6 +409,9 @@ class General_options
   set_output_file_name(const char* arg)
   { this->output_file_name_ = arg; }
 
+  void
+  set_output_format(const char*);
+
   void
   set_relocatable()
   { this->is_relocatable_ = true; }
@@ -457,15 +499,26 @@ class General_options
   { this->sysroot_ = arg; }
 
   void
-  set_text_segment_address(const char* arg)
+  set_segment_address(const char* name, const char* arg, uint64_t* val)
   {
     char* endptr;
-    this->text_segment_address_ = strtoull(arg, &endptr, 0);
-    if (*endptr != '\0'
-       || this->text_segment_address_ == -1U)
-      gold_fatal(_("invalid argument to -Ttext: %s"), arg);
+    *val = strtoull(arg, &endptr, 0);
+    if (*endptr != '\0' || *val == -1U)
+      gold_fatal(_("invalid argument to %s: %s"), name, arg);
   }
 
+  void
+  set_bss_segment_address(const char* arg)
+  { this->set_segment_address("-Tbss", arg, &this->bss_segment_address_); }
+
+  void
+  set_data_segment_address(const char* arg)
+  { this->set_segment_address("-Tdata", arg, &this->data_segment_address_); }
+
+  void
+  set_text_segment_address(const char* arg)
+  { this->set_segment_address("-Ttext", arg, &this->text_segment_address_); }
+
   int
   parse_thread_count(const char* arg)
   {
@@ -544,6 +597,8 @@ class General_options
   Dir_list search_path_;
   int optimization_level_;
   const char* output_file_name_;
+  Object_format output_format_;
+  const char* output_format_string_;
   bool is_relocatable_;
   Strip strip_;
   bool allow_shlib_undefined_;
@@ -558,6 +613,8 @@ class General_options
   bool is_static_;
   bool print_stats_;
   std::string sysroot_;
+  uint64_t bss_segment_address_;
+  uint64_t data_segment_address_;
   uint64_t text_segment_address_;
   bool threads_;
   int thread_count_initial_;
@@ -575,6 +632,8 @@ class General_options
 class Position_dependent_options
 {
  public:
+  typedef General_options::Object_format Object_format;
+
   Position_dependent_options();
 
   // -Bdynamic/-Bstatic: Whether we are searching for a static archive
@@ -595,6 +654,11 @@ class Position_dependent_options
   include_whole_archive() const
   { return this->include_whole_archive_; }
 
+  // --format: The format of the input file.
+  Object_format
+  input_format() const
+  { return this->input_format_; }
+
   void
   set_static_search()
   { this->do_static_search_ = true; }
@@ -619,10 +683,14 @@ class Position_dependent_options
   clear_whole_archive()
   { this->include_whole_archive_ = false; }
 
+  void
+  set_input_format(const char*);
+
  private:
   bool do_static_search_;
   bool as_needed_;
   bool include_whole_archive_;
+  Object_format input_format_;
 };
 
 // A single file or library argument from the command line.