Reformat for rustfmt's 2024 style edition

This commit is contained in:
Rui Ueyama committed 2026-09-18 16:58:21 +09:00
1 parent 1efb465bfa
commit 61c0854ddc
50 files changed
+154 -229

No files matched your search

+4 -8
View File
@@ -55,11 +55,11 @@ use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{
check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc, InputSection, InputSectionId,
InputSection, InputSectionId, check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc,
};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::thunks::Thunk;
use crate::util::endian::{write_ul32, BigEndian, Endian, LittleEndian, Ub32, Ul32};
use crate::util::endian::{BigEndian, Endian, LittleEndian, Ub32, Ul32, write_ul32};
use crate::util::{align_to, bit, bits, is_int, sign_extend};
use crate::{error, fatal};
@@ -316,11 +316,7 @@ where
}
fn eflags(_ctx: &Context<Self>) -> u32 {
if End::IS_LITTLE {
EF_ARM_EABI_VER5
} else {
EF_ARM_EABI_VER5 | EF_ARM_BE8
}
if End::IS_LITTLE { EF_ARM_EABI_VER5 } else { EF_ARM_EABI_VER5 | EF_ARM_BE8 }
}
fn write_plt_header(ctx: &Context<Self>, buf: &mut [u8]) {
+2 -2
View File
@@ -27,8 +27,8 @@ use crate::chunks::eh_frame;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::input_sections::{InputSection, check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::thunks::Thunk;
use crate::util::endian::{BigEndian, Endian, LittleEndian, Ub64, Ul64};
use crate::util::{bits, is_int};
+2 -2
View File
@@ -41,8 +41,8 @@ use crate::chunks::eh_frame;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::input_sections::{InputSection, check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::util::endian::{LittleEndian, Ul32};
use crate::{error, fatal};
+4 -8
View File
@@ -31,12 +31,12 @@ use crate::elf::*;
use crate::input_files::FileId;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{
check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc, InputSection, RelocDelta,
InputSection, RelocDelta, check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc,
};
use crate::shrink_sections::compute_distance;
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::util::endian::{
read_ul16, read_ul32, read_ul64, write_ul16, write_ul32, write_ul64, LittleEndian, Ul32, Ul64,
LittleEndian, Ul32, Ul64, read_ul16, read_ul32, read_ul64, write_ul16, write_ul32, write_ul64,
};
use crate::util::{align_to, bits, is_int, overwrite_uleb, read_uleb, sign_extend};
use crate::{error, fatal};
@@ -189,11 +189,7 @@ fn write_pcaddi(loc: &mut [u8], val: u64) {
/// relocation families that debug info and tables are built from.
fn add_bits(loc: &mut [u8], size: u32, val: u64, subtract: bool) {
let apply = |cur: u64| {
if subtract {
cur.wrapping_sub(val)
} else {
cur.wrapping_add(val)
}
if subtract { cur.wrapping_sub(val) } else { cur.wrapping_add(val) }
};
match size {
6 => loc[0] = (loc[0] & 0b1100_0000) | (apply(loc[0] as u64) as u8 & 0b0011_1111),
+3 -3
View File
@@ -21,9 +21,9 @@ use crate::chunks::eh_frame;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, scan_absrel, scan_pcrel, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::util::endian::{write_ub16, write_ub32, BigEndian, Ub32};
use crate::input_sections::{InputSection, check_tlsle, scan_absrel, scan_pcrel};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::util::endian::{BigEndian, Ub32, write_ub16, write_ub32};
use crate::{error, fatal};
#[derive(Clone, Copy, Debug, Default)]
+3 -3
View File
@@ -47,10 +47,10 @@ use crate::chunks::eh_frame;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, scan_absrel, scan_pcrel, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::input_sections::{InputSection, check_tlsle, scan_absrel, scan_pcrel};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::thunks::Thunk;
use crate::util::endian::{read_ub32, write_ub16, write_ub32, BigEndian, Ub32};
use crate::util::endian::{BigEndian, Ub32, read_ub32, write_ub16, write_ub32};
use crate::util::{bits, is_int};
use crate::{error, fatal};
+3 -3
View File
@@ -56,13 +56,13 @@ use crate::context::Context;
use crate::elf::*;
use crate::input_files::{FileId, SymbolEditor};
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, InputSection, SectionRef};
use crate::input_sections::{InputSection, SectionRef, check_tlsle};
use crate::symbol::{
AddrFlags, Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_PPC_OPD, NEEDS_TLSGD,
AddrFlags, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_PPC_OPD, NEEDS_TLSGD, Symbol,
};
use crate::thunks::Thunk;
use crate::util::endian::{
read_ub16, read_ub32, write_ub16, write_ub32, write_ub64, BigEndian, Ub64,
BigEndian, Ub64, read_ub16, read_ub32, write_ub16, write_ub32, write_ub64,
};
use crate::util::{bits, is_int};
use crate::{error, fatal};
+3 -3
View File
@@ -90,11 +90,11 @@ use crate::chunks::eh_frame;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::input_sections::{InputSection, check_tlsle};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::thunks::Thunk;
use crate::util::endian::{
read_ul16, read_ul32, write_ul16, write_ul32, write_ul64, LittleEndian, Ul64,
LittleEndian, Ul64, read_ul16, read_ul32, write_ul16, write_ul32, write_ul64,
};
use crate::util::{bits, is_int};
use crate::{error, fatal};
+5 -3
View File
@@ -29,10 +29,10 @@ use crate::elf::*;
use crate::input_files::FileId;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{
check_tlsle, r_delta, scan_absrel, scan_pcrel, scan_tlsdesc, InputSection, RelocDelta,
InputSection, RelocDelta, check_tlsle, r_delta, scan_absrel, scan_pcrel, scan_tlsdesc,
};
use crate::shrink_sections::compute_distance;
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::util::endian::{BigEndian, Endian, LittleEndian, Ub32, Ub64, Ul32, Ul64};
use crate::util::{align_to, bit, bits, encode_uleb, is_int, overwrite_uleb, read_uleb};
use crate::{error, fatal};
@@ -322,7 +322,9 @@ where
ret |= EF_RISCV_RVC;
}
if flags & EF_RISCV_FLOAT_ABI != ret & EF_RISCV_FLOAT_ABI {
error!("{file}: cannot link object files with different floating-point ABI from {first}");
error!(
"{file}: cannot link object files with different floating-point ABI from {first}"
);
}
if flags & EF_RISCV_RVE != ret & EF_RISCV_RVE {
error!("{file}: cannot link object files with different EF_RISCV_RVE from {first}");
+3 -3
View File
@@ -40,10 +40,10 @@ use crate::chunks::eh_frame;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, scan_absrel, scan_pcrel, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::input_sections::{InputSection, check_tlsle, scan_absrel, scan_pcrel};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::util::endian::{
read_ub16, read_ub32, write_ub16, write_ub32, write_ub64, BigEndian, Ub64,
BigEndian, Ub64, read_ub16, read_ub32, write_ub16, write_ub32, write_ub64,
};
use crate::util::{bits, is_int};
use crate::{error, fatal};
+3 -7
View File
@@ -67,8 +67,8 @@ use crate::chunks::eh_frame;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, scan_pcrel, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::input_sections::{InputSection, check_tlsle, scan_pcrel};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::util::endian::{BigEndian, Endian, LittleEndian, Ub32, Ul32};
use crate::{error, fatal};
@@ -160,11 +160,7 @@ where
}
fn get_addend(loc: &[u8], rel: &Self::Rel) -> i64 {
if addend_in_place(rel.r_type()) {
End::read_u32(loc) as i32 as i64
} else {
0
}
if addend_in_place(rel.r_type()) { End::read_u32(loc) as i32 as i64 } else { 0 }
}
fn write_addend(loc: &mut [u8], val: i64, rel: &Self::Rel) {
+3 -3
View File
@@ -64,10 +64,10 @@ use crate::chunks::plt::SPARC_NUM_SMALL_PLT;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, scan_absrel, scan_pcrel, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::input_sections::{InputSection, check_tlsle, scan_absrel, scan_pcrel};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::util::endian::{
read_ub16, read_ub32, write_ub16, write_ub32, write_ub64, BigEndian, Ub64,
BigEndian, Ub64, read_ub16, read_ub32, write_ub16, write_ub32, write_ub64,
};
use crate::util::{bit, bits};
use crate::{error, fatal};
+2 -2
View File
@@ -30,8 +30,8 @@ use crate::chunks::eh_frame;
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::NonAllocReloc;
use crate::input_sections::{check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc, InputSection};
use crate::symbol::{Symbol, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD};
use crate::input_sections::{InputSection, check_tlsle, scan_absrel, scan_pcrel, scan_tlsdesc};
use crate::symbol::{NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSGD, Symbol};
use crate::util::endian::{LittleEndian, Ul64};
use crate::util::is_int;
use crate::{error, fatal};
+1 -5
View File
@@ -160,11 +160,7 @@ pub fn get_thin_archive_member_paths(mf: &'static MappedFile) -> impl Iterator<I
}
fn member_path(mf: &MappedFile, name: PathBuf) -> PathBuf {
if name.is_absolute() {
name
} else {
mf.name.parent().unwrap_or(Path::new(".")).join(name)
}
if name.is_absolute() { name } else { mf.name.parent().unwrap_or(Path::new(".")).join(name) }
}
/// Opens members as they are consumed. Parallel readers can instead schedule
+1 -1
View File
@@ -15,7 +15,7 @@
use rayon::prelude::*;
use crate::arch::Arch;
use crate::chunks::{output_section, ChunkHeader, ChunkId, OutputSectionId};
use crate::chunks::{ChunkHeader, ChunkId, OutputSectionId, output_section};
use crate::context::Context;
use crate::elf::*;
use crate::util::endian::Endian;
+4 -2
View File
@@ -40,12 +40,14 @@ pub fn add_symbol<E: Arch>(ctx: &mut Context<E>, relro: bool, id: SymbolId) {
};
let dso = &ctx.dsos[dso_id.index()];
if sym.esym(ctx).st_visibility() == STV_PROTECTED {
error!("{dso}: cannot create a copy relocation for protected symbol '{sym}'; recompile with -fPIC"
error!(
"{dso}: cannot create a copy relocation for protected symbol '{sym}'; recompile with -fPIC"
);
return;
}
if !ctx.args.z_copyreloc {
error!("-z nocopyreloc: {dso}: cannot create a copy relocation for symbol '{sym}'; recompile with -fPIC"
error!(
"-z nocopyreloc: {dso}: cannot create a copy relocation for symbol '{sym}'; recompile with -fPIC"
);
return;
}
+3 -2
View File
@@ -5,8 +5,8 @@ use std::sync::atomic::{AtomicBool, Ordering};
use rayon::prelude::*;
use crate::arch::Arch;
use crate::chunks::symtab::to_output_esym;
use crate::chunks::ChunkHeader;
use crate::chunks::symtab::to_output_esym;
use crate::context::Context;
use crate::elf::*;
use crate::error;
@@ -84,7 +84,8 @@ pub fn copy_buf<E: Arch>(ctx: &Context<E>, buf: &mut [u8]) {
if overflow.load(Ordering::Relaxed) {
let nshdrs =
ctx.shdr.as_ref().map_or(0, |s| s.shdr.sh_size.get() / ElfShdr::<E>::size() as u64);
error!("{}: .dynsym: too many output sections: {nshdrs} requested, but ELF allows at most 65279",
error!(
"{}: .dynsym: too many output sections: {nshdrs} requested, but ELF allows at most 65279",
ctx.args.output.display()
);
}
+1 -1
View File
@@ -8,8 +8,8 @@
use rayon::prelude::*;
use crate::arch::Arch;
use crate::chunks::eh_frame_hdr::EhFrameHdrSection;
use crate::chunks::ChunkHeader;
use crate::chunks::eh_frame_hdr::EhFrameHdrSection;
use crate::context::Context;
use crate::elf::*;
use crate::input_files::ObjectFile;
+1 -5
View File
@@ -41,11 +41,7 @@ pub fn new_header<E: Arch>() -> ChunkHeader<E> {
}
pub fn entry_size<E: Arch>() -> usize {
if E::FAMILY == Family::S390x {
8
} else {
4
}
if E::FAMILY == Family::S390x { 8 } else { 4 }
}
pub fn update_shdr<E: Arch>(ctx: &mut Context<E>) {
+1 -1
View File
@@ -8,8 +8,8 @@
use std::borrow::Cow;
use std::ffi::OsStr;
use std::sync::atomic::Ordering;
use std::sync::RwLock;
use std::sync::atomic::Ordering;
use bstr::BStr;
use rayon::prelude::*;
+1 -5
View File
@@ -31,11 +31,7 @@ impl<E: Arch> Default for NotePropertySection<E> {
}
fn entry_size<E: Arch>() -> usize {
if E::IS_64 {
16
} else {
12
}
if E::IS_64 { 16 } else { 12 }
}
// Merges input files' .note.gnu.property values.
+1 -5
View File
@@ -62,11 +62,7 @@ pub fn add_symbol<E: Arch>(ctx: &mut Context<E>, sym: SymbolId) {
/// Position-independent output relocates both the entry point and the
/// TOC pointer at load time.
pub fn num_dynrels<E: Arch>(ctx: &Context<E>) -> u64 {
if ctx.args.pic {
section(ctx).symbols.len() as u64 * 2
} else {
0
}
if ctx.args.pic { section(ctx).symbols.len() as u64 * 2 } else { 0 }
}
pub fn relr_offsets<E: Arch>(ctx: &Context<E>) -> Vec<u64> {
+2 -2
View File
@@ -11,8 +11,8 @@ use crate::chunks::{ChunkHeader, OutputSectionId};
use crate::context::Context;
use crate::elf::*;
use crate::input_files::SymtabBlock;
use crate::input_sections::{r_delta, InputSectionId};
use crate::symbol::{AddrFlags, SymbolId, NEEDS_CANONICAL};
use crate::input_sections::{InputSectionId, r_delta};
use crate::symbol::{AddrFlags, NEEDS_CANONICAL, SymbolId};
use crate::thunks::Thunk;
use crate::util::align_to;
use crate::util::endian::Endian;
+1 -1
View File
@@ -6,7 +6,7 @@ use crate::arch::Arch;
use crate::chunks::{ChunkHeader, OutputSectionId};
use crate::context::Context;
use crate::elf::*;
use crate::input_sections::{r_delta, FragmentLookup, InputSection};
use crate::input_sections::{FragmentLookup, InputSection, r_delta};
use crate::symbol::{OriginValue, Symbol};
// RelocSection represents a relocation table for an output file.
+1 -1
View File
@@ -1,7 +1,7 @@
//! `.rel.plt` and `.rela.plt`, relocations for PLT entries.
use crate::arch::Arch;
use crate::chunks::{plt, ChunkHeader};
use crate::chunks::{ChunkHeader, plt};
use crate::context::Context;
use crate::elf::*;
+2 -2
View File
@@ -3,11 +3,11 @@
use rayon::prelude::*;
use crate::arch::{Arch, Family};
use crate::chunks::{self, strtab, ChunkHeader, ChunkId};
use crate::chunks::{self, ChunkHeader, ChunkId, strtab};
use crate::context::Context;
use crate::elf::*;
use crate::input_files::{SymtabBlock, SymtabEntries};
use crate::input_sections::{r_delta, InputSection};
use crate::input_sections::{InputSection, r_delta};
use crate::symbol::{AddrFlags, OriginValue, Symbol};
use crate::util::endian::Endian;
+1 -1
View File
@@ -3,9 +3,9 @@
use rayon::prelude::*;
use crate::arch::Arch;
use crate::chunks::ChunkHeader;
use crate::chunks::dynstr::DynstrSection;
use crate::chunks::hash::elf_hash;
use crate::chunks::ChunkHeader;
use crate::context::Context;
use crate::elf::*;
use crate::input_files::FileId;
+1 -1
View File
@@ -1,9 +1,9 @@
//! `.gnu.version_r`, required symbol versions.
use crate::arch::Arch;
use crate::chunks::ChunkHeader;
use crate::chunks::dynstr::DynstrSection;
use crate::chunks::hash::elf_hash;
use crate::chunks::ChunkHeader;
use crate::context::Context;
use crate::elf::*;
use crate::input_files::{DsoId, FileId};
+12 -15
View File
@@ -857,11 +857,7 @@ fn parse_number(opt: &str, value: &str) -> i64 {
};
let n = parse_c_number(digits).unwrap_or_else(|| fatal!("option -{opt}: not a number: {value}"))
as i64;
if negative {
n.wrapping_neg()
} else {
n
}
if negative { n.wrapping_neg() } else { n }
}
fn from_hex(c: u8) -> u8 {
@@ -1292,7 +1288,8 @@ pub fn parse_args(target: &TargetTraits, raw_cmdline: &[Cow<'_, OsStr>]) -> Pars
out!("{VERSION}");
std::process::exit(0);
} else if cursor.read_flag("V") {
out!("{VERSION}\n Supported emulations:\n elf_x86_64\n elf_i386\n aarch64elf\n \
out!(
"{VERSION}\n Supported emulations:\n elf_x86_64\n elf_i386\n aarch64elf\n \
aarch64linux\n aarch64elfb\n aarch64linuxb\n armelf_linux_eabi\n elf64lriscv\n \
elf64briscv\n elf32lriscv\n elf32briscv\n elf32ppc\n elf64ppc\n elf64lppc\n \
elf64_s390\n elf64_sparc\n m68kelf\n shlelf_linux\n shelf_linux\n \
@@ -1540,7 +1537,8 @@ pub fn parse_args(target: &TargetTraits, raw_cmdline: &[Cow<'_, OsStr>]) -> Pars
s if s.starts_with("zlib:") => {
let level = parse_number("compress-debug-sections", &s[5..]);
if !(0..=9).contains(&level) {
fatal!("invalid --compress-debug-sections argument: {arg} (zlib level must be between 0 and 9)"
fatal!(
"invalid --compress-debug-sections argument: {arg} (zlib level must be between 0 and 9)"
);
}
DebugCompression::Zlib(level as u32)
@@ -1548,7 +1546,8 @@ pub fn parse_args(target: &TargetTraits, raw_cmdline: &[Cow<'_, OsStr>]) -> Pars
s if s.starts_with("zstd:") => {
let level = parse_number("compress-debug-sections", &s[5..]);
if !(1..=22).contains(&level) {
fatal!("invalid --compress-debug-sections argument: {arg} (zstd level must be between 1 and 22)"
fatal!(
"invalid --compress-debug-sections argument: {arg} (zstd level must be between 1 and 22)"
);
}
DebugCompression::Zstd(level as i32)
@@ -1810,7 +1809,8 @@ pub fn parse_args(target: &TargetTraits, raw_cmdline: &[Cow<'_, OsStr>]) -> Pars
be8 = value;
} else if read_arg!("format") || read_arg!("b") {
if arg == "binary" {
fatal!("mold does not support `-b binary`. If you want to convert a binary file into an \
fatal!(
"mold does not support `-b binary`. If you want to convert a binary file into an \
object file, use `objcopy -I binary -O default <input-file> <output-file.o>` instead."
);
}
@@ -1911,7 +1911,8 @@ pub fn parse_args(target: &TargetTraits, raw_cmdline: &[Cow<'_, OsStr>]) -> Pars
);
cursor.index += 2;
} else if cursor.text() == "-dynamic" {
fatal!("unknown command line option: -dynamic; -dynamic is a macOS linker's option. mold does not support macOS."
fatal!(
"unknown command line option: -dynamic; -dynamic is a macOS linker's option. mold does not support macOS."
);
} else {
fatal!("unknown command line option: {}", cursor.current().to_string_lossy());
@@ -1979,11 +1980,7 @@ pub fn parse_args(target: &TargetTraits, raw_cmdline: &[Cow<'_, OsStr>]) -> Pars
let report_undefined = report_undefined.unwrap_or(!a.shared);
a.unresolved_symbols = if report_undefined {
if error_unresolved_symbols {
UnresolvedKind::Error
} else {
UnresolvedKind::Warn
}
if error_unresolved_symbols { UnresolvedKind::Error } else { UnresolvedKind::Warn }
} else {
UnresolvedKind::Ignore
};
+1 -1
View File
@@ -12,7 +12,7 @@ use crate::chunks::{self, ChunkId};
use crate::cmdline::{self, Args, TargetTraits};
use crate::context::Context;
use crate::elf::*;
use crate::output_file::{split_ranges, OutputFile};
use crate::output_file::{OutputFile, split_ranges};
use crate::util::parallel::Background;
use crate::{error, fatal, passes};
+1 -1
View File
@@ -6,8 +6,8 @@
use std::fmt;
use std::io::{self, Write};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};
/// Whether to demangle symbol names in diagnostics. This is process-wide
/// state so that `Display` implementations, which have no access to the
+2 -10
View File
@@ -192,19 +192,11 @@ pub fn get_elf_target(data: &[u8]) -> Option<&'static str> {
let is_64 = data[EI_CLASS as usize] == ELFCLASS64 as u8;
let read_u16 = |off: usize| {
let b = [data[off], data[off + 1]];
if is_le {
u16::from_le_bytes(b)
} else {
u16::from_be_bytes(b)
}
if is_le { u16::from_le_bytes(b) } else { u16::from_be_bytes(b) }
};
let read_u32 = |off: usize| {
let b = [data[off], data[off + 1], data[off + 2], data[off + 3]];
if is_le {
u32::from_le_bytes(b)
} else {
u32::from_be_bytes(b)
}
if is_le { u32::from_le_bytes(b) } else { u32::from_be_bytes(b) }
};
let e_machine = read_u16(18) as u32;
// e_flags follows the three word-sized fields after e_version.
+1 -1
View File
@@ -11,7 +11,7 @@ use crate::context::Context;
use crate::elf::*;
use crate::input_files::{FileId, ObjectFile};
use crate::input_sections::{InputSection, SectionRef};
use crate::symbol::{is_c_identifier, OriginValue, SymbolId};
use crate::symbol::{OriginValue, SymbolId, is_c_identifier};
fn should_keep<E: Arch>(file: &ObjectFile<E>, isec: &InputSection<E>) -> bool {
let ty = isec.sh_type(file);
+7 -3
View File
@@ -71,7 +71,7 @@ use crate::context::Context;
use crate::elf::*;
use crate::fatal;
use crate::input_files::display_file;
use crate::output_file::{split_at_offsets, OutputFile};
use crate::output_file::{OutputFile, split_at_offsets};
use crate::util::endian::Endian;
use std::borrow::Cow;
use std::path::Path;
@@ -390,14 +390,18 @@ fn find_cu_abbrev<'a, E: Arch>(
loop {
let code = abbrev.uleb();
if code == 0 {
fatal!("--gdb-index: .debug_abbrev does not contain a record for the first .debug_info record");
fatal!(
"--gdb-index: .debug_abbrev does not contain a record for the first .debug_info record"
);
}
let tag = abbrev.uleb(); // tag
abbrev.u8(); // skip has_children byte
if code == abbrev_code {
// Found a record
if tag != DW_TAG_compile_unit as u64 && tag != DW_TAG_skeleton_unit as u64 {
fatal!("--gdb-index: the first entry's tag is not DW_TAG_compile_unit/DW_TAG_skeleton_unit but {tag:#x}");
fatal!(
"--gdb-index: the first entry's tag is not DW_TAG_compile_unit/DW_TAG_skeleton_unit but {tag:#x}"
);
}
return abbrev;
}
+1 -1
View File
@@ -89,7 +89,7 @@ use crate::context::Context;
use crate::elf::*;
use crate::input_files::{ObjId, ObjectFile};
use crate::input_sections::{InputSection, SectionRef};
use crate::symbol::{is_c_identifier, OriginValue, Symbol};
use crate::symbol::{OriginValue, Symbol, is_c_identifier};
use crate::util::perf::Counter;
use crate::util::siphash::SipHash13_128;
+12 -16
View File
@@ -27,8 +27,8 @@ use crate::input_sections::{
};
use crate::mapped_file::MappedFile;
use crate::symbol::{
hash_key, Bins, OriginValue, ParallelSymbolAllocator, Symbol, SymbolId, SymbolSlot,
SymbolTable, NEEDS_PLT,
Bins, NEEDS_PLT, OriginValue, ParallelSymbolAllocator, Symbol, SymbolId, SymbolSlot,
SymbolTable, hash_key,
};
use crate::util::endian::Endian;
use crate::util::perf::Counter;
@@ -1354,11 +1354,7 @@ impl<E: Arch> ObjectFile<E> {
let is_little_endian = self.base.is_little_endian;
bytes.chunks_exact(4).skip(1).map(move |b| {
let b = [b[0], b[1], b[2], b[3]];
if is_little_endian {
u32::from_le_bytes(b)
} else {
u32::from_be_bytes(b)
}
if is_little_endian { u32::from_le_bytes(b) } else { u32::from_be_bytes(b) }
})
}
@@ -1701,7 +1697,8 @@ impl<E: Arch> ObjectFile<E> {
if name == b".note.GNU-stack" && !args.relocatable {
if flags & SHF_EXECINSTR as u64 != 0 {
if !args.z_execstack && !args.z_execstack_if_needed {
warn!("{self}: this file may cause a segmentation fault because it requires an executable stack. See https://github.com/rui314/mold/tree/main/docs/execstack.md for more info."
warn!(
"{self}: this file may cause a segmentation fault because it requires an executable stack. See https://github.com/rui314/mold/tree/main/docs/execstack.md for more info."
);
}
self.needs_executable_stack = true;
@@ -1815,7 +1812,8 @@ impl<E: Arch> ObjectFile<E> {
// It exists only in DWARF 4, has been removed in DWARF 5 and neither
// GCC nor Clang generate it by default (-fdebug-types-section is
// needed). As such there is probably little need to support it.
fatal!("{self}: mold's --gdb-index is not compatible with .debug_types; to fix this error, remove -fdebug-types-section and recompile"
fatal!(
"{self}: mold's --gdb-index is not compatible with .debug_types; to fix this error, remove -fdebug-types-section and recompile"
);
}
}
@@ -2494,13 +2492,15 @@ impl<E: Arch> ObjectFile<E> {
for rel in cie.rels(self) {
let sym = &ctx.symbols[self.base.symbols[rel.r_sym() as usize]];
if ctx.args.pic && rel.r_type() == E::R_ABS {
error!("{self}: relocation {} in .eh_frame can not be used when making a position-independent output; recompile with -fPIE or -fPIC",
error!(
"{self}: relocation {} in .eh_frame can not be used when making a position-independent output; recompile with -fPIE or -fPIC",
rel.type_name::<E>()
);
}
if sym.is_imported() {
if sym.ty() != STT_FUNC {
fatal!("{self}: {sym}: .eh_frame CIE record with an external data reference is not supported"
fatal!(
"{self}: {sym}: .eh_frame CIE record with an external data reference is not supported"
);
}
sym.add_flags(NEEDS_PLT);
@@ -3380,11 +3380,7 @@ fn symbol_rank_from_fields(
if is_dso || is_in_archive {
return if st_bind == STB_WEAK { 4 } else { 3 };
}
if st_bind == STB_WEAK {
2
} else {
1
}
if st_bind == STB_WEAK { 2 } else { 1 }
}
#[inline]
+10 -20
View File
@@ -1,18 +1,18 @@
//! Input sections and the records the linker parses out of them.
use std::fmt::{self, Write};
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering};
use std::sync::atomic::{AtomicBool, AtomicU8, AtomicU64, Ordering};
use bstr::BStr;
use crate::arch::{Arch, Family};
use crate::chunks::merged::{MergedSection, MergedSectionId};
use crate::chunks::OutputSectionId;
use crate::chunks::merged::{MergedSection, MergedSectionId};
use crate::cmdline::UnresolvedKind;
use crate::context::Context;
use crate::elf::*;
use crate::input_files::{ObjId, ObjectFile};
use crate::symbol::{Symbol, SymbolId, NEEDS_CANONICAL, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSDESC};
use crate::symbol::{NEEDS_CANONICAL, NEEDS_GOTTP, NEEDS_PLT, NEEDS_TLSDESC, Symbol, SymbolId};
use crate::util::compress::{zlib_decompress, zstd_decompress};
use crate::util::concurrent_map::EntryId;
use crate::util::endian::Endian;
@@ -249,11 +249,7 @@ pub struct InputSection<E: Arch> {
#[inline]
fn to_p2align(alignment: u64) -> u8 {
if alignment == 0 {
0
} else {
alignment.trailing_zeros() as u8
}
if alignment == 0 { 0 } else { alignment.trailing_zeros() as u8 }
}
/// Resolved S and A for a nonallocated relocation. Keep its fragment so the
@@ -1033,22 +1029,14 @@ impl<E: Arch> InputSection<E> {
/// The number of bytes removed at delta `i`.
pub fn removed_bytes(deltas: &[RelocDelta], i: usize) -> i64 {
if i == 0 {
deltas[0].delta
} else {
deltas[i].delta - deltas[i - 1].delta
}
if i == 0 { deltas[0].delta } else { deltas[i].delta - deltas[i - 1].delta }
}
/// The total number of bytes removed before `offset`.
pub fn r_delta<E: Arch>(isec: &InputSection<E>, offset: u64) -> i64 {
let deltas = isec.r_deltas();
let i = deltas.partition_point(|d| d.offset < offset);
if i == 0 {
0
} else {
deltas[i - 1].delta
}
if i == 0 { 0 } else { deltas[i - 1].delta }
}
/// Find the prevailing group having the same signature as the discarded group
@@ -1096,7 +1084,8 @@ fn do_action<E: Arch>(
) {
match action {
Action::None => {}
Action::Error => error!("{}: {} relocation at offset 0x{:x} against symbol `{}' can not be used; recompile with -fPIC",
Action::Error => error!(
"{}: {} relocation at offset 0x{:x} against symbol `{}' can not be used; recompile with -fPIC",
isec.display(&ctx.objs[isec.file.index()]),
rel.type_name::<E>(),
rel.r_offset(),
@@ -1200,7 +1189,8 @@ pub fn check_tlsle<E: Arch>(
rel: &ElfRel<E>,
) {
if ctx.args.shared {
error!("{}: relocation {} against `{}` can not be used when making a shared object; recompile with -fPIC",
error!(
"{}: relocation {} against `{}` can not be used when making a shared object; recompile with -fPIC",
isec.display(&ctx.objs[isec.file.index()]),
rel.type_name::<E>(),
sym
+1 -1
View File
@@ -12,7 +12,7 @@ use crate::arch::Arch;
use crate::cmdline::{DefsymValue, ReaderContext};
use crate::context::Context;
use crate::elf::*;
use crate::mapped_file::{apply_chroot, must_open_file, open_file, MappedFile};
use crate::mapped_file::{MappedFile, apply_chroot, must_open_file, open_file};
use crate::reader;
use crate::util;
use crate::{fatal, warn};
+7 -9
View File
@@ -21,7 +21,7 @@
//! state, so this module does too.
use std::borrow::Cow;
use std::ffi::{c_char, c_int, c_uint, c_void, CStr, CString, OsStr, OsString};
use std::ffi::{CStr, CString, OsStr, OsString, c_char, c_int, c_uint, c_void};
use std::fs::File;
#[cfg(not(windows))]
use std::os::unix::io::AsRawFd;
@@ -40,7 +40,7 @@ use crate::cmdline::VERSION;
use crate::context::Context;
use crate::elf::*;
use crate::input_files::{FileId, ObjectFile, ObjectOrigin};
use crate::mapped_file::{must_open_file, MappedFile};
use crate::mapped_file::{MappedFile, must_open_file};
use crate::symbol::SymbolId;
use crate::util::leak_bytes;
use crate::{fatal, out, warn};
@@ -504,11 +504,7 @@ unsafe fn get_symbols<E: Arch>(
if sym.referenced_by_regular_obj() {
LDPR_PREVAILING_DEF
} else if sym.is_exported() {
if is_v2 {
LDPR_PREVAILING_DEF
} else {
LDPR_PREVAILING_DEF_IRONLY_EXP
}
if is_v2 { LDPR_PREVAILING_DEF } else { LDPR_PREVAILING_DEF_IRONLY_EXP }
} else {
LDPR_PREVAILING_DEF_IRONLY
}
@@ -734,7 +730,8 @@ pub fn read_lto_object<E: Arch>(
archive_name: &'static std::path::Path,
) -> Option<ObjectFile<E>> {
if ctx.args.plugin.as_os_str().is_empty() {
fatal!("{}: unable to handle this LTO object file because the -plugin option was not provided. \
fatal!(
"{}: unable to handle this LTO object file because the -plugin option was not provided. \
Please make sure you added -flto not only when creating object files but also when linking \
the final executable.",
mf.name.display()
@@ -755,7 +752,8 @@ pub fn read_lto_object<E: Arch>(
if claimed == 0 {
if mf.parent.is_none() && mf.thin_parent.is_none() {
fatal!("{}: not claimed by the LTO plugin; please make sure you are using the same compiler of the \
fatal!(
"{}: not claimed by the LTO plugin; please make sure you are using the same compiler of the \
same version for all object files",
mf.name.display()
);
+1 -1
View File
@@ -13,8 +13,8 @@ use std::io::{self, Read};
use std::ops::Range;
use std::path::{Path, PathBuf};
use std::ptr::NonNull;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};
#[cfg(not(windows))]
use rayon::prelude::*;
+2 -2
View File
@@ -10,10 +10,10 @@ use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
#[cfg(not(windows))]
use std::os::unix::io::AsRawFd;
use std::path::{Path, PathBuf};
#[cfg(not(windows))]
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
#[cfg(windows)]
use std::sync::Mutex;
#[cfg(not(windows))]
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use memmap2::MmapMut;
#[cfg(not(windows))]
+11 -14
View File
@@ -20,7 +20,7 @@ use crate::chunks::note_property::NotePropertySection;
use crate::chunks::output_section::OutputSection;
use crate::chunks::verdef::VerdefSection;
use crate::chunks::{
self, compressed, copyrel, dynsym, reloc, ChunkHeader, ChunkId, OutputPhdr, OutputSectionId,
self, ChunkHeader, ChunkId, OutputPhdr, OutputSectionId, compressed, copyrel, dynsym, reloc,
};
use crate::cmdline::{
BsymbolicKind, BuildId, CetReportKind, DefsymValue, ReportOutput, SectionOrder,
@@ -29,15 +29,15 @@ use crate::cmdline::{
use crate::context::Context;
use crate::elf::*;
use crate::input_files::{
resolved_symbol_rank, symbol_resolution_rank, ComdatGroupRef, FileId, FileList, ObjId,
ObjectFile, ObjectOrigin, SymbolEditor, SymbolResolver,
ComdatGroupRef, FileId, FileList, ObjId, ObjectFile, ObjectOrigin, SymbolEditor,
SymbolResolver, resolved_symbol_rank, symbol_resolution_rank,
};
use crate::input_sections::{InputSection, InputSectionId, SectionRef};
use crate::linker_script::VersionPattern;
use crate::output_file::OutputFile;
use crate::symbol::{
is_c_identifier, Bins, Symbol, SymbolId, NEEDS_CANONICAL, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT,
NEEDS_PPC_OPD, NEEDS_TLSDESC, NEEDS_TLSGD,
Bins, NEEDS_CANONICAL, NEEDS_GOT, NEEDS_GOTTP, NEEDS_PLT, NEEDS_PPC_OPD, NEEDS_TLSDESC,
NEEDS_TLSGD, Symbol, SymbolId, is_c_identifier,
};
use crate::util::glob::GlobBuilder;
use crate::util::perf::Counter;
@@ -1901,7 +1901,8 @@ pub fn check_symbol_types<E: Arch>(ctx: &Context<E>) {
&& st_type2 != STT_NOTYPE
&& canonicalize(esym1.st_type()) != canonicalize(st_type2)
{
warn!("symbol type mismatch: {sym}\n>>> defined in {} as {}\n>>> defined in {file} as {}",
warn!(
"symbol type mismatch: {sym}\n>>> defined in {} as {}\n>>> defined in {file} as {}",
ctx.file_display(owner),
stt_to_string(esym1.st_type()),
stt_to_string(st_type2)
@@ -3399,11 +3400,7 @@ fn set_virtual_addresses_regular<E: Arch>(ctx: &mut Context<E>) {
const RELRO: u64 = 1 << 32;
let flags_of = |ctx: &Context<E>, id: ChunkId| -> u64 {
let flags = chunks::to_phdr_flags(ctx, id) as u64;
if ctx.args.z_relro && ctx.chunk_header(id).is_relro {
flags | RELRO
} else {
flags
}
if ctx.args.z_relro && ctx.chunk_header(id).is_relro { flags | RELRO } else { flags }
};
let is_tls = |ctx: &Context<E>, id: ChunkId| {
ctx.chunk_header(id).shdr.sh_flags.get() & SHF_TLS as u64 != 0
@@ -3555,9 +3552,9 @@ fn set_virtual_addresses_by_order<E: Arch>(ctx: &mut Context<E>) {
}
SectionOrder::Addr { value, token } => {
if addr != ctx.args.image_base && *value < addr {
error!("--section-order: address goes backward: requested {:#x} < current {addr:#x} (at token '{}')",
value,
token
error!(
"--section-order: address goes backward: requested {:#x} < current {addr:#x} (at token '{}')",
value, token
);
}
addr = *value;
+1 -1
View File
@@ -19,7 +19,7 @@ use crate::context::Context;
use crate::filetype::{self, FileType};
use crate::input_files::{ObjectFile, SharedFile};
use crate::linker_script::Script;
use crate::mapped_file::{must_open_file, open_file, MappedFile};
use crate::mapped_file::{MappedFile, must_open_file, open_file};
use crate::util::perf::Counter;
use crate::util::worker_local::WorkerLocal;
use crate::{fatal, out, warn};
+1 -1
View File
@@ -62,7 +62,7 @@ use crate::chunks::{self, ChunkId};
use crate::context::Context;
use crate::elf::*;
use crate::input_files::{FileId, SymbolEditor};
use crate::input_sections::{r_delta, InputSection, RelocDelta};
use crate::input_sections::{InputSection, RelocDelta, r_delta};
use crate::symbol::Symbol;
/// Returns the distance between a relocated place and a symbol.
+1 -1
View File
@@ -10,7 +10,7 @@ use std::marker::PhantomData;
use std::mem::MaybeUninit;
use std::ops::{Index, IndexMut, Range};
use std::ptr::NonNull;
use std::sync::atomic::{AtomicPtr, AtomicU32, AtomicU8, AtomicUsize, Ordering};
use std::sync::atomic::{AtomicPtr, AtomicU8, AtomicU32, AtomicUsize, Ordering};
// Atomic accesses use relaxed ordering unless stronger synchronization is
// required, matching C++ mold's default atomic wrapper.
+1 -1
View File
@@ -154,7 +154,7 @@
//! pointer (DTP) is the base `__tls_get_addr` returns for offset 0.
use crate::arch::{Arch, Family};
use crate::elf::{ElfPhdr, ElfWord, PhdrRecord, PT_TLS};
use crate::elf::{ElfPhdr, ElfWord, PT_TLS, PhdrRecord};
use crate::util::{align_down, align_to};
/// Returns the TP address which can be used for efficient TLV accesses in
+1 -1
View File
@@ -22,7 +22,7 @@
use rayon::prelude::*;
#[cfg(windows)]
use std::alloc::{alloc_zeroed, dealloc, Layout};
use std::alloc::{Layout, alloc_zeroed, dealloc};
use std::cell::UnsafeCell;
use std::mem::MaybeUninit;
use std::ptr::{self, NonNull};
+5 -25
View File
@@ -42,43 +42,23 @@ pub trait Endian: Copy + Default + Eq + Send + Sync + fmt::Debug + 'static {
const IS_LITTLE: bool;
fn read_u16(bytes: &[u8]) -> u16 {
if Self::IS_LITTLE {
read_ul16(bytes)
} else {
read_ub16(bytes)
}
if Self::IS_LITTLE { read_ul16(bytes) } else { read_ub16(bytes) }
}
fn read_u32(bytes: &[u8]) -> u32 {
if Self::IS_LITTLE {
read_ul32(bytes)
} else {
read_ub32(bytes)
}
if Self::IS_LITTLE { read_ul32(bytes) } else { read_ub32(bytes) }
}
fn read_u64(bytes: &[u8]) -> u64 {
if Self::IS_LITTLE {
read_ul64(bytes)
} else {
read_ub64(bytes)
}
if Self::IS_LITTLE { read_ul64(bytes) } else { read_ub64(bytes) }
}
fn read_i32(bytes: &[u8]) -> i32 {
if Self::IS_LITTLE {
read_il32(bytes)
} else {
read_ib32(bytes)
}
if Self::IS_LITTLE { read_il32(bytes) } else { read_ib32(bytes) }
}
fn read_i64(bytes: &[u8]) -> i64 {
if Self::IS_LITTLE {
read_il64(bytes)
} else {
read_ib64(bytes)
}
if Self::IS_LITTLE { read_il64(bytes) } else { read_ib64(bytes) }
}
fn write_u16(bytes: &mut [u8], value: u16) {
+1 -5
View File
@@ -266,11 +266,7 @@ pub(crate) fn clean_path(path: &std::path::Path) -> std::path::PathBuf {
other => out.push(other),
}
}
if out.as_os_str().is_empty() {
PathBuf::from(".")
} else {
out
}
if out.as_os_str().is_empty() { PathBuf::from(".") } else { out }
}
/// Formats a byte string for diagnostics, replacing invalid UTF-8.
+12 -14
View File
@@ -12,7 +12,7 @@ use std::io;
use std::path::{Path, PathBuf};
use std::process::{Command, ExitCode, Stdio};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{mpsc, Arc};
use std::sync::{Arc, mpsc};
use std::thread;
use std::time::{Duration, Instant};
@@ -499,7 +499,7 @@ fn run_process(root: &Path, job: &TestJob, timeout: Duration) -> Result<Outcome,
Outcome::Skip
} else {
Outcome::Pass
})
});
}
None if start.elapsed() < timeout => thread::sleep(Duration::from_millis(20)),
None => {
@@ -560,13 +560,15 @@ fn run_jobs(root: &Path, jobs: Vec<TestJob>, options: &Options) -> Vec<TestResul
let jobs = &jobs;
let next = &next;
let sender = sender.clone();
scope.spawn(move || loop {
let index = next.fetch_add(1, Ordering::Relaxed);
let Some(job) = jobs.get(index) else {
break;
};
if sender.send(run_job(root, job, options.timeout)).is_err() {
break;
scope.spawn(move || {
loop {
let index = next.fetch_add(1, Ordering::Relaxed);
let Some(job) = jobs.get(index) else {
break;
};
if sender.send(run_job(root, job, options.timeout)).is_err() {
break;
}
}
});
}
@@ -651,11 +653,7 @@ pub fn run(cases_dirs: &[PathBuf], mold: &Path) -> ExitCode {
}
let results = run_jobs(&work_dir, jobs, &options);
if print_summary(&results) {
ExitCode::SUCCESS
} else {
ExitCode::FAILURE
}
if print_summary(&results) { ExitCode::SUCCESS } else { ExitCode::FAILURE }
}
#[cfg(test)]