Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/cmd/coff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2156,12 +2156,36 @@ fn split_write_coff(
}
_ => None,
};
let imports = match (&pe.imports, module.config.generate_imports) {
(Some(imports), true) => {
use crate::util::pe_imports::{slot_symbols, write_import_library, write_import_order};
let symbols = slot_symbols(&module.obj, imports)
.with_context(|| format!("{}: generate_imports", module.config.name()))?;
let library_path = out_dir_path.join("imports.lib");
write_if_changed(&library_path.to_native(), &write_import_library(imports, &symbols))?;
let order_path = out_dir_path.join("imports.order");
let iat_section_end = module
.obj
.sections
.iter()
.flat_map(|(_, s)| &s.sub_regions)
.find(|r| r.name == ".idata$5")
.map(|r| r.end);
let order = write_import_order(imports, &symbols, iat_section_end)
.with_context(|| format!("{}: generate_imports", module.config.name()))?;
write_if_changed(&order_path.to_native(), order.as_bytes())?;
Some((library_path.to_string(), order_path.to_string()))
}
(None, true) => bail!("{}: generate_imports needs an import table", module.config.name()),
_ => None,
};
let args_string = generate_args_rsp(
&module.obj,
pe,
&force_includes,
config.dead_strip,
exports_def.as_deref(),
imports.as_ref().map(|(l, o)| (l.as_str(), o.as_str())),
)?;
let args_path = out_config.ldscript.to_native();
write_if_changed(&args_path, args_string.as_bytes())?;
Expand Down
6 changes: 6 additions & 0 deletions src/cmd/dol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ pub struct ModuleConfig {
/// timestamp. The splits must leave the original table out of every unit.
#[serde(default, skip_serializing_if = "is_default")]
pub generate_exports: bool,
/// Have the linker generate the import directory (PE) from an import
/// library and layout order read back from the original, built with a
/// vc6-aware lld-link (`/vc6imports:`). The splits must leave the original
/// tables (`.idata$N`) out of every unit.
#[serde(default, skip_serializing_if = "is_default")]
pub generate_imports: bool,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub skip_cfa_ranges: Vec<SkipCfaRangeConfig>,
/// Prebuilt library objects linked verbatim for some of this module's units.
Expand Down
1 change: 1 addition & 0 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod ncompress;
pub mod nested;
pub mod nlzss;
pub mod path;
pub mod pe_imports;
pub mod rarc;
pub mod read;
pub mod reader;
Expand Down
Loading
Loading