This is an archive of the discontinued LLVM Phabricator instance.

[Object][COFF] Improve section name parsing
ClosedPublic

Authored by pzheng on Jun 15 2022, 12:57 PM.

Details

Summary

Inspired by discussions on D127369, we probably can further improve LLVM's COFF
section name parsing. Hopefully, this makes the logic simpler and handles some
edge cases more elegantly.

Diff Detail

Event Timeline

pzheng created this revision.Jun 15 2022, 12:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2022, 12:57 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
pzheng requested review of this revision.Jun 15 2022, 12:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2022, 12:57 PM
rnk added a comment.Jun 15 2022, 1:50 PM

Thanks, this is a good idea.

llvm/lib/Object/COFFObjectFile.cpp
1159

This can now be getAsInteger, right?

pzheng added inline comments.Jun 15 2022, 2:39 PM
llvm/lib/Object/COFFObjectFile.cpp
1159

Compared to getAsInteger, consumeInteger is a little more error tolerant and can handle inputs like "/4abcdef". However, I haven't actually seen any input like that in the wild yet, so it's probably fine if we use getAsInteger. Thoughts?

rnk accepted this revision.Jun 16 2022, 2:28 PM

lgtm

llvm/lib/Object/COFFObjectFile.cpp
1159

I think it would be reasonable to report an error for such a section name, so I support that change, but either way, the split code is simpler than what we currently have.

This revision is now accepted and ready to land.Jun 16 2022, 2:28 PM
pzheng added inline comments.Jun 16 2022, 2:51 PM
llvm/lib/Object/COFFObjectFile.cpp
1159

Agreed, will change to getAsInteger.

pzheng updated this revision to Diff 437719.Jun 16 2022, 2:55 PM

Use getAsInteger

This revision was landed with ongoing or failed builds.Jun 16 2022, 5:01 PM
This revision was automatically updated to reflect the committed changes.