OSDN Git Service

[symbolizer] Avoid collecting symbols belonging to invalid sections.
authorMatt Davis <Matthew.Davis@sony.com>
Thu, 14 Feb 2019 23:50:35 +0000 (23:50 +0000)
committerMatt Davis <Matthew.Davis@sony.com>
Thu, 14 Feb 2019 23:50:35 +0000 (23:50 +0000)
commit925de09633b0f91b1e082ca0a0448aaf854c1f1a
treea80f58cda7e07d38ad105a6f8743ac48b1ada05b
parentd4e78b06a146e17cb0b8913bd5694439c3093c5f
[symbolizer] Avoid collecting symbols belonging to invalid sections.

Summary:
llvm-symbolizer would originally report symbols that belonged to an invalid object file section.
Specifically the case where: `*Symbol.getSection() == ObjFile.section_end()`
This patch prevents the Symbolizer from collecting symbols that belong to invalid sections.

The test  (from PR40591) introduces a case where two symbols have address 0,
one symbol is defined, 'foo', and the other is not defined, 'bar'.  This patch will cause
the Symbolizer to keep 'foo' and ignore 'bar'.

As a side note, the logic for adding symbols to the Symbolizer's store
(`SymbolizableObjectFile::addSymbol`) replaces symbols with the
same <address, size> pair.  At some point that logic should be revisited as in the
aforementioned case, 'bar' was overwriting 'foo' in the Symbolizer's store,
and 'foo' was forgotten.

This fixes PR40591

Reviewers: jhenderson, rupprecht

Reviewed By: rupprecht

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58146

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354083 91177308-0d34-0410-b5e6-96231b3b80d8
lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
test/tools/llvm-symbolizer/ignore-undefined-symbols.s [new file with mode: 0644]