aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog20
-rw-r--r--gold/fileread.cc10
-rw-r--r--gold/fileread.h4
-rw-r--r--gold/layout.cc4
-rw-r--r--gold/object.cc24
-rw-r--r--gold/object.h10
-rw-r--r--gold/options.cc26
-rw-r--r--gold/options.h17
-rw-r--r--gold/symtab.cc35
-rw-r--r--gold/symtab.h10
10 files changed, 100 insertions, 60 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index dfc99b7..3f9d219 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,25 @@
2009-02-27 Ian Lance Taylor <iant@google.com>
+ PR 6811
+ * options.h (class Search_directory): Add is_system_directory.
+ (class General_options): Declare is_in_system_directory.
+ * options.cc (get_relative_sysroot): Make static.
+ (get_default_sysroot): Make static.
+ (General_optoins::is_in_system_directory): New function.
+ * fileread.cc (Input_file::is_in_system_directory): New function.
+ * fileread.h (class Input_file): Declare is_in_system_directory.
+ * object.h (class Object): Add is_in_system_directory.
+ (class Input_objects): Remove system_library_directory_ field.
+ * object.cc (Input_objects::add_object): Don't set
+ system_library_directory_.
+ (input_objects::found_in_system_library_directory): Remove.
+ * symtab.cc (Symbol_table::write_globals): Remove input_objects
+ parameter. Change all callers.
+ (Symbol_table::sized_write_globals): Likewise.
+ (Symbol_table::warn_about_undefined_dynobj_symbol): Likewise.
+ Call Object::is_in_system_directory.
+ * symtab.h (class Symbol_table): Update declarations.
+
PR 5990
* descriptors.h (Open_descriptor): Add is_on_stack field.
* descriptors.cc (Descriptors::open): If the descriptor is on the
diff --git a/gold/fileread.cc b/gold/fileread.cc
index 36eee6c..13442ff 100644
--- a/gold/fileread.cc
+++ b/gold/fileread.cc
@@ -738,6 +738,16 @@ Input_file::name() const
return this->input_argument_->name();
}
+// Return whether this file is in a system directory.
+
+bool
+Input_file::is_in_system_directory() const
+{
+ if (this->is_in_sysroot())
+ return true;
+ return parameters->options().is_in_system_directory(this->filename());
+}
+
// Return whether we are only reading symbols.
bool
diff --git a/gold/fileread.h b/gold/fileread.h
index 3afba86..1c0969c 100644
--- a/gold/fileread.h
+++ b/gold/fileread.h
@@ -471,6 +471,10 @@ class Input_file
is_in_sysroot() const
{ return this->is_in_sysroot_; }
+ // Whether this file is in a system directory.
+ bool
+ is_in_system_directory() const;
+
// Return whether this file is to be read only for its symbols.
bool
just_symbols() const;
diff --git a/gold/layout.cc b/gold/layout.cc
index 2bc1483..01b7c87 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -3317,8 +3317,8 @@ Write_symbols_task::locks(Task_locker* tl)
void
Write_symbols_task::run(Workqueue*)
{
- this->symtab_->write_globals(this->input_objects_, this->sympool_,
- this->dynpool_, this->layout_->symtab_xindex(),
+ this->symtab_->write_globals(this->sympool_, this->dynpool_,
+ this->layout_->symtab_xindex(),
this->layout_->dynsym_xindex(), this->of_);
}
diff --git a/gold/object.cc b/gold/object.cc
index 82c5dd6..0f618c1 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -1941,19 +1941,6 @@ Input_objects::add_object(Object* obj)
}
this->dynobj_list_.push_back(dynobj);
-
- // If this is -lc, remember the directory in which we found it.
- // We use this when issuing warnings about undefined symbols: as
- // a heuristic, we don't warn about system libraries found in
- // the same directory as -lc.
- if (strncmp(soname, "libc.so", 7) == 0)
- {
- const char* object_name = dynobj->name().c_str();
- const char* base = lbasename(object_name);
- if (base != object_name)
- this->system_library_directory_.assign(object_name,
- base - 1 - object_name);
- }
}
// Add this object to the cross-referencer if requested.
@@ -1967,17 +1954,6 @@ Input_objects::add_object(Object* obj)
return true;
}
-// Return whether an object was found in the system library directory.
-
-bool
-Input_objects::found_in_system_library_directory(const Object* object) const
-{
- return (!this->system_library_directory_.empty()
- && object->name().compare(0,
- this->system_library_directory_.size(),
- this->system_library_directory_) == 0);
-}
-
// For each dynamic object, record whether we've seen all of its
// explicit dependencies.
diff --git a/gold/object.h b/gold/object.h
index 6efc0fe..9e4c66f 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -444,6 +444,11 @@ class Object
set_target(Target* target)
{ this->target_ = target; }
+ // Return whether this object was found in a system directory.
+ bool
+ is_in_system_directory() const
+ { return this->input_file()->is_in_system_directory(); }
+
protected:
// Returns NULL for Objects that are not plugin objects. This method
// is overridden in the Pluginobj class.
@@ -1832,8 +1837,7 @@ class Input_objects
{
public:
Input_objects()
- : relobj_list_(), dynobj_list_(), sonames_(), system_library_directory_(),
- cref_(NULL)
+ : relobj_list_(), dynobj_list_(), sonames_(), cref_(NULL)
{ }
// The type of the list of input relocateable objects.
@@ -1911,8 +1915,6 @@ class Input_objects
Dynobj_list dynobj_list_;
// SONAMEs that we have seen.
Unordered_set<std::string> sonames_;
- // The directory in which we find the libc.so.
- std::string system_library_directory_;
// Manage cross-references if requested.
Cref* cref_;
};
diff --git a/gold/options.cc b/gold/options.cc
index 35ed863..3f6fbfa 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -1,6 +1,6 @@
// options.c -- handle command line options for gold
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -451,7 +451,7 @@ string_to_object_format(const char* arg)
// If the default sysroot is relocatable, try relocating it based on
// the prefix FROM.
-char*
+static char*
get_relative_sysroot(const char* from)
{
char* path = make_relative_prefix(gold::program_name, from,
@@ -472,7 +472,7 @@ get_relative_sysroot(const char* from)
// get_relative_sysroot, which is a small memory leak, but is
// necessary since we store this pointer directly in General_options.
-const char*
+static const char*
get_default_sysroot()
{
const char* sysroot = TARGET_SYSTEM_ROOT;
@@ -684,6 +684,26 @@ General_options::add_sysroot()
free(canonical_sysroot);
}
+// Return whether FILENAME is in a system directory.
+
+bool
+General_options::is_in_system_directory(const std::string& filename) const
+{
+ for (Dir_list::const_iterator p = this->library_path_.value.begin();
+ p != this->library_path_.value.end();
+ ++p)
+ {
+ // We use a straight string comparison rather than calling
+ // FILENAME_CMP because we are only interested in the cases
+ // where we found the file in a system directory, which means
+ // that we used the directory name as a prefix for a -L search.
+ if (p->is_system_directory()
+ && filename.compare(0, p->name().size(), p->name()) == 0)
+ return true;
+ }
+ return false;
+}
+
// Add a plugin to the list of plugins.
void
diff --git a/gold/options.h b/gold/options.h
index 1d30a56..7fd9a00 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -534,9 +534,22 @@ class Search_directory
is_in_sysroot() const
{ return this->is_in_sysroot_; }
+ // Return whether this is considered a system directory.
+ bool
+ is_system_directory() const
+ { return this->put_in_sysroot_ || this->is_in_sysroot_; }
+
private:
+ // The directory name.
std::string name_;
+ // True if the sysroot should be added as a prefix for this
+ // directory (if there is a sysroot). This is true for system
+ // directories that we search by default.
bool put_in_sysroot_;
+ // True if this directory is in the sysroot (if there is a sysroot).
+ // This is true if there is a sysroot and either 1) put_in_sysroot_
+ // is true, or 2) the directory happens to be in the sysroot based
+ // on a pathname comparison.
bool is_in_sysroot_;
};
@@ -962,6 +975,10 @@ class General_options
Object_format format_enum() const;
Object_format oformat_enum() const;
+ // Return whether FILENAME is in a system directory.
+ bool
+ is_in_system_directory(const std::string& name) const;
+
// These are the best way to get access to the execstack state,
// not execstack() and noexecstack() which are hard to use properly.
bool
diff --git a/gold/symtab.cc b/gold/symtab.cc
index dcbb46e..46bed68 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -2373,8 +2373,7 @@ Symbol_table::sized_finalize_symbol(Symbol* unsized_sym)
// Write out the global symbols.
void
-Symbol_table::write_globals(const Input_objects* input_objects,
- const Stringpool* sympool,
+Symbol_table::write_globals(const Stringpool* sympool,
const Stringpool* dynpool,
Output_symtab_xindex* symtab_xindex,
Output_symtab_xindex* dynsym_xindex,
@@ -2384,29 +2383,25 @@ Symbol_table::write_globals(const Input_objects* input_objects,
{
#ifdef HAVE_TARGET_32_LITTLE
case Parameters::TARGET_32_LITTLE:
- this->sized_write_globals<32, false>(input_objects, sympool,
- dynpool, symtab_xindex,
+ this->sized_write_globals<32, false>(sympool, dynpool, symtab_xindex,
dynsym_xindex, of);
break;
#endif
#ifdef HAVE_TARGET_32_BIG
case Parameters::TARGET_32_BIG:
- this->sized_write_globals<32, true>(input_objects, sympool,
- dynpool, symtab_xindex,
+ this->sized_write_globals<32, true>(sympool, dynpool, symtab_xindex,
dynsym_xindex, of);
break;
#endif
#ifdef HAVE_TARGET_64_LITTLE
case Parameters::TARGET_64_LITTLE:
- this->sized_write_globals<64, false>(input_objects, sympool,
- dynpool, symtab_xindex,
+ this->sized_write_globals<64, false>(sympool, dynpool, symtab_xindex,
dynsym_xindex, of);
break;
#endif
#ifdef HAVE_TARGET_64_BIG
case Parameters::TARGET_64_BIG:
- this->sized_write_globals<64, true>(input_objects, sympool,
- dynpool, symtab_xindex,
+ this->sized_write_globals<64, true>(sympool, dynpool, symtab_xindex,
dynsym_xindex, of);
break;
#endif
@@ -2419,8 +2414,7 @@ Symbol_table::write_globals(const Input_objects* input_objects,
template<int size, bool big_endian>
void
-Symbol_table::sized_write_globals(const Input_objects* input_objects,
- const Stringpool* sympool,
+Symbol_table::sized_write_globals(const Stringpool* sympool,
const Stringpool* dynpool,
Output_symtab_xindex* symtab_xindex,
Output_symtab_xindex* dynsym_xindex,
@@ -2456,7 +2450,7 @@ Symbol_table::sized_write_globals(const Input_objects* input_objects,
Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(p->second);
// Possibly warn about unresolved symbols in shared libraries.
- this->warn_about_undefined_dynobj_symbol(input_objects, sym);
+ this->warn_about_undefined_dynobj_symbol(sym);
unsigned int sym_index = sym->symtab_index();
unsigned int dynsym_index;
@@ -2621,16 +2615,13 @@ Symbol_table::sized_write_symbol(
// entry, we aren't going to be able to reliably report whether the
// symbol is undefined.
-// We also don't warn about libraries found in the system library
-// directory (the directory were we find libc.so); we assume that
-// those libraries are OK. This heuristic avoids problems in
-// GNU/Linux, in which -ldl can have undefined references satisfied by
-// ld-linux.so.
+// We also don't warn about libraries found in a system library
+// directory (e.g., /lib or /usr/lib); we assume that those libraries
+// are OK. This heuristic avoids problems on GNU/Linux, in which -ldl
+// can have undefined references satisfied by ld-linux.so.
inline void
-Symbol_table::warn_about_undefined_dynobj_symbol(
- const Input_objects* input_objects,
- Symbol* sym) const
+Symbol_table::warn_about_undefined_dynobj_symbol(Symbol* sym) const
{
bool dummy;
if (sym->source() == Symbol::FROM_OBJECT
@@ -2639,7 +2630,7 @@ Symbol_table::warn_about_undefined_dynobj_symbol(
&& sym->binding() != elfcpp::STB_WEAK
&& !parameters->options().allow_shlib_undefined()
&& !parameters->target().is_defined_by_abi(sym)
- && !input_objects->found_in_system_library_directory(sym->object()))
+ && !sym->object()->is_in_system_directory())
{
// A very ugly cast.
Dynobj* dynobj = static_cast<Dynobj*>(sym->object());
diff --git a/gold/symtab.h b/gold/symtab.h
index b504d0a..003318c 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -1342,7 +1342,7 @@ class Symbol_table
// Write out the global symbols.
void
- write_globals(const Input_objects*, const Stringpool*, const Stringpool*,
+ write_globals(const Stringpool*, const Stringpool*,
Output_symtab_xindex*, Output_symtab_xindex*,
Output_file*) const;
@@ -1509,9 +1509,9 @@ class Symbol_table
// Write globals specialized for size and endianness.
template<int size, bool big_endian>
void
- sized_write_globals(const Input_objects*, const Stringpool*,
- const Stringpool*, Output_symtab_xindex*,
- Output_symtab_xindex*, Output_file*) const;
+ sized_write_globals(const Stringpool*, const Stringpool*,
+ Output_symtab_xindex*, Output_symtab_xindex*,
+ Output_file*) const;
// Write out a symbol to P.
template<int size, bool big_endian>
@@ -1523,7 +1523,7 @@ class Symbol_table
// Possibly warn about an undefined symbol from a dynamic object.
void
- warn_about_undefined_dynobj_symbol(const Input_objects*, Symbol*) const;
+ warn_about_undefined_dynobj_symbol(Symbol*) const;
// Write out a section symbol, specialized for size and endianness.
template<int size, bool big_endian>