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
93 changes: 51 additions & 42 deletions Cargo.lock

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

26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ crate-type = ["dylib"]

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { version = "0.130.0", default-features = false, features = ["std", "timing", "unwind", "all-native-arch"] }
cranelift-frontend = { version = "0.130.0" }
cranelift-module = { version = "0.130.0" }
cranelift-native = { version = "0.130.0" }
cranelift-jit = { version = "0.130.0", optional = true }
cranelift-object = { version = "0.130.0" }
cranelift-codegen = { version = "0.131.0", default-features = false, features = ["std", "timing", "unwind", "all-native-arch"] }
cranelift-frontend = { version = "0.131.0" }
cranelift-module = { version = "0.131.0" }
cranelift-native = { version = "0.131.0" }
cranelift-jit = { version = "0.131.0", optional = true }
cranelift-object = { version = "0.131.0" }
target-lexicon = "0.13"
gimli = { version = "0.33", default-features = false, features = ["write"] }
object = { version = "0.38.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
object = { version = "0.39.1", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

indexmap = "2.0.0"
libloading = { version = "0.9.0", optional = true }
smallvec = "1.8.1"

[patch.crates-io]
# Uncomment to use an unreleased version of cranelift
#cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-43.0.0" }
#cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-43.0.0" }
#cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-43.0.0" }
#cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-43.0.0" }
#cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-43.0.0" }
#cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-43.0.0" }
#cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-44.0.0" }
#cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-44.0.0" }
#cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-44.0.0" }
#cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-44.0.0" }
#cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-44.0.0" }
#cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-44.0.0" }

# Uncomment to use local checkout of cranelift
#cranelift-codegen = { path = "../wasmtime/cranelift/codegen" }
Expand Down
2 changes: 1 addition & 1 deletion src/debuginfo/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl DebugContext {
let _: Result<()> = sections.for_each(|id, section| {
if let Some(section_id) = section_map.get(&id) {
for reloc in &section.relocs {
product.add_debug_reloc(&section_map, section_id, reloc);
Comment thread
philipc marked this conversation as resolved.
product.add_debug_reloc(&section_map, section_id, reloc, true);
}
}
Ok(())
Expand Down
54 changes: 31 additions & 23 deletions src/debuginfo/object.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cranelift_module::{DataId, FuncId};
use cranelift_object::ObjectProduct;
use gimli::SectionId;
use object::write::{Relocation, StandardSegment};
use object::write::{Relocation, StandardSection, StandardSegment};
use object::{RelocationEncoding, RelocationFlags, SectionKind};
use rustc_data_structures::fx::FxHashMap;

Expand All @@ -16,6 +16,7 @@ pub(super) trait WriteDebugInfo {
section_map: &FxHashMap<SectionId, Self::SectionId>,
from: &Self::SectionId,
reloc: &DebugReloc,
use_section_symbol: bool,
);
}

Expand All @@ -27,29 +28,31 @@ impl WriteDebugInfo for ObjectProduct {
id: SectionId,
data: Vec<u8>,
) -> (object::write::SectionId, object::write::SymbolId) {
let name = if self.object.format() == object::BinaryFormat::MachO {
id.name().replace('.', "__") // machO expects __debug_info instead of .debug_info
let (section_id, align);
if id == SectionId::EhFrame {
section_id = self.object.section_id(StandardSection::EhFrame);
align = 8;
} else {
id.name().to_string()
}
.into_bytes();

let segment = self.object.segment_name(StandardSegment::Debug).to_vec();
// FIXME use SHT_X86_64_UNWIND for .eh_frame
let section_id = self.object.add_section(
segment,
name,
if id == SectionId::DebugStr || id == SectionId::DebugLineStr {
SectionKind::DebugString
} else if id == SectionId::EhFrame {
SectionKind::ReadOnlyData
let name = if self.object.format() == object::BinaryFormat::MachO {
id.name().replace('.', "__") // machO expects __debug_info instead of .debug_info
} else {
SectionKind::Debug
},
);
self.object
.section_mut(section_id)
.set_data(data, if id == SectionId::EhFrame { 8 } else { 1 });
id.name().to_string()
}
.into_bytes();

let segment = self.object.segment_name(StandardSegment::Debug).to_vec();
section_id = self.object.add_section(
segment,
name,
if id == SectionId::DebugStr || id == SectionId::DebugLineStr {
SectionKind::DebugString
} else {
SectionKind::Debug
},
);
align = 1;
}
self.object.section_mut(section_id).set_data(data, align);
let symbol_id = self.object.section_symbol(section_id);
(section_id, symbol_id)
}
Expand All @@ -59,6 +62,7 @@ impl WriteDebugInfo for ObjectProduct {
section_map: &FxHashMap<SectionId, Self::SectionId>,
from: &Self::SectionId,
reloc: &DebugReloc,
use_section_symbol: bool,
) {
let (symbol, symbol_offset) = match reloc.name {
DebugRelocName::Section(id) => (section_map.get(&id).unwrap().1, 0),
Expand All @@ -69,7 +73,11 @@ impl WriteDebugInfo for ObjectProduct {
} else {
self.data_symbol(DataId::from_u32(id & !(1 << 31)))
};
self.object.symbol_section_and_offset(symbol_id).unwrap_or((symbol_id, 0))
if use_section_symbol {
self.object.symbol_section_and_offset(symbol_id).unwrap_or((symbol_id, 0))
} else {
(symbol_id, 0)
}
}
};
self.object
Expand Down
Loading
Loading