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
30 changes: 7 additions & 23 deletions libwild/src/elf_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,28 +1467,11 @@ fn write_object<'data, A: Arch<Platform = Elf>>(
let _span = debug_span!("write_file", filename = %object.input).entered();
let _file_span = layout.args().common().trace_span_for_file(object.file_id);

let Some(crate::layout::FileLayout::Epilogue(epilogue)) =
layout.group_layouts.last().and_then(|g| g.files.last())
else {
unreachable!("Epilogue is broken and must be the last file in the final layout group");
};

for (i, sec) in object.sections.iter().enumerate() {
let section_index = object::SectionIndex(i);

match sec {
SectionSlot::Loaded(sec) => {
let is_harvested = epilogue
.script_sorted_sections
.binary_search_by_key(&(object.file_id, section_index.0), |h| {
(h.file_id, h.section_index.0)
})
.is_ok();

if is_harvested {
continue;
}

write_object_section::<A>(
object,
layout,
Expand Down Expand Up @@ -2134,6 +2117,7 @@ fn write_symbols<'data>(
if let Some(section_index) = object.object.symbol_section(sym, sym_index)? {
match &object.sections[section_index.0] {
SectionSlot::Loaded(_)
| SectionSlot::Sorted(_)
| SectionSlot::LoadedDebugInfo(_)
| SectionSlot::MergeStrings(_) => object
.section_part_id(section_index, &layout.symbol_db.section_part_ids)
Expand Down Expand Up @@ -4052,18 +4036,18 @@ fn write_epilogue<A: Arch<Platform = Elf>>(
let build_id_buffer = buffers.get_mut(part_id::NOTE_GNU_BUILD_ID);
build_id_buffer.fill(0);

for harvested in &epilogue.script_sorted_sections {
let crate::layout::FileLayout::Object(object) = layout.file_layout(harvested.file_id)
for sorted_section in &layout.script_sorted_sections {
let crate::layout::FileLayout::Object(object) = layout.file_layout(sorted_section.file_id)
else {
continue;
unreachable!();
};

if let SectionSlot::Loaded(sec) = &object.sections[harvested.section_index.0] {
if let SectionSlot::Sorted(sec) = &object.sections[sorted_section.section_index.0] {
write_object_section::<A>(
object,
layout,
*sec,
harvested.section_index,
sec.section,
sorted_section.section_index,
buffers,
table_writer,
trace,
Expand Down
Loading
Loading