Skip to content

Commit 46e6052

Browse files
committed
Fix extab splitting with -inline deferred
With `-inline deferred`, functions within a TU may be emitted in reverse order in `.text`, while extab data remains in source (forward) order. This means consecutive extabindex entries can reference decreasing extab addresses. To avoid contradictory ordering constraints (which cause cyclic dependency errors in link order resolution), we group such reversed entries and assign them a single TU name, creating one covering split per section type. Fixes #65 Fixes #120 Fixes #132
1 parent c4de1b4 commit 46e6052

2 files changed

Lines changed: 397 additions & 125 deletions

File tree

src/util/dol.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,15 @@ fn locate_extab_extabindex(obj: &mut ObjInfo) -> Result<()> {
10061006
)?;
10071007
}
10081008

1009-
let mut entry_iter = eti_entries.iter().peekable();
1009+
// Sort by extab_addr for correct size computation.
1010+
// With -inline deferred, extab addresses may not be monotonically increasing
1011+
// in extabindex iteration order, so sorting ensures subtraction never underflows.
1012+
let mut sorted_entries: Vec<&EtiEntry> = eti_entries.iter().collect();
1013+
sorted_entries.sort_by_key(|e| e.extab_addr);
1014+
let mut entry_iter = sorted_entries.iter().peekable();
10101015
loop {
10111016
let (addr, size) = match (entry_iter.next(), entry_iter.peek()) {
1012-
(Some(a), Some(&b)) => (a.extab_addr, b.extab_addr - a.extab_addr),
1017+
(Some(a), Some(b)) => (a.extab_addr, b.extab_addr - a.extab_addr),
10131018
(Some(a), None) => (
10141019
a.extab_addr,
10151020
(extab_section_address + extab_section_size) as u32 - a.extab_addr,

0 commit comments

Comments
 (0)