mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2025-02-03 23:56:39 +00:00
Add support for -E/--export-dynamic. Also clean up --help output a bit.
This commit is contained in:
parent
6b2d86bda4
commit
a6badf5a97
@ -138,6 +138,7 @@ help(int, char**, char*, gold::Command_line*)
|
||||
}
|
||||
printf(options[j].help_output);
|
||||
len += std::strlen(options[i].help_output);
|
||||
comma = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -150,6 +151,7 @@ help(int, char**, char*, gold::Command_line*)
|
||||
}
|
||||
printf("-%c", options[j].short_option);
|
||||
len += 2;
|
||||
comma = true;
|
||||
}
|
||||
|
||||
if (options[j].long_option != NULL)
|
||||
@ -171,13 +173,14 @@ help(int, char**, char*, gold::Command_line*)
|
||||
}
|
||||
printf("%s", options[j].long_option);
|
||||
len += std::strlen(options[j].long_option);
|
||||
comma = true;
|
||||
}
|
||||
}
|
||||
++j;
|
||||
}
|
||||
while (j < options_size && options[j].doc == NULL);
|
||||
|
||||
if (len > 30)
|
||||
if (len >= 30)
|
||||
{
|
||||
printf("\n");
|
||||
len = 0;
|
||||
@ -225,12 +228,14 @@ const options::One_option
|
||||
options::Command_line_options::options[] =
|
||||
{
|
||||
SPECIAL('l', "library", N_("Search for library LIBNAME"),
|
||||
N_("-lLIBNAME --library LIBNAME"), TWO_DASHES,
|
||||
N_("-lLIBNAME, --library LIBNAME"), TWO_DASHES,
|
||||
&library),
|
||||
SPECIAL('(', "start-group", N_("Start a library search group"), NULL,
|
||||
TWO_DASHES, &start_group),
|
||||
SPECIAL(')', "end-group", N_("End a library search group"), NULL,
|
||||
TWO_DASHES, &end_group),
|
||||
GENERAL_NOARG('E', "export-dynamic", N_("Export all dynamic symbols"),
|
||||
NULL, TWO_DASHES, &General_options::set_export_dynamic),
|
||||
GENERAL_ARG('I', "dynamic-linker", N_("Set dynamic linker path"),
|
||||
N_("-I PROGRAM, --dynamic-linker PROGRAM"), TWO_DASHES,
|
||||
&General_options::set_dynamic_linker),
|
||||
@ -252,10 +257,10 @@ options::Command_line_options::options[] =
|
||||
GENERAL_NOARG('\0', "static", N_("Do not link against shared libraries"),
|
||||
NULL, ONE_DASH, &General_options::set_static),
|
||||
POSDEP_NOARG('\0', "as-needed",
|
||||
N_("Only set DT_NEEDED for following dynamic libs if used"),
|
||||
N_("Only set DT_NEEDED for dynamic libs if used"),
|
||||
NULL, TWO_DASHES, &Position_dependent_options::set_as_needed),
|
||||
POSDEP_NOARG('\0', "no-as-needed",
|
||||
N_("Always DT_NEEDED for following dynamic libs (default)"),
|
||||
N_("Always DT_NEEDED for dynamic libs (default)"),
|
||||
NULL, TWO_DASHES, &Position_dependent_options::clear_as_needed),
|
||||
POSDEP_NOARG('\0', "whole-archive",
|
||||
N_("Include all archive contents"),
|
||||
@ -275,7 +280,8 @@ const int options::Command_line_options::options_size =
|
||||
// The default values for the general options.
|
||||
|
||||
General_options::General_options()
|
||||
: dynamic_linker_(NULL),
|
||||
: export_dynamic_(false),
|
||||
dynamic_linker_(NULL),
|
||||
search_path_(),
|
||||
output_file_name_("a.out"),
|
||||
is_relocatable_(false),
|
||||
|
@ -37,6 +37,11 @@ class General_options
|
||||
public:
|
||||
General_options();
|
||||
|
||||
// -E: export dynamic symbols.
|
||||
bool
|
||||
export_dynamic() const
|
||||
{ return this->export_dynamic_; }
|
||||
|
||||
// -I: dynamic linker name.
|
||||
const char*
|
||||
dynamic_linker() const
|
||||
@ -82,6 +87,10 @@ class General_options
|
||||
friend class Command_line;
|
||||
friend class options::Command_line_options;
|
||||
|
||||
void
|
||||
set_export_dynamic()
|
||||
{ this->export_dynamic_ = true; }
|
||||
|
||||
void
|
||||
set_dynamic_linker(const char* arg)
|
||||
{ this->dynamic_linker_ = arg; }
|
||||
@ -114,6 +123,7 @@ class General_options
|
||||
ignore(const char*)
|
||||
{ }
|
||||
|
||||
bool export_dynamic_;
|
||||
const char* dynamic_linker_;
|
||||
Dir_list search_path_;
|
||||
const char* output_file_name_;
|
||||
|
@ -1001,7 +1001,10 @@ Symbol_table::set_dynsym_indexes(const General_options* options,
|
||||
// some symbols appear more than once in the symbol table, with
|
||||
// and without a version.
|
||||
|
||||
if (!sym->needs_dynsym_entry())
|
||||
if (!sym->needs_dynsym_entry()
|
||||
&& (!options->export_dynamic()
|
||||
|| !sym->in_reg()
|
||||
|| !sym->is_externally_visible()))
|
||||
sym->set_dynsym_index(-1U);
|
||||
else if (!sym->has_dynsym_index())
|
||||
{
|
||||
|
@ -337,6 +337,14 @@ class Symbol
|
||||
|| this->type_ == elfcpp::STT_COMMON));
|
||||
}
|
||||
|
||||
// Return whether this symbol can be seen outside this object.
|
||||
bool
|
||||
is_externally_visible() const
|
||||
{
|
||||
return (this->visibility_ == elfcpp::STV_DEFAULT
|
||||
|| this->visibility_ == elfcpp::STV_PROTECTED);
|
||||
}
|
||||
|
||||
// Return whether there should be a warning for references to this
|
||||
// symbol.
|
||||
bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user