mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
custom logic around finding 'forward' exports
This commit is contained in:
parent
0da6484618
commit
92514a1499
1 changed files with 43 additions and 1 deletions
|
@ -48,6 +48,24 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn check_exports_coff() {
|
||||
// NOTE: this does not work
|
||||
//
|
||||
// let target = target_lexicon::Triple {
|
||||
// architecture: target_lexicon::Architecture::X86_64,
|
||||
// operating_system: target_lexicon::OperatingSystem::Windows,
|
||||
// binary_format: target_lexicon::BinaryFormat::Coff,
|
||||
// ..target_lexicon::Triple::host()
|
||||
// };
|
||||
//
|
||||
// check_exports(&target);
|
||||
//
|
||||
// Because our exports point back into the .edata section, they are considered "forward"
|
||||
// exports: they aren't actually defined in this .dll and hence not considered exports by
|
||||
// the `object` crate.
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_exports_coff_manual() {
|
||||
let target = target_lexicon::Triple {
|
||||
architecture: target_lexicon::Architecture::X86_64,
|
||||
operating_system: target_lexicon::OperatingSystem::Windows,
|
||||
|
@ -55,6 +73,30 @@ mod tests {
|
|||
..target_lexicon::Triple::host()
|
||||
};
|
||||
|
||||
check_exports(&target);
|
||||
let custom_names = ["foo".to_string(), "bar".to_string()];
|
||||
|
||||
let bytes = generate(&target, &custom_names).unwrap();
|
||||
let object = object::read::pe::PeFile64::parse(bytes.as_slice()).unwrap();
|
||||
|
||||
let exports = {
|
||||
let mut exports = Vec::new();
|
||||
if let Some(export_table) = object.export_table().unwrap() {
|
||||
for (name_pointer, _address_index) in export_table.name_iter() {
|
||||
let name = export_table.name_from_pointer(name_pointer).unwrap();
|
||||
|
||||
// here the standard `.exports()` checks for `if !export_table.is_forward(address)`
|
||||
exports.push(name)
|
||||
}
|
||||
}
|
||||
exports
|
||||
};
|
||||
|
||||
for custom in custom_names {
|
||||
assert!(
|
||||
exports.iter().any(|name| *name == custom.as_bytes()),
|
||||
"missing {}",
|
||||
&custom
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue