diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-12-15 13:57:13 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-12-15 13:57:13 +0000 |
| commit | d841f93855f94cafaf3c1a5933b6a0b1c88fa9d3 (patch) | |
| tree | aba2de2dc6113bf750de05e6303b766adb48124e | |
| parent | d74e5b6cc7d7b015362e68ae2be88cfc3415ce3a (diff) | |
| download | rust-d841f93855f94cafaf3c1a5933b6a0b1c88fa9d3.tar.gz rust-d841f93855f94cafaf3c1a5933b6a0b1c88fa9d3.zip | |
Add .comment section with producer name
Fixes #1211
| -rw-r--r-- | src/debuginfo/mod.rs | 14 | ||||
| -rw-r--r-- | src/driver/aot.rs | 14 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 2ba012a77b0..4cb556844b7 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -20,6 +20,14 @@ use indexmap::IndexSet; pub(crate) use emit::{DebugReloc, DebugRelocName}; pub(crate) use unwind::UnwindContext; +pub(crate) fn producer() -> String { + format!( + "cg_clif (rustc {}, cranelift {})", + rustc_interface::util::rustc_version_str().unwrap_or("unknown version"), + cranelift_codegen::VERSION, + ) +} + pub(crate) struct DebugContext { endian: RunTimeEndian, @@ -57,11 +65,7 @@ impl DebugContext { let mut dwarf = DwarfUnit::new(encoding); - let producer = format!( - "cg_clif (rustc {}, cranelift {})", - rustc_interface::util::rustc_version_str().unwrap_or("unknown version"), - cranelift_codegen::VERSION, - ); + let producer = producer(); let comp_dir = tcx .sess .opts diff --git a/src/driver/aot.rs b/src/driver/aot.rs index f873561c171..27cce7c15e1 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -169,10 +169,22 @@ fn emit_cgu( fn emit_module( output_filenames: &OutputFilenames, prof: &SelfProfilerRef, - object: cranelift_object::object::write::Object<'_>, + mut object: cranelift_object::object::write::Object<'_>, kind: ModuleKind, name: String, ) -> Result<CompiledModule, String> { + if object.format() == cranelift_object::object::BinaryFormat::Elf { + let comment_section = object.add_section( + Vec::new(), + b".comment".to_vec(), + cranelift_object::object::SectionKind::OtherString, + ); + let mut producer = vec![0]; + producer.extend(crate::debuginfo::producer().as_bytes()); + producer.push(0); + object.set_section_data(comment_section, producer, 1); + } + let tmp_file = output_filenames.temp_path(OutputType::Object, Some(&name)); let mut file = match File::create(&tmp_file) { Ok(file) => file, |
