Page MenuHomePhabricator

[DWARFYAML][debug_ranges] Emit an error message for invalid offset.
ClosedPublic

Authored by Higuoxing on Jun 7 2020, 8:53 PM.

Details

Summary

This patch helps make yaml2obj emit an error message when we try to assign an invalid offset to the entry of the 'debug_ranges' section.

Diff Detail

Event Timeline

Higuoxing created this revision.Jun 7 2020, 8:53 PM
Herald added a project: Restricted Project. · View Herald Transcript
jhenderson added inline comments.Jun 8 2020, 1:04 AM
llvm/lib/ObjectYAML/DWARFEmitter.cpp
134–140

Do you need the new cast? If I've followed it correctly, Offset is a Hex64, so is already a 64-bit number.

138–139

I think this should be " must be greater than or equal to the number of bytes written already (0x"

llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml
317

invalid offset to the -> invalid offset to an

337

Let's make this 0x1A to test the edge case (i.e. no off-by-one error).

Higuoxing updated this revision to Diff 269202.Jun 8 2020, 6:44 AM
Higuoxing marked 4 inline comments as done.

Address comments.

Thanks for reviewing.

llvm/lib/ObjectYAML/DWARFEmitter.cpp
134–140

Yes, but the compiler complains that 'Use of overloaded operator '<' is ambiguous'. So we have to explicitly cast it to uint64_t.

jhenderson added inline comments.Jun 8 2020, 7:19 AM
llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml
337

Oops, sorry, I failed at hex :-)

I meant 0x1f, i.e. exactly one less than the permitted value!

Higuoxing updated this revision to Diff 269226.Jun 8 2020, 7:42 AM
Higuoxing marked 2 inline comments as done.

Update.

llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml
337

Never mind :)

jhenderson accepted this revision.Jun 9 2020, 12:46 AM

LGTM, thanks.

This revision is now accepted and ready to land.Jun 9 2020, 12:46 AM
This revision was automatically updated to reflect the committed changes.