-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Section offsets are 1-indexed #124
Comments
The most straight-forward refactor here would be to make the Would someone have preferences on the API here? To sum it up: // Option 1:
pub struct PdbInternalSectionOffset {
pub offset: u32,
pub section: Option<usize>,
}
pub struct LabelSymbol<'t> {
pub offset: PdbInternalSectionOffset,
pub flags: ProcedureFlags,
pub name: RawString<'t>,
}
// Option 2:
pub struct PdbInternalSectionOffset {
pub offset: u32,
pub section: usize,
}
pub struct LabelSymbol<'t> {
pub offset: Option<PdbInternalSectionOffset>,
pub flags: ProcedureFlags,
pub name: RawString<'t>,
} |
A third option would be… How about there wouldn’t be any kind of validation/transformation when reading these (internal)offsets from the file, but rather at the time you try to dereference them? What does it mean if a |
That's the status quo. It can be error-prone at times, because from a Point granted, our structs would be diverging from the physical representation with such a change -- this makes me lean towards Option 1, still. It's a good compromise between a safe interface and staying truthful to the PDB format.
The latter, it means the reference points into the void and should not be dereferenced, from what I can see. The PDB code always subtracts 1 to go (in their language) from an Ximod to an imod. Then, they have |
Neither option is particularly compelling, but I don't have a better suggestion either. I like/dislike both options about equally. I checked the pdb-addr2line code to see if either option would lead to simpler code, but I think it wouldn't make much of a difference. For example, first I thought that |
#93 improved module references by using optional 0-based
usize
indexes instead of requiring to subtract 1 to resolve modules. In #93 (comment), @mstange points out that same is true forPdbInternalSectionOffset::section
:The most common usage for section offsets so far was to convert them to RVAs via an OMAP. Internally, this ran the checked sub (going back to #87):
https://github.com/willglynn/pdb/blob/e1b86a2c5c8e2c20dc0be9909baecaf1fdf0aa8a/src/omap.rs#L440-L441
However, since there are other direct uses of the section offset, it would be safer to make
section: Option<usize>
as well.The text was updated successfully, but these errors were encountered: