Assert that labels are defined when applying label relocations #6100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A label has a null address until its location is determined when it is encountered in the instruction stream during binary encoding. When the compiler generates a jump to a label whose address has not yet been determined, it also generates a label relocation to correct the jump target once the label's address is known after binary encoding. But if for some reason the label's address is never updated, the relocation would silently continue using zero and generate an incorrect jump.
Because such jumps can be hard to debug, this commit adds assertions that verify that the label has at least had some address set, otherwise failing fast. Note that zero cannot be the true address of a label, since we never generate instructions there.