Fix REL v2 creation (and v1, hopefully)

- Adjusts `write_rel` to use the proper ordering for relocations and imports based on the REL version.
- Adds `-r`/`--relocations` switch to `rel info` that prints (very) verbose relocation information.
This commit is contained in:
2023-11-09 01:16:37 -05:00
parent 456f4eebd4
commit 4935708b61
2 changed files with 170 additions and 59 deletions

View File

@@ -36,8 +36,8 @@ use crate::{
file::{buf_reader, buf_writer, map_file, process_rsp, verify_hash, FileIterator},
nested::NestedMap,
rel::{
process_rel, process_rel_header, process_rel_sections, write_rel, RelHeader, RelReloc,
RelSectionHeader, RelWriteInfo, PERMITTED_SECTIONS,
print_relocations, process_rel, process_rel_header, process_rel_sections, write_rel,
RelHeader, RelReloc, RelSectionHeader, RelWriteInfo, PERMITTED_SECTIONS,
},
IntoCow, ToCow,
},
@@ -66,6 +66,9 @@ pub struct InfoArgs {
#[argp(positional)]
/// REL file
rel_file: PathBuf,
#[argp(switch, short = 'r')]
/// print relocations
relocations: bool,
}
#[derive(FromArgs, PartialEq, Eq, Debug)]
@@ -408,6 +411,12 @@ fn info(args: InfoArgs) -> Result<()> {
section_str, symbol.address, size_str, symbol.name
);
}
if args.relocations {
println!("\nRelocations:");
println!(" [Source] section:address RelocType -> [Target] module:section:address");
print_relocations(&mut file.as_reader(), &header)?;
}
Ok(())
}