This is an archive of the discontinued LLVM Phabricator instance.

[LLD] Check for too large offsets into merge sections earlier to avoid DenseMap tombstone collision
ClosedPublic

Authored by bd1976llvm on Aug 23 2018, 1:21 PM.

Details

Summary

This patch moves the checking for too large offsets into merge sections earlier.

Without this change the large offset generated in the added test-case will cause an assert (as it happens to be a value reserved as a "tombstone" in the DenseMap implementation) when OffsetMap is queried in getSectionPiece().

To simplify the code and avoid future mistakes I have refactored so that there is only one function that looks up offsets in the OffsetMap.

Diff Detail

Repository
rL LLVM

Event Timeline

bd1976llvm created this revision.Aug 23 2018, 1:21 PM
bd1976llvm retitled this revision from [LLD] Check for too large offsets into merge sections earlier to avoid DenseMap tombstone collsiion to [LLD] Check for too large offsets into merge sections earlier to avoid DenseMap tombstone collision.Aug 23 2018, 1:28 PM
bd1976llvm edited the summary of this revision. (Show Details)
bd1976llvm added subscribers: jhenderson, edd, chrisjackson and 2 others.
ruiu accepted this revision.Aug 23 2018, 9:46 PM
ruiu edited reviewers, added: ruiu; removed: rui314.

LGTM

This revision is now accepted and ready to land.Aug 23 2018, 9:47 PM
grimar accepted this revision.Aug 24 2018, 1:33 AM

LGTM.

ELF/InputSection.cpp
1154 ↗(On Diff #162251)

I think it could be error, but I see that would require a bit more changes, so I would do that in follow up.

ruiu added a comment.Aug 24 2018, 2:01 AM

fatal() should be fine because that line is not unreachable unless you don't pass a corrupted input file.

This revision was automatically updated to reflect the committed changes.