Add heuristics for undefined symbol warnings.

This commit is contained in:
Ian Lance Taylor
2007-11-14 16:53:25 +00:00
parent 3e6fe5ae73
commit 9a2d698415
13 changed files with 129 additions and 48 deletions

View File

@@ -25,6 +25,7 @@
#include <cerrno>
#include <cstring>
#include <cstdarg>
#include "libiberty.h"
#include "target-select.h"
#include "dwarf_reader.h"
@@ -1062,9 +1063,10 @@ Input_objects::add_object(Object* obj)
{
// See if this is a duplicate SONAME.
Dynobj* dynobj = static_cast<Dynobj*>(obj);
const char* soname = dynobj->soname();
std::pair<Unordered_set<std::string>::iterator, bool> ins =
this->sonames_.insert(dynobj->soname());
this->sonames_.insert(soname);
if (!ins.second)
{
// We have already seen a dynamic object with this soname.
@@ -1072,6 +1074,19 @@ 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);
}
}
set_parameters_size_and_endianness(target->get_size(),
@@ -1080,6 +1095,17 @@ 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.