Add elf split; rework asm generation

`elf split` allows splitting an ELF
directly into relocatable object files
This commit is contained in:
2022-12-24 03:10:12 -05:00
parent 54f2abd35f
commit 9f4cc2f542
8 changed files with 909 additions and 625 deletions

View File

@@ -7,7 +7,7 @@ use std::{
use anyhow::{Context, Error, Result};
use argh::FromArgs;
use object::{Object, ObjectSymbol};
use object::{Object, ObjectSymbol, SymbolScope};
#[derive(FromArgs, PartialEq, Debug)]
/// Commands for processing static libraries.
@@ -52,7 +52,7 @@ fn create(args: CreateArgs) -> Result<()> {
Some(rsp_file) => {
let reader = BufReader::new(
File::open(rsp_file)
.with_context(|| format!("Failed to open file '{}'", rsp_file))?,
.with_context(|| format!("Failed to open file '{rsp_file}'"))?,
);
for result in reader.lines() {
let line = result?;
@@ -92,7 +92,7 @@ fn create(args: CreateArgs) -> Result<()> {
.with_context(|| format!("Failed to mmap object file: '{}'", path.to_string_lossy()))?;
let obj = object::File::parse(map.as_ref())?;
for symbol in obj.symbols() {
if symbol.is_global() {
if symbol.scope() == SymbolScope::Dynamic {
entries.push(symbol.name_bytes()?.to_vec());
}
}