Fix DWARFDataExtractor::getRelocatedValue near EOF
authorPavel Labath <pavel@labath.sk>
Tue, 14 Apr 2020 15:06:04 +0000 (17:06 +0200)
committerPavel Labath <pavel@labath.sk>
Wed, 15 Apr 2020 10:47:57 +0000 (12:47 +0200)
commit122c50d5efc2d5bc8d6716a532ba0cc6b773ab3a
treea336fb66c26726932419d2b05bed407c8ee1e894
parentcf9ee49b4d7f2e1341b84f941ad55cce1b16722d
Fix DWARFDataExtractor::getRelocatedValue near EOF

Summary:
If we have an (invalid) relocation which relocates bytes which partially
lie outside the range of the relocated section, the getRelocatedValue
would return confusing results. It would first read zero (because that's
what the underlying DataExtractor api does for out-of-bounds reads), and
then relocate that zero anyway.

A more appropriate behavior is to return zero straight away. This is
what this patch does.

Reviewers: dblaikie, jhenderson

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78113
llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDataExtractorTest.cpp