diff --git a/src/backend.rs b/src/backend.rs index 449e2a5cc265..60cf43da1b91 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -42,24 +42,21 @@ impl WriteMetadata for faerie::Artifact { } impl WriteMetadata for object::write::Object { - fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool) { + fn add_rustc_section(&mut self, symbol_name: String, data: Vec, _is_like_osx: bool) { let segment = self.segment_name(object::write::StandardSegment::Data).to_vec(); let section_id = self.add_section(segment, b".rustc".to_vec(), object::SectionKind::Data); let offset = self.append_section_data(section_id, &data, 1); - // FIXME implement faerie elf backend section custom symbols - // For MachO this is necessary to prevent the linker from throwing away the .rustc section, - // but for ELF it isn't. - if is_like_osx { - self.add_symbol(object::write::Symbol { - name: symbol_name.into_bytes(), - value: offset, - size: data.len() as u64, - kind: object::SymbolKind::Data, - scope: object::SymbolScope::Compilation, - weak: false, - section: Some(section_id), - }); - } + // For MachO and probably PE this is necessary to prevent the linker from throwing away the + // .rustc section. For ELF this isn't necessary, but it also doesn't harm. + self.add_symbol(object::write::Symbol { + name: symbol_name.into_bytes(), + value: offset, + size: data.len() as u64, + kind: object::SymbolKind::Data, + scope: object::SymbolScope::Compilation, + weak: false, + section: Some(section_id), + }); } } @@ -70,7 +67,7 @@ pub trait WriteDebugInfo { fn add_debug_reloc( &mut self, section_map: &HashMap, - symbol_map: &indexmap::IndexSet<(String, FuncId)>, + symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, ); @@ -87,7 +84,7 @@ impl WriteDebugInfo for FaerieProduct { fn add_debug_reloc( &mut self, _section_map: &HashMap, - symbol_map: &indexmap::IndexSet<(String, FuncId)>, + symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, ) { @@ -98,7 +95,7 @@ impl WriteDebugInfo for FaerieProduct { from: from.name(), to: match reloc.name { DebugRelocName::Section(id) => id.name(), - DebugRelocName::Symbol(index) => &symbol_map.get_index(index).unwrap().0, + DebugRelocName::Symbol(index) => &symbol_map.get_index(index).unwrap().1, }, at: u64::from(reloc.offset), }, @@ -130,15 +127,14 @@ impl WriteDebugInfo for ObjectProduct { fn add_debug_reloc( &mut self, section_map: &HashMap, - symbol_map: &indexmap::IndexSet<(String, FuncId)>, + symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, ) { let symbol = match reloc.name { DebugRelocName::Section(id) => section_map.get(&id).unwrap().1, DebugRelocName::Symbol(id) => { - let (_func_name, func_id) = symbol_map.get_index(id).unwrap(); - self.function_symbol(*func_id) + self.function_symbol(*symbol_map.get_index(id).unwrap().0) } }; self.object.add_relocation(from.0, Relocation { diff --git a/src/debuginfo.rs b/src/debuginfo.rs index d2705c6a2c74..762fa8668bfb 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -71,7 +71,7 @@ pub enum DebugRelocName { pub struct DebugContext<'tcx> { endian: RunTimeEndian, - symbols: indexmap::IndexSet<(String, FuncId)>, + symbols: indexmap::IndexMap, dwarf: DwarfUnit, unit_range_list: RangeList, @@ -133,7 +133,7 @@ impl<'tcx> DebugContext<'tcx> { DebugContext { endian: target_endian(tcx), - symbols: indexmap::IndexSet::new(), + symbols: indexmap::IndexMap::new(), dwarf, unit_range_list: RangeList(Vec::new()), @@ -216,7 +216,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { name: &str, _sig: &Signature, ) -> Self { - let (symbol, _) = debug_context.symbols.insert_full((name.to_string(), func_id)); + let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string()); // FIXME: add to appropriate scope intead of root let scope = debug_context.dwarf.unit.root(); diff --git a/src/driver.rs b/src/driver.rs index b26da23da907..215ae071c3f6 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -174,7 +174,7 @@ fn run_aot( let obj = product.emit(); std::fs::write(&tmp_file, obj).unwrap(); CompiledModule { - name: name, + name, kind, object: Some(tmp_file), bytecode: None,