mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-12-16 08:27:02 +00:00
Emit FORCEACTIVE in LCF & various fixes
This commit is contained in:
@@ -34,8 +34,6 @@ flags! {
|
||||
Common,
|
||||
Hidden,
|
||||
ForceActive,
|
||||
// Same as ForceActive, but used internally
|
||||
ExternallyReferenced,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +72,6 @@ impl ObjSymbolFlagSet {
|
||||
#[inline]
|
||||
pub fn is_force_active(&self) -> bool { self.0.contains(ObjSymbolFlags::ForceActive) }
|
||||
|
||||
#[inline]
|
||||
pub fn is_externally_referenced(&self) -> bool {
|
||||
self.0.contains(ObjSymbolFlags::ExternallyReferenced)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_scope(&mut self, scope: ObjSymbolScope) {
|
||||
match scope {
|
||||
@@ -101,11 +94,11 @@ impl ObjSymbolFlagSet {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_externally_referenced(&mut self, value: bool) {
|
||||
pub fn set_force_active(&mut self, value: bool) {
|
||||
if value {
|
||||
self.0 |= ObjSymbolFlags::ExternallyReferenced;
|
||||
self.0 |= ObjSymbolFlags::ForceActive;
|
||||
} else {
|
||||
self.0 &= !ObjSymbolFlags::ExternallyReferenced;
|
||||
self.0 &= !ObjSymbolFlags::ForceActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -562,8 +555,9 @@ impl ObjSymbols {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn set_externally_referenced(&mut self, idx: SymbolIndex, value: bool) {
|
||||
self.symbols[idx].flags.set_externally_referenced(value);
|
||||
#[inline]
|
||||
pub fn flags(&mut self, idx: SymbolIndex) -> &mut ObjSymbolFlagSet {
|
||||
&mut self.symbols[idx].flags
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,6 +623,18 @@ impl ObjInfo {
|
||||
|
||||
pub fn section_data(&self, start: u32, end: u32) -> Result<(&ObjSection, &[u8])> {
|
||||
let section = self.section_at(start)?;
|
||||
ensure!(
|
||||
section.contains_range(start..end),
|
||||
"Range {:#010X}-{:#010X} outside of section {}: {:#010X}-{:#010X}",
|
||||
start,
|
||||
end,
|
||||
section.name,
|
||||
section.address,
|
||||
section.address + section.size
|
||||
);
|
||||
if section.kind == ObjSectionKind::Bss {
|
||||
return Ok((section, &[]));
|
||||
}
|
||||
let data = if end == 0 {
|
||||
§ion.data[(start as u64 - section.address) as usize..]
|
||||
} else {
|
||||
|
||||
@@ -97,7 +97,7 @@ fn split_ctors_dtors(obj: &mut ObjInfo, section_start: u32, section_end: u32) ->
|
||||
|
||||
// Hack to avoid deadstripping
|
||||
for symbol_idx in referenced_symbols {
|
||||
obj.symbols.set_externally_referenced(symbol_idx, true);
|
||||
obj.symbols.flags(symbol_idx).set_force_active(true);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user