mirror of
https://github.com/encounter/objdiff.git
synced 2025-07-03 11:45:57 +00:00
Merge remote-tracking branch 'origin/main' into arm
This commit is contained in:
commit
e9b8730b66
@ -16,7 +16,7 @@ Features:
|
|||||||
Supports:
|
Supports:
|
||||||
- PowerPC 750CL (GameCube & Wii)
|
- PowerPC 750CL (GameCube & Wii)
|
||||||
- MIPS (Nintendo 64 & PS2)
|
- MIPS (Nintendo 64 & PS2)
|
||||||
- x86 (PE only at the moment)
|
- x86 (COFF only at the moment)
|
||||||
|
|
||||||
See [Usage](#usage) for more information.
|
See [Usage](#usage) for more information.
|
||||||
|
|
||||||
@ -59,6 +59,10 @@ file as well. You can then add `objdiff.json` to your `.gitignore` to prevent it
|
|||||||
// objdiff.json
|
// objdiff.json
|
||||||
{
|
{
|
||||||
"custom_make": "ninja",
|
"custom_make": "ninja",
|
||||||
|
"custom_args": [
|
||||||
|
"-d",
|
||||||
|
"keeprsp"
|
||||||
|
],
|
||||||
|
|
||||||
// Only required if objects use "path" instead of "target_path" and "base_path".
|
// Only required if objects use "path" instead of "target_path" and "base_path".
|
||||||
"target_dir": "build/asm",
|
"target_dir": "build/asm",
|
||||||
@ -93,6 +97,9 @@ file as well. You can then add `objdiff.json` to your `.gitignore` to prevent it
|
|||||||
|
|
||||||
`custom_make` _(optional)_: By default, objdiff will use `make` to build the project.
|
`custom_make` _(optional)_: By default, objdiff will use `make` to build the project.
|
||||||
If the project uses a different build system (e.g. `ninja`), specify it here.
|
If the project uses a different build system (e.g. `ninja`), specify it here.
|
||||||
|
The build command will be `[custom_make] [custom_args] path/to/object.o`.
|
||||||
|
|
||||||
|
`custom_args` _(optional)_: Additional arguments to pass to the build command prior to the object path.
|
||||||
|
|
||||||
`target_dir` _(optional)_: Relative from the root of the project, this where the "target" or "expected" objects are located.
|
`target_dir` _(optional)_: Relative from the root of the project, this where the "target" or "expected" objects are located.
|
||||||
These are the **intended result** of the match.
|
These are the **intended result** of the match.
|
||||||
|
@ -18,6 +18,8 @@ pub struct ProjectConfig {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub custom_make: Option<String>,
|
pub custom_make: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
pub custom_args: Option<Vec<String>>,
|
||||||
|
#[serde(default)]
|
||||||
pub target_dir: Option<PathBuf>,
|
pub target_dir: Option<PathBuf>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub base_dir: Option<PathBuf>,
|
pub base_dir: Option<PathBuf>,
|
||||||
|
@ -87,12 +87,12 @@ impl SplitMeta {
|
|||||||
if let Some(generator) = &self.generator {
|
if let Some(generator) = &self.generator {
|
||||||
write_note_header(writer, e, NT_SPLIT_GENERATOR, generator.len())?;
|
write_note_header(writer, e, NT_SPLIT_GENERATOR, generator.len())?;
|
||||||
writer.write_all(generator.as_bytes())?;
|
writer.write_all(generator.as_bytes())?;
|
||||||
align_to_4(writer, generator.len())?;
|
align_data_to_4(writer, generator.len())?;
|
||||||
}
|
}
|
||||||
if let Some(module_name) = &self.module_name {
|
if let Some(module_name) = &self.module_name {
|
||||||
write_note_header(writer, e, NT_SPLIT_MODULE_NAME, module_name.len())?;
|
write_note_header(writer, e, NT_SPLIT_MODULE_NAME, module_name.len())?;
|
||||||
writer.write_all(module_name.as_bytes())?;
|
writer.write_all(module_name.as_bytes())?;
|
||||||
align_to_4(writer, module_name.len())?;
|
align_data_to_4(writer, module_name.len())?;
|
||||||
}
|
}
|
||||||
if let Some(module_id) = self.module_id {
|
if let Some(module_id) = self.module_id {
|
||||||
write_note_header(writer, e, NT_SPLIT_MODULE_ID, 4)?;
|
write_note_header(writer, e, NT_SPLIT_MODULE_ID, 4)?;
|
||||||
@ -119,15 +119,19 @@ impl SplitMeta {
|
|||||||
let mut size = 0;
|
let mut size = 0;
|
||||||
if let Some(generator) = self.generator.as_deref() {
|
if let Some(generator) = self.generator.as_deref() {
|
||||||
size += NOTE_HEADER_SIZE + generator.len();
|
size += NOTE_HEADER_SIZE + generator.len();
|
||||||
|
size = align_size_to_4(size);
|
||||||
}
|
}
|
||||||
if let Some(module_name) = self.module_name.as_deref() {
|
if let Some(module_name) = self.module_name.as_deref() {
|
||||||
size += NOTE_HEADER_SIZE + module_name.len();
|
size += NOTE_HEADER_SIZE + module_name.len();
|
||||||
|
size = align_size_to_4(size);
|
||||||
}
|
}
|
||||||
if self.module_id.is_some() {
|
if self.module_id.is_some() {
|
||||||
size += NOTE_HEADER_SIZE + 4;
|
size += NOTE_HEADER_SIZE + 4;
|
||||||
|
size = align_size_to_4(size);
|
||||||
}
|
}
|
||||||
if let Some(virtual_addresses) = self.virtual_addresses.as_deref() {
|
if let Some(virtual_addresses) = self.virtual_addresses.as_deref() {
|
||||||
size += NOTE_HEADER_SIZE + if is_64 { 8 } else { 4 } * virtual_addresses.len();
|
size += NOTE_HEADER_SIZE + if is_64 { 8 } else { 4 } * virtual_addresses.len();
|
||||||
|
size = align_size_to_4(size);
|
||||||
}
|
}
|
||||||
size
|
size
|
||||||
}
|
}
|
||||||
@ -186,7 +190,9 @@ where E: Endian
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn align_to_4<W: Write + ?Sized>(writer: &mut W, len: usize) -> io::Result<()> {
|
fn align_size_to_4(size: usize) -> usize { (size + 3) & !3 }
|
||||||
|
|
||||||
|
fn align_data_to_4<W: Write + ?Sized>(writer: &mut W, len: usize) -> io::Result<()> {
|
||||||
const ALIGN_BYTES: &[u8] = &[0; 4];
|
const ALIGN_BYTES: &[u8] = &[0; 4];
|
||||||
if len % 4 != 0 {
|
if len % 4 != 0 {
|
||||||
writer.write_all(&ALIGN_BYTES[..4 - len % 4])?;
|
writer.write_all(&ALIGN_BYTES[..4 - len % 4])?;
|
||||||
@ -212,6 +218,6 @@ where
|
|||||||
writer.write_all(&e.write_u32_bytes(kind))?; // Type
|
writer.write_all(&e.write_u32_bytes(kind))?; // Type
|
||||||
writer.write_all(ELF_NOTE_SPLIT)?; // Name
|
writer.write_all(ELF_NOTE_SPLIT)?; // Name
|
||||||
writer.write_all(&[0; 1])?; // Null terminator
|
writer.write_all(&[0; 1])?; // Null terminator
|
||||||
align_to_4(writer, ELF_NOTE_SPLIT.len() + 1)?;
|
align_data_to_4(writer, ELF_NOTE_SPLIT.len() + 1)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,8 @@ pub struct AppConfig {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub custom_make: Option<String>,
|
pub custom_make: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
pub custom_args: Option<Vec<String>>,
|
||||||
|
#[serde(default)]
|
||||||
pub selected_wsl_distro: Option<String>,
|
pub selected_wsl_distro: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub project_dir: Option<PathBuf>,
|
pub project_dir: Option<PathBuf>,
|
||||||
@ -131,6 +133,7 @@ impl Default for AppConfig {
|
|||||||
Self {
|
Self {
|
||||||
version: AppConfigVersion::default().version,
|
version: AppConfigVersion::default().version,
|
||||||
custom_make: None,
|
custom_make: None,
|
||||||
|
custom_args: None,
|
||||||
selected_wsl_distro: None,
|
selected_wsl_distro: None,
|
||||||
project_dir: None,
|
project_dir: None,
|
||||||
target_obj_dir: None,
|
target_obj_dir: None,
|
||||||
|
@ -71,6 +71,7 @@ pub fn load_project_config(config: &mut AppConfig) -> Result<()> {
|
|||||||
if let Some((result, info)) = try_project_config(project_dir) {
|
if let Some((result, info)) = try_project_config(project_dir) {
|
||||||
let project_config = result?;
|
let project_config = result?;
|
||||||
config.custom_make = project_config.custom_make;
|
config.custom_make = project_config.custom_make;
|
||||||
|
config.custom_args = project_config.custom_args;
|
||||||
config.target_obj_dir = project_config.target_dir.map(|p| project_dir.join(p));
|
config.target_obj_dir = project_config.target_dir.map(|p| project_dir.join(p));
|
||||||
config.base_obj_dir = project_config.base_dir.map(|p| project_dir.join(p));
|
config.base_obj_dir = project_config.base_dir.map(|p| project_dir.join(p));
|
||||||
config.build_base = project_config.build_base;
|
config.build_base = project_config.build_base;
|
||||||
|
@ -39,6 +39,7 @@ impl Default for BuildStatus {
|
|||||||
pub struct BuildConfig {
|
pub struct BuildConfig {
|
||||||
pub project_dir: Option<PathBuf>,
|
pub project_dir: Option<PathBuf>,
|
||||||
pub custom_make: Option<String>,
|
pub custom_make: Option<String>,
|
||||||
|
pub custom_args: Option<Vec<String>>,
|
||||||
pub selected_wsl_distro: Option<String>,
|
pub selected_wsl_distro: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ impl BuildConfig {
|
|||||||
Self {
|
Self {
|
||||||
project_dir: config.project_dir.clone(),
|
project_dir: config.project_dir.clone(),
|
||||||
custom_make: config.custom_make.clone(),
|
custom_make: config.custom_make.clone(),
|
||||||
|
custom_args: config.custom_args.clone(),
|
||||||
selected_wsl_distro: config.selected_wsl_distro.clone(),
|
selected_wsl_distro: config.selected_wsl_distro.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,10 +98,11 @@ pub(crate) fn run_make(config: &BuildConfig, arg: &Path) -> BuildStatus {
|
|||||||
|
|
||||||
fn run_make_cmd(config: &BuildConfig, cwd: &Path, arg: &Path) -> Result<BuildStatus> {
|
fn run_make_cmd(config: &BuildConfig, cwd: &Path, arg: &Path) -> Result<BuildStatus> {
|
||||||
let make = config.custom_make.as_deref().unwrap_or("make");
|
let make = config.custom_make.as_deref().unwrap_or("make");
|
||||||
|
let make_args = config.custom_args.as_deref().unwrap_or(&[]);
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
let mut command = {
|
let mut command = {
|
||||||
let mut command = Command::new(make);
|
let mut command = Command::new(make);
|
||||||
command.current_dir(cwd).arg(arg);
|
command.current_dir(cwd).args(make_args).arg(arg);
|
||||||
command
|
command
|
||||||
};
|
};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -113,6 +116,13 @@ fn run_make_cmd(config: &BuildConfig, cwd: &Path, arg: &Path) -> Result<BuildSta
|
|||||||
Command::new(make)
|
Command::new(make)
|
||||||
};
|
};
|
||||||
if let Some(distro) = &config.selected_wsl_distro {
|
if let Some(distro) = &config.selected_wsl_distro {
|
||||||
|
// Strip distro root prefix \\wsl.localhost\{distro}
|
||||||
|
let wsl_path_prefix = format!("\\\\wsl.localhost\\{}", distro);
|
||||||
|
let cwd = match cwd.strip_prefix(wsl_path_prefix) {
|
||||||
|
Ok(new_cwd) => format!("/{}", new_cwd.to_slash_lossy().as_ref()),
|
||||||
|
Err(_) => cwd.to_string_lossy().to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
command
|
command
|
||||||
.arg("--cd")
|
.arg("--cd")
|
||||||
.arg(cwd)
|
.arg(cwd)
|
||||||
@ -120,9 +130,10 @@ fn run_make_cmd(config: &BuildConfig, cwd: &Path, arg: &Path) -> Result<BuildSta
|
|||||||
.arg(distro)
|
.arg(distro)
|
||||||
.arg("--")
|
.arg("--")
|
||||||
.arg(make)
|
.arg(make)
|
||||||
|
.args(make_args)
|
||||||
.arg(arg.to_slash_lossy().as_ref());
|
.arg(arg.to_slash_lossy().as_ref());
|
||||||
} else {
|
} else {
|
||||||
command.current_dir(cwd).arg(arg.to_slash_lossy().as_ref());
|
command.current_dir(cwd).args(make_args).arg(arg.to_slash_lossy().as_ref());
|
||||||
}
|
}
|
||||||
command.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW);
|
command.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW);
|
||||||
command
|
command
|
||||||
|
Loading…
x
Reference in New Issue
Block a user