Skip to content
/ cecil Public
forked from jbevain/cecil
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix corrupted debug header directory entry when writing multiple such entries #35

Merged
merged 1 commit into from
Jul 19, 2022

Conversation

vitek-karas
Copy link
Member

Basically the first two entries are written correctly, and any after that which has data will have the RVA correct, but the virtual address field will be wrong. Depending on the consumer this can work (if they use RVA) or fail (if they use virtual address) as they would read garbage data.

Currently this mostly affects embedded protable PDBs since in that case we write 4 headers: CodeView, PdbChecksum, EmbeddedPdb and Deterministic (in this order), so the embedded PDB data is effectively wrong.

Also adds a test which validates that both the RVA and virtual address point to the same thing.

This is a port of jbevain#869.

… entries.

Basically the first two entries are written correctly, and any after that which has data will have the RVA correct, but the virtual address field will be wrong. Depending on the consumer this can work (if they use RVA) or fail (if they use virtual address) as they would read garbage data.

Currently this mostly affects embedded protable PDBs since in that case we write 4 headers: CodeView, PdbChecksum, EmbeddedPdb and Deterministic (in this order), so the embedded PDB data is effectively wrong.

Also adds a test which validates that both the RVA and virtual address point to the same thing.
@vitek-karas
Copy link
Member Author

@agocke @marek-safar @sbomer - could you please take a look?

@@ -719,7 +719,7 @@ void BuildTextMap ()
entry.Directory = directory;

data_len += entry.Data.Length;
data_address += data_len;
data_address += entry.Data.Length;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is more index than address, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really - it's more like an offset - but the field this is used for is called AddressOfRawData, so it makes sense to call it address.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also RVA - which is "Address" as well.

@marek-safar marek-safar merged commit 2cd569a into dotnet:main Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants