diff options
author | Ian Lance Taylor <ian@airs.com> | 2011-03-10 01:31:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2011-03-10 01:31:33 +0000 |
commit | 71ff89863ff23a581a1578755785e6b39dd209f2 (patch) | |
tree | b5aab2587b661dc64d6117602ecb030274857c93 /gold/symtab.h | |
parent | a19fefdc57f5eafcb682175f2b2bcd8f6f366c90 (diff) | |
download | gdb-71ff89863ff23a581a1578755785e6b39dd209f2.zip gdb-71ff89863ff23a581a1578755785e6b39dd209f2.tar.gz gdb-71ff89863ff23a581a1578755785e6b39dd209f2.tar.bz2 |
* dwarf_reader.cc (Sized_dwarf_line_info): Include all lines,
but mark earlier ones as non-canonical
(offset_to_iterator): Update search target and example
(do_addr2line): Return extra lines in a vector*
(format_file_lineno): Extract from do_addr2line
(one_addr2line): Add vector* out-param
* dwarf_reader.h (Offset_to_lineno_entry): New field recording
when a lineno entry appeared last for its instruction
(Dwarf_line_info): Add vector* out-param
* object.cc (Relocate_info): Pass NULL for the vector* out-param
* symtab.cc (Odr_violation_compare): Include the lineno in the
comparison again.
(linenos_from_loc): New. Combine the canonical line for an
address with its other lines.
(True_if_intersect): New. Helper functor to make
std::set_intersection a query.
(detect_odr_violations): Compare sets of lines instead of just
one line for each function. This became less deterministic, but
has fewer false positives.
* symtab.h: Declarations.
* testsuite/Makefile.am (odr_violation2.o): Compile with -O2 to
mix an optimized and non-optimized object in the same binary
(odr_violation2.so): Same.
* testsuite/Makefile.in: Regenerate from Makefile.am.
* testsuite/debug_msg.cc (main): Make OdrDerived classes.
* testsuite/debug_msg.sh: Update line numbers and add
assertions.
* testsuite/odr_violation1.cc: Use OdrDerived, in a
non-optimized context.
* testsuite/odr_violation2.cc: Make sure Ordering::operator()
isn't inlined, and use OdrDerived in an optimized context.
* testsuite/odr_header1.h: Defines OdrDerived, where
optimization will change the
first-instruction-in-the-destructor's file and line number.
* testsuite/odr_header2.h: Defines OdrBase.
Diffstat (limited to 'gold/symtab.h')
-rw-r--r-- | gold/symtab.h | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/gold/symtab.h b/gold/symtab.h index c0ae358..d350d1d 100644 --- a/gold/symtab.h +++ b/gold/symtab.h @@ -1560,6 +1560,33 @@ class Symbol_table typedef Unordered_map<Symbol_table_key, Symbol*, Symbol_table_hash, Symbol_table_eq> Symbol_table_type; + // A map from symbol name (as a pointer into the namepool) to all + // the locations the symbols is (weakly) defined (and certain other + // conditions are met). This map will be used later to detect + // possible One Definition Rule (ODR) violations. + struct Symbol_location + { + Object* object; // Object where the symbol is defined. + unsigned int shndx; // Section-in-object where the symbol is defined. + off_t offset; // Offset-in-section where the symbol is defined. + bool operator==(const Symbol_location& that) const + { + return (this->object == that.object + && this->shndx == that.shndx + && this->offset == that.offset); + } + }; + + struct Symbol_location_hash + { + size_t operator()(const Symbol_location& loc) const + { return reinterpret_cast<uintptr_t>(loc.object) ^ loc.offset ^ loc.shndx; } + }; + + typedef Unordered_map<const char*, + Unordered_set<Symbol_location, Symbol_location_hash> > + Odr_map; + // Make FROM a forwarder symbol to TO. void make_forwarder(Symbol* from, Symbol* to); @@ -1707,6 +1734,12 @@ class Symbol_table do_allocate_commons_list(Layout*, Commons_section_type, Commons_type*, Mapfile*, Sort_commons_order); + // Returns all of the lines attached to LOC, not just the one the + // instruction actually came from. This helps the ODR checker avoid + // false positives. + static std::vector<std::string> + linenos_from_loc(const Task* task, const Symbol_location& loc); + // Implement detect_odr_violations. template<int size, bool big_endian> void @@ -1760,33 +1793,6 @@ class Symbol_table // they are defined. typedef Unordered_map<const Symbol*, Dynobj*> Copied_symbol_dynobjs; - // A map from symbol name (as a pointer into the namepool) to all - // the locations the symbols is (weakly) defined (and certain other - // conditions are met). This map will be used later to detect - // possible One Definition Rule (ODR) violations. - struct Symbol_location - { - Object* object; // Object where the symbol is defined. - unsigned int shndx; // Section-in-object where the symbol is defined. - off_t offset; // Offset-in-section where the symbol is defined. - bool operator==(const Symbol_location& that) const - { - return (this->object == that.object - && this->shndx == that.shndx - && this->offset == that.offset); - } - }; - - struct Symbol_location_hash - { - size_t operator()(const Symbol_location& loc) const - { return reinterpret_cast<uintptr_t>(loc.object) ^ loc.offset ^ loc.shndx; } - }; - - typedef Unordered_map<const char*, - Unordered_set<Symbol_location, Symbol_location_hash> > - Odr_map; - // We increment this every time we see a new undefined symbol, for // use in archive groups. size_t saw_undefined_; |