From 19b3223a6f793fa53ae7c81b53953a69805e5281 Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Mon, 13 Mar 2023 20:50:54 -0700 Subject: [PATCH] Working on adding gnu note --- .../rustc_codegen_ssa/src/back/metadata.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 4ab56699922f5..213e5ba82f035 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -201,6 +201,25 @@ pub(crate) fn create_object_file(sess: &Session) -> Option elf::ELFOSABI_NONE, }; let abi_version = 0; + + if binary_format == BinaryFormat::Elf{ + if architecture == Architecture::I386 || architecture == Architecture::Arm{ + if let Some(bp) = sess.opts.unstable_opts.branch_protection { + if bp.bti{ + //&sess.target.options.features + // Information it should include Owner, Data size,Description + let name:Vec = b"hello".to_vec();//.new.gnu.property" + let segment:Vec = b"world".to_vec(); + let kind: SectionKind = SectionKind::Note; + let section = file.add_section(segment, name, kind); + let data: &[u8] = b"howdy"; + file.append_section_data(section, data, 1); + () + } + } + } + } + file.flags = FileFlags::Elf { os_abi, abi_version, e_flags }; Some(file) }