+2009-06-22 Ian Lance Taylor <iant@google.com>
+
+ PR 10030
+ * yyscript.y: Parse TARGET.
+ * script.cc (script_set_target): New function.
+ * script-c.h (script_set_target): Declare.
+ * options.cc (General_options::string_to_object_format): Rename
+ from string_to_object_format in anonymous namespace. Change
+ callers.
+ * options.h (class General_options): Declare
+ string_to_object_format.
+
2009-06-22 Ian Lance Taylor <iant@google.com>
* script-sections.cc (Script_sections::create_segments): Don't put
return false;
}
+// Recognize input and output target names. The GNU linker accepts
+// these with --format and --oformat. This code is intended to be
+// minimally compatible. In practice for an ELF target this would be
+// the same target as the input files; that name always start with
+// "elf". Non-ELF targets would be "srec", "symbolsrec", "tekhex",
+// "binary", "ihex".
+
+General_options::Object_format
+General_options::string_to_object_format(const char* arg)
+{
+ if (strncmp(arg, "elf", 3) == 0)
+ return gold::General_options::OBJECT_FORMAT_ELF;
+ else if (strcmp(arg, "binary") == 0)
+ return gold::General_options::OBJECT_FORMAT_BINARY;
+ else
+ {
+ gold::gold_error(_("format '%s' not supported; treating as elf "
+ "(supported formats: elf, binary)"),
+ arg);
+ return gold::General_options::OBJECT_FORMAT_ELF;
+ }
+}
+
} // End namespace gold.
namespace
usage();
}
-// Recognize input and output target names. The GNU linker accepts
-// these with --format and --oformat. This code is intended to be
-// minimally compatible. In practice for an ELF target this would be
-// the same target as the input files; that name always start with
-// "elf". Non-ELF targets would be "srec", "symbolsrec", "tekhex",
-// "binary", "ihex".
-
-gold::General_options::Object_format
-string_to_object_format(const char* arg)
-{
- if (strncmp(arg, "elf", 3) == 0)
- return gold::General_options::OBJECT_FORMAT_ELF;
- else if (strcmp(arg, "binary") == 0)
- return gold::General_options::OBJECT_FORMAT_BINARY;
- else
- {
- gold::gold_error(_("format '%s' not supported; treating as elf "
- "(supported formats: elf, binary)"),
- arg);
- return gold::General_options::OBJECT_FORMAT_ELF;
- }
-}
-
// If the default sysroot is relocatable, try relocating it based on
// the prefix FROM.
General_options::Object_format
General_options::format_enum() const
{
- return string_to_object_format(this->format());
+ return General_options::string_to_object_format(this->format());
}
General_options::Object_format
General_options::oformat_enum() const
{
- return string_to_object_format(this->oformat());
+ return General_options::string_to_object_format(this->oformat());
}
// Add the sysroot, if any, to the search paths.
skip_on_incompatible_target() const
{ return this->skip_on_incompatible_target_; }
- // Stop skipping to the next flie on an incompatible target. This
+ // Stop skipping to the next file on an incompatible target. This
// is called when we make some unrevocable change to the data
// structures.
void
return 1;
}
+// Called by the bison parser to handle TARGET.
+
+extern "C" void
+script_set_target(void* closurev, const char* target, size_t len)
+{
+ Parser_closure* closure = static_cast<Parser_closure*>(closurev);
+ std::string s(target, len);
+ General_options::Object_format format_enum;
+ format_enum = General_options::string_to_object_format(s.c_str());
+ closure->position_dependent_options().set_format_enum(format_enum);
+}
+
// Called by the bison parser to handle SEARCH_DIR. This is handled
// exactly like a -L option.