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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libwild/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ impl ArgumentParser {
// TODO: This is ad-hoc
help.push_str(&format!(
" {:<31} Read options from a file\n",
format!("@<VALUE>"),
"@<VALUE>",
));

let mut help_to_options: HashMap<&str, Vec<String>> = HashMap::new();
Expand Down
10 changes: 5 additions & 5 deletions libwild/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl platform::Platform for Elf {
*memory_offsets.get(part_id::EH_FRAME)
}

fn finalise_find_required_sections<'data>(groups: &[layout::GroupState<'data, Elf>]) {
fn finalise_find_required_sections(groups: &[layout::GroupState<Elf>]) {
tracing::debug!(target: "metrics", total = groups
.iter()
.map(|g| g.common.format_specific.exception_frame_count)
Expand Down Expand Up @@ -580,8 +580,8 @@ impl platform::Platform for Elf {
&[STACK_SEGMENT_DEF]
}

fn create_linker_defined_symbols<'data>(
symbols: &mut crate::parsing::InternalSymbolsBuilder<'data>,
fn create_linker_defined_symbols(
symbols: &mut crate::parsing::InternalSymbolsBuilder,
output_kind: OutputKind,
) {
// The undefined symbol must always be symbol 0.
Expand Down Expand Up @@ -1782,7 +1782,7 @@ fn allocate_sysv_hash(
return Ok(());
}

let bucket_count = ((num_defs / 2).max(1)).next_power_of_two() as u32;
let bucket_count = (num_defs / 2).max(1).next_power_of_two() as u32;
// Whereas `num_defs` above is the number of definitions, this is the number of dynamic
// symbols, which also includes undefined dynamic symbols.
let num_dynsym = *current_sizes.get(part_id::DYNSYM) / SYMTAB_ENTRY_SIZE;
Expand Down Expand Up @@ -2943,7 +2943,7 @@ pub(crate) struct NonAddressableIndexes {
}

impl platform::NonAddressableIndexes for NonAddressableIndexes {
fn new<'data, P: Platform>(symbol_db: &crate::symbol_db::SymbolDb<'data, P>) -> Self {
fn new<P: Platform>(symbol_db: &crate::symbol_db::SymbolDb<P>) -> Self {
Self {
// Allocate version indexes starting from after the local and global indexes and any
// versions defined by a version script.
Expand Down
6 changes: 3 additions & 3 deletions libwild/src/elf_aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl crate::platform::Arch for ElfAArch64 {
false
}

fn tp_offset_start<'data>(layout: &Layout<'data, Elf>) -> u64 {
fn tp_offset_start(layout: &Layout<Elf>) -> u64 {
layout.tls_start_address_aarch64()
}

Expand Down Expand Up @@ -278,8 +278,8 @@ impl crate::platform::Arch for ElfAArch64 {
None
}

fn is_symbol_variant_pcs<'data>(
object: &<Self::Platform as Platform>::File<'data>,
fn is_symbol_variant_pcs(
object: &<Self::Platform as Platform>::File<'_>,
symbol_index: object::SymbolIndex,
) -> bool {
object
Expand Down
2 changes: 1 addition & 1 deletion libwild/src/elf_loongarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl crate::platform::Arch for ElfLoongArch64 {
true
}

fn tp_offset_start<'data>(layout: &crate::layout::Layout<'data, Elf>) -> u64 {
fn tp_offset_start(layout: &crate::layout::Layout<Elf>) -> u64 {
layout.tls_start_address()
}

Expand Down
6 changes: 3 additions & 3 deletions libwild/src/elf_riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl crate::platform::Arch for ElfRiscV64 {
true
}

fn tp_offset_start<'data>(layout: &crate::layout::Layout<'data, Elf>) -> u64 {
fn tp_offset_start(layout: &crate::layout::Layout<Elf>) -> u64 {
layout.tls_start_address()
}

Expand Down Expand Up @@ -155,8 +155,8 @@ impl crate::platform::Arch for ElfRiscV64 {
]
}

fn is_symbol_variant_pcs<'data>(
object: &<Self::Platform as Platform>::File<'data>,
fn is_symbol_variant_pcs(
object: &<Self::Platform as Platform>::File<'_>,
symbol_index: object::SymbolIndex,
) -> bool {
object
Expand Down
3 changes: 1 addition & 2 deletions libwild/src/elf_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3230,8 +3230,7 @@ fn write_epilogue<A: Arch<Platform = Elf>>(

// The actual build-id will be filled in later once all writing has completed. It's important
// that we fill it with zeros now however, since if we're overwriting an existing file, there
// might be other data there and it we don't zero it, then the build ID will be hashing that
// data.
// might be other data there and we don't zero it, then the build ID will be hashing that data.
let build_id_buffer = buffers.get_mut(part_id::NOTE_GNU_BUILD_ID);
build_id_buffer.fill(0);

Expand Down
8 changes: 4 additions & 4 deletions libwild/src/elf_x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl crate::platform::Arch for ElfX86_64 {
plt_address: u64,
) -> crate::error::Result {
plt_entry.copy_from_slice(PLT_ENTRY_TEMPLATE);
let offset: i32 = ((got_address.wrapping_sub(plt_address + 0xb)) as i64)
let offset: i32 = (got_address.wrapping_sub(plt_address + 0xb) as i64)
.try_into()
.map_err(|_| error!("PLT is more than 2GiB away from GOT"))?;
plt_entry[7..11].copy_from_slice(&offset.to_le_bytes());
Expand All @@ -91,7 +91,7 @@ impl crate::platform::Arch for ElfX86_64 {
false
}

fn tp_offset_start<'data>(layout: &crate::layout::Layout<'data, Elf>) -> u64 {
fn tp_offset_start(layout: &crate::layout::Layout<Elf>) -> u64 {
layout.tls_end_address()
}

Expand Down Expand Up @@ -164,9 +164,9 @@ impl crate::platform::Arch for ElfX86_64 {

match relocation_kind {
object::elf::R_X86_64_REX_GOTPCRELX | object::elf::R_X86_64_CODE_4_GOTPCRELX
if ((relocation_kind == object::elf::R_X86_64_CODE_4_GOTPCRELX
if (relocation_kind == object::elf::R_X86_64_CODE_4_GOTPCRELX
&& (offset >= 4 && section_bytes[offset - 4] == 0xd5))
|| offset >= 3) =>
|| offset >= 3 =>
{
let b1 = section_bytes[offset - 2];
let rex = section_bytes[offset - 3];
Expand Down
2 changes: 1 addition & 1 deletion libwild/src/file_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ pub(crate) fn split_buffers_by_alignment<'out, 'data, P: Platform>(
)
}

fn write_layout<'data, P: Platform>(layout: &Layout<'data, P>) -> Result {
fn write_layout<P: Platform>(layout: &Layout<P>) -> Result {
let layout_path = linker_layout::layout_path(&layout.args().output);
write_layout_to(layout, &layout_path)
.with_context(|| format!("Failed to write layout to `{}`", layout_path.display()))
Expand Down
2 changes: 1 addition & 1 deletion libwild/src/grouping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn determine_max_files_per_group(args: &Args) -> usize {
}

/// Compute the total number of symbols in the supplied objects.
fn count_symbols<'data, P: Platform>(objects: &[Box<ParsedInputObject<'data, P>>]) -> usize {
fn count_symbols<P: Platform>(objects: &[Box<ParsedInputObject<P>>]) -> usize {
verbose_timing_phase!("Count symbols");

objects.iter().map(|o| o.num_symbols()).sum::<usize>()
Expand Down
16 changes: 8 additions & 8 deletions libwild/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ struct SectionLoadRequest {
}

impl WorkItem {
fn file_id<'data, P: Platform>(self, symbol_db: &SymbolDb<'data, P>) -> FileId {
fn file_id<P: Platform>(self, symbol_db: &SymbolDb<P>) -> FileId {
match self {
WorkItem::LoadGlobalSymbol(s) | WorkItem::CopyRelocateSymbol(s) => {
symbol_db.file_id_for_symbol(s)
Expand Down Expand Up @@ -1594,8 +1594,8 @@ fn merge_secondary_parts<P: Platform>(
}
}

fn compute_start_offsets_by_group<'data, P: Platform>(
group_states: &[GroupState<'data, P>],
fn compute_start_offsets_by_group<P: Platform>(
group_states: &[GroupState<P>],
mut mem_offsets: OutputSectionPartMap<u64>,
) -> Vec<OutputSectionPartMap<u64>> {
timing_phase!("Compute per-group start offsets");
Expand Down Expand Up @@ -3722,9 +3722,9 @@ impl HeaderInfo {

/// Construct a new inactive instance, which means we don't yet load non-GC sections and only
/// load them later if a symbol from this object is referenced.
fn new_object_layout_state<'data, P: Platform>(
input_state: resolution::ResolvedObject<'data, P>,
) -> FileLayoutState<'data, P> {
fn new_object_layout_state<P: Platform>(
input_state: resolution::ResolvedObject<P>,
) -> FileLayoutState<P> {
// Note, this function is called for all objects from a single thread, so don't be tempted to do
// significant work here. Do work when activate is called instead. Doing it there also means
// that we don't do the work unless the object is actually needed.
Expand Down Expand Up @@ -5608,8 +5608,8 @@ impl<'data, P: Platform> std::fmt::Debug for FileLayoutState<'data, P> {
}
}

fn section_debug<'data, P: Platform>(
object: &P::File<'data>,
fn section_debug<P: Platform>(
object: &P::File<'_>,
section_index: object::SectionIndex,
) -> impl std::fmt::Display {
let name = object
Expand Down
13 changes: 5 additions & 8 deletions libwild/src/linker_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl<'data> LinkerPlugin<'data> {
}
}

fn has_loaded_lto_input<'data, P: Platform>(resolved_groups: &[ResolvedGroup<'data, P>]) -> bool {
fn has_loaded_lto_input<P: Platform>(resolved_groups: &[ResolvedGroup<P>]) -> bool {
resolved_groups.iter().any(|group| {
group
.files
Expand Down Expand Up @@ -1012,13 +1012,10 @@ extern "C" fn message(level: libc::c_int, format: *const libc::c_char) -> Status
/// from all non-trivial hooks in order to ensure that we don't try to propagate a panic back into
/// the linker-plugin which would be undefined behaviour.
fn catch_panics(body: impl FnOnce() -> Status) -> Status {
match std::panic::catch_unwind(AssertUnwindSafe(body)) {
Ok(status) => status,
Err(_) => {
ERROR_MESSAGE.replace(Some("Panic in plugin callback".to_owned()));
Status::Err
}
}
std::panic::catch_unwind(AssertUnwindSafe(body)).unwrap_or_else(|_| {
ERROR_MESSAGE.replace(Some("Panic in plugin callback".to_owned()));
Status::Err
})
}

struct ClaimContext<'data> {
Expand Down
14 changes: 7 additions & 7 deletions libwild/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) trait Arch: Send + Sync + 'static {
/// Get position of the $tp (thread pointer) in the TLS section. Each platform defines
/// a different place based on the following article:
/// https://maskray.me/blog/2021-02-14-all-about-thread-local-storage#tls-variants
fn tp_offset_start<'data>(layout: &Layout<'data, Self::Platform>) -> u64;
fn tp_offset_start(layout: &Layout<Self::Platform>) -> u64;

/// Classify a GNU property note.
fn get_property_class(property_type: u32) -> Option<crate::elf::PropertyClass>;
Expand Down Expand Up @@ -103,8 +103,8 @@ pub(crate) trait Arch: Send + Sync + 'static {
unreachable!();
}

fn is_symbol_variant_pcs<'data>(
_object: &<Self::Platform as Platform>::File<'data>,
fn is_symbol_variant_pcs(
_object: &<Self::Platform as Platform>::File<'_>,
_symbol_index: object::SymbolIndex,
) -> bool {
false
Expand Down Expand Up @@ -219,7 +219,7 @@ pub(crate) trait Platform: Send + Sync + Sized + std::fmt::Debug + 'static {
fn frame_data_base_address(memory_offsets: &OutputSectionPartMap<u64>) -> u64;

/// Called after GC phase has completed. Mostly useful for platform-specific logging.
fn finalise_find_required_sections<'data>(groups: &[layout::GroupState<'data, Self>]);
fn finalise_find_required_sections(groups: &[layout::GroupState<Self>]);

fn pre_finalise_sizes_prelude<'data>(
common: &mut layout::CommonGroupState<'data, Self>,
Expand Down Expand Up @@ -301,8 +301,8 @@ pub(crate) trait Platform: Send + Sync + Sized + std::fmt::Debug + 'static {
/// Returns segment definitions that should be unconditionally emitted without content.
fn unconditional_segment_defs() -> &'static [Self::ProgramSegmentDef];

fn create_linker_defined_symbols<'data>(
symbols: &mut crate::parsing::InternalSymbolsBuilder<'data>,
fn create_linker_defined_symbols(
symbols: &mut crate::parsing::InternalSymbolsBuilder,
output_kind: OutputKind,
);

Expand Down Expand Up @@ -716,7 +716,7 @@ pub(crate) trait DynamicTagValues<'data>: std::fmt::Debug + Send + Sync + 'data
}

pub(crate) trait NonAddressableIndexes: Send + Sync + 'static {
fn new<'data, P: Platform>(symbol_db: &SymbolDb<'data, P>) -> Self;
fn new<P: Platform>(symbol_db: &SymbolDb<P>) -> Self;
}

pub(crate) trait SectionAttributes:
Expand Down
2 changes: 1 addition & 1 deletion libwild/src/string_merging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ struct StringToMerge<'data, 'offsets> {
offset_out: OffsetOut<'offsets>,
}

/// A place where we'll store the `BucketOffset` of the the string once known.
/// A place where we'll store the `BucketOffset` of the string once known.
enum OffsetOut<'offsets> {
InShard(&'offsets mut BucketOffset),
Overflow(LinearInputOffset),
Expand Down
6 changes: 3 additions & 3 deletions libwild/src/symbol_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'data, P: Platform> SymbolDb<'data, P> {
});

// Don't forget to add the non-interposable flag the local symbols.
// We coudn't do this earlier as we didn't know which symbols would remain
// We couldn't do this earlier as we didn't know which symbols would remain
// local.
per_symbol_flags
.flags_mut()
Expand Down Expand Up @@ -1666,7 +1666,7 @@ trait SymbolLoader<'data, P: Platform> {
false
}

/// Returns whether the supplied symbol should be ignore.
/// Returns whether the supplied symbol should be ignored.
fn should_ignore_symbol(&self, _symbol: &P::SymtabEntry) -> bool {
false
}
Expand Down Expand Up @@ -2030,7 +2030,7 @@ impl InternalSymDefInfo<'_> {
SymbolPlacement::SectionEnd(i) => Some(i),
SymbolPlacement::SectionGroupEnd(i) => Some(i),
// The other linkers attach to the closest section, but the address is nonetheless
// outside of the selected section. It's tricky for us to find the the closest section
// outside of the selected section. It's tricky for us to find the closest section
// at this point in the code, so we pick an arbitrary section.
SymbolPlacement::LoadBaseAddress => Some(output_section_id::TEXT),
}
Expand Down
1 change: 0 additions & 1 deletion linker-diff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ symbolic-demangle = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true }
itertools = { workspace = true }
leb128 = { workspace = true }
gimli = { workspace = true }
colored = { workspace = true }
tracing = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions linker-diff/src/asm_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,8 +1407,8 @@ struct ResolvedGroup<'data, A: Arch> {
/// The inclusive start of the bytes associated with this resolution.
start: u64,

/// The exclusive end of the bytes associated with this resolution. This should the the offset
/// of the first byte after the later of (a) any instructions modified by the relaxation and
/// The exclusive end of the bytes associated with this resolution. This should be the offset
/// of the first byte after the latter of (a) any instructions modified by the relaxation and
/// (b) the bytes of the relocation offset.
end: u64,

Expand Down
Loading