[PATCH] D139184: [LLD][Windows]Feature "checksum" for Windows PE

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 29 00:48:24 PST 2022


mstorsjo added a comment.

In D139184#4019123 <https://reviews.llvm.org/D139184#4019123>, @Qfrost911 wrote:

> But I have some questions. Why using "ulittle32_t" rather than "ulittle16_t".

Sorry, that was a typo - it should indeed be `ulittle16_t`.

> And to be honest, I don't know how to achieve a test. It is very difficult to calc a checksum using lit tools.

It should be quite straightforward.

Have a look at some existing test, e.g. `lld/test/COFF/heap.test` seems like a good example. First the test creates an object file from a stored yaml file (the exact contents doesn't matter much here). Then you would link one output without the `/release` flag, which should not set any checksum. After this, run `llvm-readobj` and inspect that the checksum in the output file is `0x0`. (You may want to check for `0x0{{$}}` to make sure that it doesn't accidentally match a substring like `0x01234`.) Then run another link command with the `/release` flag, and check that it produces the expected checksum.

The exact value of the checksum in the test isn't that important - you don't need to verify the calculation of that separately. You've checked that the linker does the right thing in actual use - then just see what checksum value you get from the test input, and look for that as reference in the testcase. That way, we will notice if something changes (so that the checksum algorithm returns a different value than the expected one).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139184/new/

https://reviews.llvm.org/D139184



More information about the llvm-commits mailing list