This is an archive of the discontinued LLVM Phabricator instance.

[lld][COFF]llvm-readobj COFFDumper print PEHeader CheckSum
ClosedPublic

Authored by Qfrost911 on Dec 22 2022, 7:29 AM.

Details

Summary

In PEHeader, a field named "CheckSum" is not printed by llvm-readobj.

Previously, lld did not implement the PE-Checksum feature, I have implemented it in my version D139184, so I think it is necessary to output the value of this field via llvm-readobj.

And I will use it to achieve tests about this feature.

Diff Detail

Event Timeline

Qfrost911 created this revision.Dec 22 2022, 7:29 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: StephenFan. · View Herald Transcript
Qfrost911 requested review of this revision.Dec 22 2022, 7:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2022, 7:29 AM

I think you might need to update some other tests. Have you ran ninja check-all? I see at least llvm/test/tools/llvm-readobj/COFF/file-headers.test might fail because of this change, there could be others. Ideally you could use cmake with -DLLVM_ENABLE_PROJECTS="llvm;clang;lld;clang-tools-extra;mlir"to ensure you have good coverage for ninja check-all.

Qfrost911 updated this revision to Diff 484996.Dec 22 2022, 5:37 PM

Oh, right, but I see there is only an error which in file-headers.test can be raised.

aganea added inline comments.Dec 26 2022, 9:31 AM
llvm/tools/llvm-readobj/COFFDumper.cpp
740

I would call W.printHex(...) here instead.

Qfrost911 updated this revision to Diff 485335.Dec 26 2022, 7:24 PM

Thanks, I think it's a good idea.

thieta added inline comments.Dec 29 2022, 2:25 AM
lld/test/COFF/hello32.test
45

Why is this line empty here and 0x0 below? Does this mean that the header isn't there?

I think I like it to either NOT be included if the header is missing or just 0x0 so it's a bit consistent in the output. Can't see any other field just being a empty line.

mstorsjo added inline comments.
lld/test/COFF/hello32.test
45

Leaving out the value can be a common practice for tests, when you want to span all lines with <CHECK>-NEXT lines, but you don't want to literally check all the contents of those lines - i.e. any checksum value (zero or nonzero) would be fine.

But for the purposes of this particular test, I guess the value should always be zero so spelling out the CheckSum: 0x0 probably is fine too.

Qfrost911 updated this revision to Diff 485597.Dec 29 2022, 2:37 AM

Oh, previously I leave blank because I would add other checksum test sets.

aganea accepted this revision.Dec 29 2022, 7:16 AM

LGTM.

Do you have commit access? If yes, please wait a few days before commiting, in case other reviewers have anything to add. If you don’t have commit access, I could commit it for you, please provide the git author information.

This revision is now accepted and ready to land.Dec 29 2022, 7:16 AM

LGTM.

Do you have commit access? If yes, please wait a few days before commiting, in case other reviewers have anything to add. If you don’t have commit access, I could commit it for you, please provide the git author information.

Thanks. I have commit access. I wait a few days.

This revision was landed with ongoing or failed builds.Dec 30 2022, 7:49 PM
This revision was automatically updated to reflect the committed changes.