From nobody Tue Feb 10 09:22:11 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1900325720; Mon, 9 Feb 2026 08:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626965; cv=none; b=WDQNU/ny5ZWrb1d79pQ1GXutcx5J/kycdQHbVpDEBCzJcHdYvxL/BM+RLedr9fLFrXeJWm31KJF5+fbSWzQeNd1qfAlAyxmQAfmueMr/H09WVESVzwsq6jNZFA67Yzk0CvdfQm9YH5ZYGLQsk/x2uo7i0da2BEaaprHDrQmRnDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626965; c=relaxed/simple; bh=Zd41tmZc5Gk93VJ3R0Ow8lJ7sc7SGaN3xiJWLfZGuEo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ONHMzxxCqZloOJcKECLoWaJi/inXXlWUi+9oxTiB14UCxSUyMmvcLdBW8uKfcqVEirD6LTuWq3ROA7tJx18Amfu6z94KEI1PEkX/XT3d0RDWvB8cWaZw5LYhC8yRE9w2EcFib/zbI88RYpEAlIj9zqrpZqpXr23kruViaKhtjv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=e7kGzWOv; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="e7kGzWOv" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6190RsWA608141; Mon, 9 Feb 2026 08:48:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=QMaUEur+Isf/QckwI RFYY2tM7AcZD+C785AUJtOzoNw=; b=e7kGzWOvZ4/ca9Vy2l6s8809ggCfzmTZq n8P7dDm/og+j8UzRPk3QA4ABf2/oFJ03BACJl3SX2FGJYqUMFPokZy+n21d6PhMm xAWXGUvwYr9i50v0LYMnLtsr8MOW1Swo9XY70e8LEL2Qf7dcCvlOeV/1Lr94jIEV UKZaArMeIU46Z4GAxvcnDOoue5q4JN8Cysh/Wsrvo+iSU14aXvn2WeVTc9k1Q8OH lXBqzC4K1mBNvSZU8eGevVGjpK0H9pt4YqO1Qpkmw2NP6sqfUBIQL2z2Z+WWgAey OKnNicoFWFOCh1J4K16yTz7ruYtQ2V3628cyX9idiFTOmKv8ZvoVQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4c696uvydr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:48:54 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 6198LsKS001420; Mon, 9 Feb 2026 08:48:53 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4c6gqmvewa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:48:53 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6198mndr50397490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Feb 2026 08:48:49 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6BDEE2004E; Mon, 9 Feb 2026 08:48:49 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB4162004B; Mon, 9 Feb 2026 08:48:45 +0000 (GMT) Received: from li-2fa77bcc-2701-11b2-a85c-cd621c23b6bd.in.ibm.com (unknown [9.79.195.233]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Feb 2026 08:48:45 +0000 (GMT) From: Sathvika Vasireddy To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: nathan@kernel.org, masahiroy@kernel.org, kees@kernel.org, naveen@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, npiggin@gmail.com, maddy@linux.ibm.com, segher@kernel.crashing.org, christophe.leroy@csgroup.eu, mingo@kernel.org, mpe@ellerman.id.au, sv@linux.ibm.com, nsc@kernel.org Subject: [RFC PATCH v3 1/6] objtool/powerpc: Add build-time fixup of alternate feature branch targets Date: Mon, 9 Feb 2026 14:18:15 +0530 Message-ID: <20260209084820.57298-2-sv@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209084820.57298-1-sv@linux.ibm.com> References: <20260209084820.57298-1-sv@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: CNM14htUYtoaIZk_O3Vaj2-PdjX2R3mN X-Proofpoint-ORIG-GUID: DkGN-_zHF46_Sn2aNJ4hpd2QSFd3DsX- X-Authority-Analysis: v=2.4 cv=JdWxbEKV c=1 sm=1 tr=0 ts=69899f76 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VwQbUJbxAAAA:8 a=pGLkceISAAAA:8 a=VnNF1IyMAAAA:8 a=5klgpdlFSnDGvnxfnF4A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjA5MDA3MiBTYWx0ZWRfX/Qoql/1mzS7D GE+Mg0QExoWn69fE0wMnl0Qi174OG+VEg8KGM8M8zrsjYw0B55Qi77kdCpRtzl3kiGFPO1U4nwu Z5HYCPNXKfB4JW0hhWMdFO6/ao7g9xDyj6+6S43KOrhjwOs1Xf/u+0Mr1S+IMZnOMlQNeLHaS/8 moDSNldg+KNo81LBZmf5qXoWJfG65FY9UQUoTvXQqcI8XI5G2zXSQNXH9js4ovzW/6eNGY8ZK3z MdukfExeznk0Zk/Xx/0S+PUP37JFipzxzdmxb2Vm8V3rhgedXgGYjgGlQFeN3btYLHC5rvUVcOs sr9+SZjRffNJP31DL7OJt32Ne/QoEiaMp6KWi+DGu8ptI16nJJFkd03+zorq+eXLZP38bNjRDtU dvS2Ll62+noNxzO6xBo75ldJGlvqmlSAULiO1X+2zuG2QKjjMsWqhPKn2I2un4YNPA1XfyfHuuO JtBa7QdApIbv+2VwAlQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-08_05,2026-02-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602090072 Content-Type: text/plain; charset="utf-8" PowerPC __ftr_alt* sections must currently be placed near .text because they lack the executable attribute, preventing the linker from inserting stubs. Branches in the alternate code must reach their targets directly. This can cause build failures as the kernel grows. Fix this by processing alternate feature relocations at build time with objtool. Link with --emit-relocs to preserve relocation information, mark __ftr_alt* sections executable ("ax") so the linker can insert stubs, then use objtool --ftr-fixup to recompute branch offsets based on their runtime locations. objtool already has ELF parsing and instruction patching infrastructure, so this avoids introducing a separate tool as was originally proposed [1]. [1] https://lore.kernel.org/linuxppc-dev/20170521010130.13552-1-npiggin@gma= il.com/ Co-developed-by: Nicholas Piggin Signed-off-by: Nicholas Piggin Signed-off-by: Sathvika Vasireddy --- tools/objtool/arch/powerpc/decode.c | 15 +- tools/objtool/arch/powerpc/special.c | 437 ++++++++++++++++++++++++ tools/objtool/builtin-check.c | 2 + tools/objtool/check.c | 29 +- tools/objtool/elf.c | 1 + tools/objtool/include/objtool/builtin.h | 1 + tools/objtool/include/objtool/special.h | 56 +++ tools/objtool/special.c | 29 ++ 8 files changed, 568 insertions(+), 2 deletions(-) diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/power= pc/decode.c index e534ac1123b3..f6e69d074f28 100644 --- a/tools/objtool/arch/powerpc/decode.c +++ b/tools/objtool/arch/powerpc/decode.c @@ -59,13 +59,26 @@ int arch_decode_instruction(struct objtool_file *file, = const struct section *sec enum insn_type typ; unsigned long imm; u32 ins; + unsigned int aa; =20 ins =3D bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset)); opcode =3D ins >> 26; typ =3D INSN_OTHER; imm =3D 0; + aa =3D ins & 2; =20 switch (opcode) { + case 16: + if (ins & 1) + typ =3D INSN_OTHER; + else + typ =3D INSN_JUMP_CONDITIONAL; + imm =3D ins & 0xfffc; + if (imm & 0x8000) + imm -=3D 0x10000; + insn->immediate =3D imm | aa; + break; + case 18: /* b[l][a] */ if (ins =3D=3D 0x48000005) /* bl .+4 */ typ =3D INSN_OTHER; @@ -77,7 +90,7 @@ int arch_decode_instruction(struct objtool_file *file, co= nst struct section *sec imm =3D ins & 0x3fffffc; if (imm & 0x2000000) imm -=3D 0x4000000; - imm |=3D ins & 2; /* AA flag */ + insn->immediate =3D imm | aa; break; } =20 diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powe= rpc/special.c index 8f9bf61ca089..b837b8d7dfeb 100644 --- a/tools/objtool/arch/powerpc/special.c +++ b/tools/objtool/arch/powerpc/special.c @@ -3,7 +3,17 @@ #include #include #include +#include +#include +#include =20 +struct section *ftr_alt; + +struct fixup_entry *fes; +unsigned int nr_fes; + +uint64_t fe_alt_start =3D -1; +uint64_t fe_alt_end; =20 bool arch_support_alt_relocation(struct special_alt *special_alt, struct instruction *insn, @@ -23,3 +33,430 @@ const char *arch_cpu_feature_name(int feature_number) { return NULL; } + + +int process_alt_data(struct objtool_file *file) +{ + struct section *section; + + section =3D find_section_by_name(file->elf, ".__ftr_alternates.text"); + ftr_alt =3D section; + + if (!ftr_alt) { + WARN(".__ftr_alternates.text section not found\n"); + return -1; + } + + fe_alt_start =3D ftr_alt->sh.sh_addr; + fe_alt_end =3D ftr_alt->sh.sh_addr + ftr_alt->sh.sh_size; + + return 0; + +} + +static int is_le(struct objtool_file *file) +{ + return file->elf->ehdr.e_ident[EI_DATA] =3D=3D ELFDATA2LSB; +} + +static int is_64bit(struct objtool_file *file) +{ + return file->elf->ehdr.e_ident[EI_CLASS] =3D=3D ELFCLASS64; +} + +static uint32_t f32_to_cpu(struct objtool_file *file, uint32_t val) +{ + if (is_le(file)) + return __le32_to_cpu(val); + else + return __be32_to_cpu(val); +} + +static uint64_t f64_to_cpu(struct objtool_file *file, uint64_t val) +{ + if (is_le(file)) + return __le64_to_cpu(val); + else + return __be64_to_cpu(val); +} + +static uint32_t cpu_to_f32(struct objtool_file *file, uint32_t val) +{ + if (is_le(file)) + return __cpu_to_le32(val); + else + return __cpu_to_be32(val); +} + +int process_fixup_entries(struct objtool_file *file) +{ + struct section *sec; + int i; + + for_each_sec(file->elf, sec) { + Elf_Data *data; + unsigned int nr; + + if (strstr(sec->name, "_ftr_fixup") =3D=3D NULL) + continue; + + if (strstr(sec->name, ".rela") !=3D NULL) + continue; + + data =3D sec->data; + if (!data || data->d_size =3D=3D 0) + continue; + + if (is_64bit(file)) + nr =3D data->d_size / sizeof(struct fixup_entry_64); + else + nr =3D data->d_size / sizeof(struct fixup_entry_32); + + for (i =3D 0; i < nr; i++) { + unsigned long idx; + unsigned long long off; + struct fixup_entry *dst; + + if (is_64bit(file)) { + struct fixup_entry_64 *src; + + idx =3D i * sizeof(struct fixup_entry_64); + off =3D sec->sh.sh_addr + data->d_off + idx; + src =3D data->d_buf + idx; + + if (src->alt_start_off =3D=3D src->alt_end_off) + continue; + + fes =3D realloc(fes, (nr_fes + 1) * sizeof(struct fixup_entry)); + dst =3D &fes[nr_fes]; + nr_fes++; + + dst->mask =3D f64_to_cpu(file, src->mask); + dst->value =3D f64_to_cpu(file, src->value); + dst->start_off =3D f64_to_cpu(file, src->start_off) + off; + dst->end_off =3D f64_to_cpu(file, src->end_off) + off; + dst->alt_start_off =3D f64_to_cpu(file, src->alt_start_off) + off; + dst->alt_end_off =3D f64_to_cpu(file, src->alt_end_off) + off; + } else { + struct fixup_entry_32 *src; + + idx =3D i * sizeof(struct fixup_entry_32); + off =3D sec->sh.sh_addr + data->d_off + idx; + src =3D data->d_buf + idx; + + if (src->alt_start_off =3D=3D src->alt_end_off) + continue; + + fes =3D realloc(fes, (nr_fes + 1) * sizeof(struct fixup_entry)); + dst =3D &fes[nr_fes]; + nr_fes++; + + dst->mask =3D f32_to_cpu(file, src->mask); + dst->value =3D f32_to_cpu(file, src->value); + dst->start_off =3D (int32_t)f32_to_cpu(file, src->start_off) + off; + dst->end_off =3D (int32_t)f32_to_cpu(file, src->end_off) + off; + dst->alt_start_off =3D (int32_t)f32_to_cpu(file, + src->alt_start_off) + off; + dst->alt_end_off =3D (int32_t)f32_to_cpu(file, + src->alt_end_off) + off; + } + } + } + return 0; +} + +struct fixup_entry *find_fe_altaddr(uint64_t addr) +{ + unsigned int i; + + if (addr < fe_alt_start) + return NULL; + if (addr >=3D fe_alt_end) + return NULL; + + for (i =3D 0; i < nr_fes; i++) { + if (addr >=3D fes[i].alt_start_off && addr < fes[i].alt_end_off) + return &fes[i]; + } + return NULL; +} + +int set_uncond_branch_target(uint32_t *insn, + const uint64_t addr, uint64_t target) +{ + uint32_t i =3D *insn; + int64_t offset; + + offset =3D target; + if (!(i & BRANCH_ABSOLUTE)) + offset =3D offset - addr; + + /* Check we can represent the target in the instruction format */ + if (offset < -0x2000000 || offset > 0x1fffffc || offset & 0x3) + return -EOVERFLOW; + + /* Mask out the flags and target, so they don't step on each other. */ + *insn =3D 0x48000000 | (i & 0x3) | (offset & 0x03FFFFFC); + + return 0; +} + +int set_cond_branch_target(uint32_t *insn, + const uint64_t addr, uint64_t target) +{ + uint32_t i =3D *insn; + int64_t offset; + + offset =3D target; + + if (!(i & BRANCH_ABSOLUTE)) + offset =3D offset - addr; + + /* Check we can represent the target in the instruction format */ + if (offset < -0x8000 || offset > 0x7FFF || offset & 0x3) + return -EOVERFLOW; + + /* Mask out the flags and target, so they don't step on each other. */ + *insn =3D 0x40000000 | (i & 0x3FF0003) | (offset & 0xFFFC); + + return 0; +} + +void check_and_flatten_fixup_entries(void) +{ + static struct fixup_entry *fe; + unsigned int i; + + i =3D nr_fes; + while (i) { + static struct fixup_entry *parent; + uint64_t nested_off; /* offset from start of parent */ + uint64_t size; + + i--; + fe =3D &fes[i]; + + parent =3D find_fe_altaddr(fe->start_off); + if (!parent) { + parent =3D find_fe_altaddr(fe->end_off); + continue; + } + + size =3D fe->end_off - fe->start_off; + nested_off =3D fe->start_off - parent->alt_start_off; + + fe->start_off =3D parent->start_off + nested_off; + fe->end_off =3D fe->start_off + size; + } +} + + +static struct symbol *find_symbol_at_address_within_section(struct section= *sec, + unsigned long address) +{ + struct symbol *sym; + + sec_for_each_sym(sec, sym) { + if (sym->sym.st_value <=3D address && address < sym->sym.st_value + sym-= >len) + return sym; + } + + return NULL; +} + +static int is_local_symbol(uint8_t st_other) +{ + return (st_other & 0x3) !=3D 0; +} + +static struct symbol *find_symbol_at_address(struct objtool_file *file, + unsigned long address) +{ + struct section *sec; + struct symbol *sym; + + list_for_each_entry(sec, &file->elf->sections, list) { + sym =3D find_symbol_at_address_within_section(sec, address); + if (sym) + return sym; + } + return NULL; +} + +int process_alt_relocations(struct objtool_file *file) +{ + struct section *section; + size_t n =3D 0; + struct reloc *relocation; + struct symbol *sym; + struct fixup_entry *fe; + uint64_t addr; + uint64_t scn_delta; + uint64_t dst_addr; + const char *insn_ptr; + unsigned long target; + struct symbol *symbol; + int is_local; + int j; + uint32_t new_insn; + uint32_t file_insn; + struct instruction decoded_insn =3D {0}; + uint32_t *insn_ptr_raw; + uint32_t insn; + + section =3D find_section_by_name(file->elf, ".rela.__ftr_alternates.text"= ); + if (!section) { + printf(".rela.__ftr_alternates.text section not found.\n"); + return 0; + } + + for (j =3D 0; j < sec_num_entries(section); j++) { + + relocation =3D §ion->relocs[j]; + sym =3D relocation->sym; + addr =3D reloc_offset(relocation); + target =3D sym->sym.st_value + reloc_addend(relocation); + symbol =3D find_symbol_at_address(file, target); + + if (symbol) { + is_local =3D is_local_symbol(symbol->sym.st_other); + if (!is_local) + target =3D target + 0x8; + } + + n++; + fe =3D find_fe_altaddr(addr); + if (!fe) + continue; + + if (target >=3D fe->alt_start_off && target < fe->alt_end_off) + continue; + + if (target >=3D ftr_alt->sh.sh_addr && + target < ftr_alt->sh.sh_addr + ftr_alt->sh.sh_size) + return -1; + + scn_delta =3D addr - ftr_alt->sh.sh_addr; + dst_addr =3D addr - fe->alt_start_off + fe->start_off; + + if (arch_decode_instruction(file, ftr_alt, scn_delta, 4, &decoded_insn) = < 0) + continue; + + insn_ptr_raw =3D (uint32_t *)(ftr_alt->data->d_buf + scn_delta); + if (!insn_ptr_raw || !ftr_alt->data->d_buf) + continue; + + insn =3D f32_to_cpu(file, *insn_ptr_raw); + new_insn =3D insn; + + switch (decoded_insn.type) { + case INSN_JUMP_CONDITIONAL: + if (set_cond_branch_target(&new_insn, dst_addr, target) !=3D 0) + continue; + break; + + case INSN_JUMP_UNCONDITIONAL: + if (set_uncond_branch_target(&new_insn, dst_addr, target) !=3D 0) + continue; + break; + + case INSN_CALL: + if (set_uncond_branch_target(&new_insn, dst_addr, target) !=3D 0) + continue; + break; + default: + continue; + } + + if (new_insn =3D=3D insn) + continue; + + file_insn =3D cpu_to_f32(file, new_insn); + insn_ptr =3D (const char *)&file_insn; + elf_write_insn(file->elf, ftr_alt, scn_delta, sizeof(file_insn), insn_pt= r); + } + return 0; +} + +int process_exception_entries(struct objtool_file *file) +{ + struct section *section; + Elf_Data *data; + unsigned int nr, i; + + section =3D find_section_by_name(file->elf, "__ex_table"); + if (!section) { + printf("__ex_table section not found\n"); + return 0; + } + + data =3D section->data; + if (!data || data->d_size =3D=3D 0) + return 0; + + nr =3D data->d_size / sizeof(struct exception_entry); + + for (i =3D 0; i < nr; i++) { + struct exception_entry *ex; + unsigned long idx; + uint64_t exaddr; + unsigned long long off; + + idx =3D i * sizeof(struct exception_entry); + off =3D section->sh.sh_addr + data->d_off + idx; + ex =3D data->d_buf + idx; + + exaddr =3D off + (int32_t)f32_to_cpu(file, ex->insn); + + if (exaddr < fe_alt_start) + continue; + if (exaddr >=3D fe_alt_end) + continue; + + return -1; + } + return 0; +} + +int process_bug_entries(struct objtool_file *file) +{ + struct section *section; + Elf_Data *data; + unsigned int nr, i; + + section =3D find_section_by_name(file->elf, "__bug_table"); + if (!section) { + printf("__bug_table section not found\n"); + return 0; + } + + data =3D section->data; + if (!data || data->d_size =3D=3D 0) + return 0; + + if (data->d_size % sizeof(struct bug_entry) !=3D 0) + return -1; + + nr =3D data->d_size / sizeof(struct bug_entry); + for (i =3D 0; i < nr; i++) { + struct bug_entry *bug; + unsigned long idx; + uint64_t entry_addr; + uint64_t bugaddr; + int32_t bug_disp; + + idx =3D i * sizeof(struct bug_entry); + entry_addr =3D section->sh.sh_addr + data->d_off + idx; + bug =3D (struct bug_entry *)(data->d_buf + idx); + bug_disp =3D f32_to_cpu(file, bug->bug_addr_disp); + bugaddr =3D entry_addr + bug_disp; + + if (bugaddr < fe_alt_start) + continue; + if (bugaddr >=3D fe_alt_end) + continue; + + return -1; + } + return 0; +} diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index b780df513715..5ee0880baec5 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -78,6 +78,7 @@ static const struct option check_options[] =3D { OPT_STRING_OPTARG('d', "disas", &opts.disas, "function-pattern", "disass= emble functions", "*"), OPT_CALLBACK_OPTARG('h', "hacks", NULL, NULL, "jump_label,noinstr,skylake= ", "patch toolchain bugs/limitations", parse_hacks), OPT_BOOLEAN('i', "ibt", &opts.ibt, "validate and annotate IBT"), + OPT_BOOLEAN('f', "ftr-fixup", &opts.ftr_fixup, "feature fixup"), OPT_BOOLEAN('m', "mcount", &opts.mcount, "annotate mcount/fentry calls f= or ftrace"), OPT_BOOLEAN(0, "noabs", &opts.noabs, "reject absolute references in all= ocatable sections"), OPT_BOOLEAN('n', "noinstr", &opts.noinstr, "validate noinstr rules"), @@ -181,6 +182,7 @@ static bool opts_valid(void) opts.disas || opts.hack_jump_label || opts.hack_noinstr || + opts.ftr_fixup || opts.ibt || opts.mcount || opts.noabs || diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 3f7999317f4d..667d95431793 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1594,9 +1594,11 @@ static int add_jump_destinations(struct objtool_file= *file) dest_off =3D=3D func->offset + func->len) continue; =20 + ERROR_INSN(insn, "can't find jump dest instruction at %s", - offstr(dest_sec, dest_off)); + offstr(dest_sec, dest_off)); return -1; + } =20 if (!dest_sym || is_sec_sym(dest_sym)) { @@ -4966,6 +4968,31 @@ int check(struct objtool_file *file) if (!nr_insns) goto out; =20 + if (opts.ftr_fixup) { + ret =3D process_alt_data(file); + if (ret < 0) + return ret; + + ret =3D process_fixup_entries(file); + if (ret < 0) + return ret; + + check_and_flatten_fixup_entries(); + + ret =3D process_exception_entries(file); + if (ret < 0) + return ret; + + ret =3D process_bug_entries(file); + if (ret < 0) + return ret; + + ret =3D process_alt_relocations(file); + if (ret < 0) + return ret; + } + + if (opts.retpoline) warnings +=3D validate_retpoline(file); =20 diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 6a8ed9c62323..94370a470cbb 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -1158,6 +1158,7 @@ struct elf *elf_open_read(const char *name, int flags) cmd =3D ELF_C_WRITE; =20 elf->elf =3D elf_begin(elf->fd, cmd, NULL); + if (!elf->elf) { ERROR_ELF("elf_begin"); goto err; diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/includ= e/objtool/builtin.h index b9e229ed4dc0..3578ec174a59 100644 --- a/tools/objtool/include/objtool/builtin.h +++ b/tools/objtool/include/objtool/builtin.h @@ -13,6 +13,7 @@ struct opts { bool checksum; bool dump_orc; bool hack_jump_label; + bool ftr_fixup; bool hack_noinstr; bool hack_skylake; bool ibt; diff --git a/tools/objtool/include/objtool/special.h b/tools/objtool/includ= e/objtool/special.h index 121c3761899c..0a5efbfa29d0 100644 --- a/tools/objtool/include/objtool/special.h +++ b/tools/objtool/include/objtool/special.h @@ -12,6 +12,41 @@ =20 #define C_JUMP_TABLE_SECTION ".data.rel.ro.c_jump_table" =20 +#define BRANCH_SET_LINK 0x1 +#define BRANCH_ABSOLUTE 0x2 + +struct bug_entry { + int32_t bug_addr_disp; + int32_t file_disp; + uint16_t line; + uint16_t flags; +}; + +struct exception_entry { + int32_t insn; + int32_t fixup; +}; + +struct fixup_entry_64 { + uint64_t mask; + uint64_t value; + uint64_t start_off; + uint64_t end_off; + uint64_t alt_start_off; + uint64_t alt_end_off; +}; + +#define fixup_entry fixup_entry_64 + +struct fixup_entry_32 { + uint32_t mask; + uint32_t value; + uint32_t start_off; + uint32_t end_off; + uint32_t alt_start_off; + uint32_t alt_end_off; +}; + struct special_alt { struct list_head list; =20 @@ -28,6 +63,8 @@ struct special_alt { unsigned int orig_len, new_len, feature; /* group only */ }; =20 +int process_alt_data(struct objtool_file *file); + int special_get_alts(struct elf *elf, struct list_head *alts); =20 void arch_handle_alternative(struct special_alt *alt); @@ -40,4 +77,23 @@ struct reloc *arch_find_switch_table(struct objtool_file= *file, unsigned long *table_size); const char *arch_cpu_feature_name(int feature_number); =20 +int process_fixup_entries(struct objtool_file *file); + +void check_and_flatten_fixup_entries(void); + +int process_exception_entries(struct objtool_file *file); + +int process_bug_entries(struct objtool_file *file); + +int process_alt_relocations(struct objtool_file *file); + +struct fixup_entry *find_fe_altaddr(uint64_t addr); + +int set_uncond_branch_target(uint32_t *insn, + const uint64_t addr, uint64_t target); + +int set_cond_branch_target(uint32_t *insn, + const uint64_t addr, uint64_t target); + + #endif /* _SPECIAL_H */ diff --git a/tools/objtool/special.c b/tools/objtool/special.c index 2a533afbc69a..43b60bf789dd 100644 --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -167,3 +167,32 @@ int special_get_alts(struct elf *elf, struct list_head= *alts) =20 return 0; } + +int __weak process_alt_data(struct objtool_file *file) +{ + return 0; +} + +int __weak process_fixup_entries(struct objtool_file *file) +{ + return 0; +} + +void __weak check_and_flatten_fixup_entries(void) +{ +} + +int __weak process_exception_entries(struct objtool_file *file) +{ + return 0; +} + +int __weak process_bug_entries(struct objtool_file *file) +{ + return 0; +} + +int __weak process_alt_relocations(struct objtool_file *file) +{ + return 0; +} --=20 2.43.0 From nobody Tue Feb 10 09:22:11 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A187E32571F; Mon, 9 Feb 2026 08:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626965; cv=none; b=n8IoFKUho0Y5wZ7v+Gsu2dtdOblIRk/3KKNH7BuIPWoa+52ptETu0HVMMY1fORxD0OCCHuHKP3MJsayelLYgzfSCBoWC2Gyr7bHXgXBoDybt9XaqRcv+zWJduDrjn10RL8K9Gz+3KoWu+Bb06hHdjjWQ75ydQz13y7feuVYWaFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626965; c=relaxed/simple; bh=Gj1a9EyQR16Fric/kz+4z6lDEBgbAmqodcIhTi7k+EE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l5QTQdNKlUHJ/hqizJmuPNTd/nnnnfsUMWp6cFar9OGijDYGEZw41aolzTLGIRFTe5nG/HlYfz80De1d9m5jWeSvGWeoUUz1mHJYR8srAhthaLY1bIQLS/Ah/Ncc5KCN1mW1VwBBWcKRmZudFSrlg3CxvsPvumPiHFDsP7Ri9c8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=pMUhXotN; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="pMUhXotN" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 618BvvYF3433326; Mon, 9 Feb 2026 08:48:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=Vx7hbLDugiI3L3ECk ZfvUG8sfxKhjD8t7xBTjwQ9vfA=; b=pMUhXotNE6QWIuJicnNQcIKepYc3H2K5n 7wD2OZ/mEVRO56fkHFgL5oLYfFWGpd7y4VZOiJSS5xcjFg7AJ2XDGB9PTBo06Juj eis9Towvz9T0GDCobTHLVGYpmuBw2CfU8VQYBe83Axf93Thaf/uU+Ypde7XBmq5X nwwd89B9rECFVTkqOeSv0O4Z9wpkws9bG9uI75aZzHYdITxp9hZNebL0LjxBkT0z gr2kWFUtdqMXWqMS3A7RZVoZ32P7li9Ky1D74X9+p9I2eI9dEEOPt9CPCqkyINkz JKrDEwY6kWnfHu/iHomDbPZy+DM3vuomIe/O6zAG2uhY51F+jbr7g== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4c696uvye4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:48:59 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 6197N6Lo002575; Mon, 9 Feb 2026 08:48:58 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4c6fqsckyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:48:58 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6198msjm50266568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Feb 2026 08:48:54 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02CDA2004E; Mon, 9 Feb 2026 08:48:54 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 449532004D; Mon, 9 Feb 2026 08:48:50 +0000 (GMT) Received: from li-2fa77bcc-2701-11b2-a85c-cd621c23b6bd.in.ibm.com (unknown [9.79.195.233]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Feb 2026 08:48:50 +0000 (GMT) From: Sathvika Vasireddy To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: nathan@kernel.org, masahiroy@kernel.org, kees@kernel.org, naveen@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, npiggin@gmail.com, maddy@linux.ibm.com, segher@kernel.crashing.org, christophe.leroy@csgroup.eu, mingo@kernel.org, mpe@ellerman.id.au, sv@linux.ibm.com, nsc@kernel.org Subject: [RFC PATCH v3 2/6] objtool: Set ELF_F_LAYOUT flag to preserve vmlinux segment layout Date: Mon, 9 Feb 2026 14:18:16 +0530 Message-ID: <20260209084820.57298-3-sv@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209084820.57298-1-sv@linux.ibm.com> References: <20260209084820.57298-1-sv@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: Mf87jfHInFbk69MapXEC8CeS9cKIVSeh X-Proofpoint-ORIG-GUID: -apIo1t-HJUBbk6XG9wBOjLD7VpqBG94 X-Authority-Analysis: v=2.4 cv=JdWxbEKV c=1 sm=1 tr=0 ts=69899f7b cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=dGyo4u3eiptz4-Zsc8UA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjA5MDA3MiBTYWx0ZWRfX/knWIYESMxKs 0bei1RzS8Bs2yVrwie3PjynjnciDD49G0Hw5Pt1tZWp4WY7hWYwZRKHGetdR/NsLBmnL7rsjbnj KTM+N+R2ZZ06/Vl/CLlXtAzWmkpqj+dtil7dpdYMKVk7z1DM6tm/p2AbLnVemc2pS2xv65rn45h 9yrsHNpuhQ6jxa1NVo4t+zyIt8grbiwR1CXVSz7NeSMgKS1+MheCY57rkoClZzHeJ7FGF7iCG8r 3fwTxrqfy0h5nTxZCjY8tyh9X9c/idCS4LVUW/l9VHpISBVNx5eVISjxR7rYLV4kQZLg+R/SIE/ zCc8Nd5VVEYmS4gaQirv1zh+oZ5h81TNXwmT8cy78R/pHsg1yoFW7PdKbKWKEj6JU9hxVMUVSFU EsUQ3ho/wMnGR92QgQFgRY59p/8xvtq7BkDwXS52tDfM8jwgs0VzknJ4/JpH7iCg89Ijevc0XSS 5uJaprYpErs+5N6eb0g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-08_05,2026-02-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602090072 Content-Type: text/plain; charset="utf-8" When objtool writes changes back to vmlinux with --ftr-fixup --link, libelf recalculates the file layout and inserts padding between sections. This corrupts the ELF segment structure, causing kexec to fail with: ELF Note corrupted ! Cannot determine the file type of vmlinux This happens because libelf's default behavior assumes it can freely rearrange section offsets when writing, which breaks the carefully constructed vmlinux layout produced by the linker. Set ELF_F_LAYOUT after elf_begin() to instruct libelf that the application is responsible for the file layout. This prevents libelf from inserting padding or repositioning sections while still allowing data modifications to be written back. Signed-off-by: Sathvika Vasireddy --- tools/objtool/elf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 94370a470cbb..f7c6fd68ffcb 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -1159,6 +1159,9 @@ struct elf *elf_open_read(const char *name, int flags) =20 elf->elf =3D elf_begin(elf->fd, cmd, NULL); =20 + if (opts.ftr_fixup) + elf_flagelf(elf->elf, ELF_C_SET, ELF_F_LAYOUT); + if (!elf->elf) { ERROR_ELF("elf_begin"); goto err; --=20 2.43.0 From nobody Tue Feb 10 09:22:11 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E421B325739; Mon, 9 Feb 2026 08:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626968; cv=none; b=rCRV8sAugloEP9hUpiPsLyD4SlyJfevJwVYLBf1z/F2y8B42upU6DE6mAwmuKYs1cLW39CuwlV/htPnlR/GZO9MXRPvBsJdxq2axPrZ/uwyq2vBKUUnIbpQbvYyaEaqBm0H3yesEOO0brCFbTma6HjNDgRT1N+NEOxMNZlYpTOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626968; c=relaxed/simple; bh=EK0kl/a1X7J0JjHj++vnoGQyx+UTLm/vBmGL7BYB6fg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z8ZZ6kPwakizA5SkK1rpPFNjhfvSOHa9UL7xRl3RS1bF/1bGTF/QUexswmI86PVIu0Mkh2I0JwjFpfHCTVcHrHwtaq2qFBwhyVxyvEhh6bjoEp3p+5gpcmM+fItutPyFOCP5dhuY4U3OEkrtfhzUm4/1GL8xqmetP2tj7+wFc54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=UjmE4si6; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="UjmE4si6" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 618LtJwu331321; Mon, 9 Feb 2026 08:49:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=mdZpntruiqLsnnXGW S5ds3iTzhGltfz08W0xIBP0Nis=; b=UjmE4si6ptdCGowetvoQvw1lR2DXJVSol xqMJSTwQVyLe6yBnvGw5kUg6IZdMvpoDOqj6F5rGMeN+G1J36j+rTIEEf15IuHki VavkbtG4UxeNUCMQuJBm/rQ7gVpfNVCrvpCtk9XeNRhPYwPJnUkcXKw9RgPW7dr7 nxeSiNiVxH8e2E1nny2aRrLG/95kvkBZdy5XSKxJF4cmBH/oeqM2A9l8h7hNwOGG rIblDImAYJrT9NUKp5HXB0cb8UNlnnuzT/YhKtDwApmBqtSYPygpLZtULyVS/sBI 35UJ/++zNkEshykaQYR5fmHg8BwGkd0hVhWHK+wyBcdAZBH8EJhaw== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4c696uvyee-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:03 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 6194oHie001825; Mon, 9 Feb 2026 08:49:02 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4c6je1v5kx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:02 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6198mwWX28967506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Feb 2026 08:48:58 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF56220040; Mon, 9 Feb 2026 08:48:58 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E2AAF2004D; Mon, 9 Feb 2026 08:48:54 +0000 (GMT) Received: from li-2fa77bcc-2701-11b2-a85c-cd621c23b6bd.in.ibm.com (unknown [9.79.195.233]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Feb 2026 08:48:54 +0000 (GMT) From: Sathvika Vasireddy To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: nathan@kernel.org, masahiroy@kernel.org, kees@kernel.org, naveen@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, npiggin@gmail.com, maddy@linux.ibm.com, segher@kernel.crashing.org, christophe.leroy@csgroup.eu, mingo@kernel.org, mpe@ellerman.id.au, sv@linux.ibm.com, nsc@kernel.org Subject: [RFC PATCH v3 3/6] objtool: Fix "can't find starting instruction" warnings on vmlinux Date: Mon, 9 Feb 2026 14:18:17 +0530 Message-ID: <20260209084820.57298-4-sv@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209084820.57298-1-sv@linux.ibm.com> References: <20260209084820.57298-1-sv@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: 1TPwQzylPSvBZ7eiikEEW4WWFGapK_b2 X-Proofpoint-ORIG-GUID: qqryV2YEGOyoLgrM3ibQWZzp4u3dBsrU X-Authority-Analysis: v=2.4 cv=JdWxbEKV c=1 sm=1 tr=0 ts=69899f7f cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=7w6QjbFeSYXBFb6lQ1YA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjA5MDA3MiBTYWx0ZWRfXymowdVw2GDQG O0mtY8q6Wb9N/x71F23493QWqd4SqoRc28duIC3MHZGIRZD5t+z+qPbxds5IFrsnZ6Qmfd1PiQP lCaP0YdJC9TuvPIwq7eRg5O1z/T2RTlcKc+M5sV/dAG7aktkO6z0GvLrj1lXmUkCNLer4Dl9RIe vumxk2Bu0QsrEPfeGb94BrWam3XYAMB8WnLBV9/TLLH/kgBOaRBkFWFCt47t8+3Yq9D3+9NkFVS 35bZlC616cbPvvNEXwkHMncpjPYfGy6UqmSj4dUpAlQaQV8WolmCV/ciM6ujFwxaOhnzUSYfytH 6h/RM0Vl+DZS0oHZQKFcbA8dgKok0uNdpctUvTglu5oBfC0VoI/TN72kJHCoOdpu+1gmlqCxnji lZoCmRJS2S/GefWlNlKJMi7ZsQT/r9iaj8mFJdrMAs0fTwBmYE9za24VobBL8q9TI54HnOyFIxP 1pWa+EELaoh6hfvfeEQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-08_05,2026-02-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602090072 Content-Type: text/plain; charset="utf-8" Objtool throws a lot of can't find starting instruction warnings when run on vmlinux with --ftr-fixup option. These warnings are seen because find_insn() function looks for instructions at offsets that are relative to the start of the section. In case of individual object files (.o), there are no can't find starting instruction warnings seen because the actual offset associated with an instruction is itself a relative offset since the sections start at offset 0x0. However, in case of vmlinux, find_insn() function fails to find instructions at the actual offset associated with an instruction since the sections in vmlinux do not start at offset 0x0. Due to this, find_insn() will look for absolute offset and not the relative offset. This is resulting in a lot of can't find starting instruction warnings when objtool is run on vmlinux. To fix this, pass offset that is relative to the start of the section to find_insn(). find_insn() is also looking for symbols of size 0. But, objtool does not store empty STT_NOTYPE symbols in the rbtree. Due to this, for empty symbols, objtool is throwing can't find starting instruction warnings. Fix this by ignoring symbols that are of size 0 since objtool does not add them to the rbtree. Signed-off-by: Sathvika Vasireddy --- tools/objtool/check.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 667d95431793..92fe5dc05cdb 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -492,7 +492,11 @@ static int decode_instructions(struct objtool_file *fi= le) if (func->embedded_insn || func->alias !=3D func) continue; =20 - if (!find_insn(file, sec, func->offset)) { + if (func->len =3D=3D 0) + continue; + + if (!find_insn(file, sec, opts.ftr_fixup ? + func->offset - sec->sym->offset : func->offset)) { ERROR("%s(): can't find starting instruction", func->name); return -1; } --=20 2.43.0 From nobody Tue Feb 10 09:22:11 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA73C3242C8; Mon, 9 Feb 2026 08:49:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626966; cv=none; b=bov6ijNytX7G6/WtY+XPy8jKFCn4RpGpu6DzVb9To1kGeG7KTerBlytnG8tU9pYnfDoWBWWD7yjZm6bII5VfWM1jc6eKPr3j1cE6wnlL4V+OmHmifDJUtzsmoKhrEfFAyUaW+xb+weXPyKKLZo1RVTI6oJGlHxNmCEqBuC7QXcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626966; c=relaxed/simple; bh=b33lM7g4Mtd91TjJ9IVGi+uv5ciyNzrA4fTzxhiPqrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l/LlG/tkv0SbPs2d4NA5wjbdbZqTf2s+gKPHli2t0kbMUoFQ+b3hcEUYMmX/0ypzGKOPut7mKKcPCMyA3BqG4vyrGil9YvE37wRpULeXQgRWwn984HtG7EYIF9AXkDHHevxd3kvTdBFJjBrim/ZS6f/Qyy0sRljmPC4ov9dSSfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=qWztqHfi; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="qWztqHfi" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6191c5ap693544; Mon, 9 Feb 2026 08:49:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=6pTFAo/qNgU6OYUJN OjZ00Qdyl2NOyAzAlaEd2uhLNU=; b=qWztqHfiEpwpI4HhhBtIrDr9C4e4Xgl4V fdZ9VoSH4f0dvsgwDRqrWOvwxMgawnbPoMCl1p1jW7hl+GXF/dfTGssF6pb0e+xW QmYk7I3xL7pPR1VUkQotJYBa+uFzfIga3iuYFZv+wbSsS8v3r8G8D9T5i0OrEw++ iSi/vviq1naoLblYvlbOVcxIQB4Y3ODadmp3/bNELFgBLVFOXSAQzjrE2oyQBRfL sfCCN+ymmPzWaM6wOtGGBYJVGD+jUAwAUJA+BiYfaZvbmBeBK82oaSLJHO0iurwY 9bDbHbfVX8Ck7KHA8ur/oY38XgoVOLc4AWdrg8oi1mHLVfhp+1Now== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4c696vx67m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:08 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 6194I9X6019336; Mon, 9 Feb 2026 08:49:07 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4c6hxjv84b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:07 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6198n39Q53543224 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Feb 2026 08:49:03 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7634D20040; Mon, 9 Feb 2026 08:49:03 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B48A22004D; Mon, 9 Feb 2026 08:48:59 +0000 (GMT) Received: from li-2fa77bcc-2701-11b2-a85c-cd621c23b6bd.in.ibm.com (unknown [9.79.195.233]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Feb 2026 08:48:59 +0000 (GMT) From: Sathvika Vasireddy To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: nathan@kernel.org, masahiroy@kernel.org, kees@kernel.org, naveen@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, npiggin@gmail.com, maddy@linux.ibm.com, segher@kernel.crashing.org, christophe.leroy@csgroup.eu, mingo@kernel.org, mpe@ellerman.id.au, sv@linux.ibm.com, nsc@kernel.org Subject: [RFC PATCH v3 4/6] objtool/powerpc: Skip jump destination analysis and unnanotated intra-function call warnings for --ftr-fixup Date: Mon, 9 Feb 2026 14:18:18 +0530 Message-ID: <20260209084820.57298-5-sv@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209084820.57298-1-sv@linux.ibm.com> References: <20260209084820.57298-1-sv@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=YeCwJgRf c=1 sm=1 tr=0 ts=69899f84 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=8-sZ6GPjQPUUxCpKAYwA:9 X-Proofpoint-GUID: qDkfc-DJNCXacmFDikyxmhcNuGda5RJQ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjA5MDA3MiBTYWx0ZWRfX+Ld5l8kAw2q7 7eUbqIrsR7xEkqth1IaLV4St1LEvU4oZQY7P3puTEAJUrxEsm5TbXzxcF7NJWN2rKsBLyeq+B0R 1TW9aiAkkXUfspi9BNa8UQTPSpvwSZ1qMgj+bxfyYWzosqHKnGXhaRllDGsWsmGPy0hTcMWn0kD OMsJsaGSG7E306m/OPY2/wf37N2n2mZVuHX/W4g3WG3o88Nzq2Q0Q578iRSJPfEal5IjeEGP+So WTugZr9Kz3QHYiAeheCOaWn6Zpwt3cIhitEPcIffMgH9wy7/Sl0a4WBZt4nFev8qnlUbLZphDkP /zEQquIVSRwkKkOwshRCRDUu0oBkP/URk7Ww+dKot5wHD1a9y2MWpFqlxcBXQqnI0uHL79/gny0 Cuwl7CY6fX0E8bCHbUO0YwzUxdxEqQO0j6Txvm67YG8F0q4SLs0s05myS8rIi+9VQZ83g+rIz2U 7ysMbEiPKgfKe2i3zQg== X-Proofpoint-ORIG-GUID: hlklK367W2znF8mxiCFFgnhIl6K75Mtr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-08_05,2026-02-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602090072 Content-Type: text/plain; charset="utf-8" Objtool is throwing unannotated intra-function call warnings when run on vmlinux with --ftr-fixup option. One such example: vmlinux: warning: objtool: .text+0x3d94: unannotated intra-function call .text + 0x3d94 =3D c000000000008000 + 3d94 =3D c0000000000081d4 c0000000000081d4: 45 24 02 48 bl c00000000002a618 c00000000002a610 : c00000000002a610: 0e 01 4c 3c addis r2,r12,270 c00000000002a610: R_PPC64_REL16_HA .TOC. c00000000002a614: f0 6c 42 38 addi r2,r2,27888 c00000000002a614: R_PPC64_REL16_LO .TOC.+0x4 c00000000002a618: a6 02 08 7c mflr r0 This is happening because we should be looking for destination symbols that are at absolute offsets instead of relative offsets. After fixing dest_off to point to absolute offset, there are still a lot of these warnings shown. In the above example, objtool is computing the destination offset to be c00000000002a618, which points to a completely different instruction. find_call_destination() is looking for this offset and failing. Instead, we should be looking for destination offset c00000000002a610 which points to system_reset_exception function. Even after fixing the way destination offset is computed, and after looking for dest_off - 0x8 in cases where the original offset is not found, there are still a lot of unannotated intra-function call warnings generated. This is due to symbols that are not properly annotated. So, for now, as a hack to curb these warnings, do not emit unannotated intra-function call warnings when objtool is run with --ftr-fixup option. Skip add_jump_destinations() and suppress intra-function call errors in --ftr-fixup mode. The feature fixup pass only needs fixup entry tables, relocation entries from .__ftr_alternates.text, and elf_write_insn() to patch branch offsets. Signed-off-by: Sathvika Vasireddy --- tools/objtool/check.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 92fe5dc05cdb..9c6b892792a4 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1598,7 +1598,6 @@ static int add_jump_destinations(struct objtool_file = *file) dest_off =3D=3D func->offset + func->len) continue; =20 - ERROR_INSN(insn, "can't find jump dest instruction at %s", offstr(dest_sec, dest_off)); return -1; @@ -1680,7 +1679,7 @@ static int add_call_destinations(struct objtool_file = *file) if (func && func->ignore) continue; =20 - if (!insn_call_dest(insn)) { + if (!insn_call_dest(insn) && !opts.ftr_fixup) { ERROR_INSN(insn, "unannotated intra-function call"); return -1; } @@ -2636,8 +2635,10 @@ static int decode_sections(struct objtool_file *file) return -1; } =20 - if (add_jump_destinations(file)) - return -1; + if (!opts.ftr_fixup) { + if (add_jump_destinations(file)) + return -1; + } =20 /* * Must be before add_call_destination(); it changes INSN_CALL to --=20 2.43.0 From nobody Tue Feb 10 09:22:11 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 608F8242D91; Mon, 9 Feb 2026 08:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626977; cv=none; b=WBYtpLJ1afZAXYSlBoJ0w7kMMAkjJTcyYXuslp+yddGFTAHTYoI3x3sDKHNzwUYEb09aiudWBYTJ7ToF95WlSCTVHXP5OK9bNavh1nAfGVEp5u4j6FV2tEkDnkxq5iBHzt7D6a0FFIbKqyL5sQ7jJFP42jsUzgvuIWxrqBlrdZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626977; c=relaxed/simple; bh=Hv5jUJFaXmzYU18r7OqWPPwpKPgM5W+QF3X41Rv2DR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mdEGor+uTvpS7AaoexLS+4pScn32KSBK6ysB6ZHC/reqg5WURNxuKU1aDdHMz1vUR4yLWyXqeUZs7KBslk9/DmH2PXiln8VNKACnm6MqSiAydf+f8YixXOPbNWAqMcMtgi2euPMZyadCGE0/dccrYOpwvBynOFSbLI7Sd91l4hs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=pvpQuTRR; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="pvpQuTRR" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 618M1PSE273774; Mon, 9 Feb 2026 08:49:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=38Cy3VPgoePz1oJWZ c6WvA3VIYIivfKiwwD0CxG02Xk=; b=pvpQuTRRd+LmPPhJPLWnBp6t1UBTnMG+g Osay2LNhfPYMfXSwS2aTSR5Ts1EgpnEB1Ee7wTkyHMa0IRDjRADRcqfdrzhs3Fmu KB71jch5cWVkktewuwh2QIZshAJdzvD99Zu/0G+jc9djnuJXdLNb7OYvzM35r8+K NL8naMwINT/JmbrYNh+ESnSihZdKXsa7qmDk1RV3q7yq/o9Z4KfWDny7fHJZX0dR d9PJcfd8X6CO8bkvk5Jh0HbTa59w/ohzTENdX0SDMg52imScHIqk/84h0BFaQh4l nL11cA+ZEqkYW2PN0jZEzbYvw50B2w47DYHZLakTW6Rq93pagRMNQ== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4c696wn11q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:13 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 6197iBNQ008400; Mon, 9 Feb 2026 08:49:13 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4c6g3y4huc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:12 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6198n9NO54985006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Feb 2026 08:49:09 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F12620040; Mon, 9 Feb 2026 08:49:09 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41CB52004F; Mon, 9 Feb 2026 08:49:05 +0000 (GMT) Received: from li-2fa77bcc-2701-11b2-a85c-cd621c23b6bd.in.ibm.com (unknown [9.79.195.233]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Feb 2026 08:49:04 +0000 (GMT) From: Sathvika Vasireddy To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: nathan@kernel.org, masahiroy@kernel.org, kees@kernel.org, naveen@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, npiggin@gmail.com, maddy@linux.ibm.com, segher@kernel.crashing.org, christophe.leroy@csgroup.eu, mingo@kernel.org, mpe@ellerman.id.au, sv@linux.ibm.com, nsc@kernel.org Subject: [RFC PATCH v3 5/6] kbuild: Add objtool integration for PowerPC feature fixups Date: Mon, 9 Feb 2026 14:18:19 +0530 Message-ID: <20260209084820.57298-6-sv@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209084820.57298-1-sv@linux.ibm.com> References: <20260209084820.57298-1-sv@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=WZYBqkhX c=1 sm=1 tr=0 ts=69899f8a cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=k1iL6ZPSiERSBASioQUA:9 X-Proofpoint-GUID: uVcMjmtKjsaSvQs3MGuI7QjMy73l8yht X-Proofpoint-ORIG-GUID: DEEqSo1YnZxzP6Yi2-XP2hSe4Iz0uifA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjA5MDA3MiBTYWx0ZWRfXwmpnDxhhXaBt HMyiiVnLS48ueiaU3FJWjNPMZRban1SPWQyY6ozE7mRhpCH/ITbMb/QW6qxDbuJMUqtbKU794OV KkA62PuC+/4L6Cvkf0Mtv2Aan1S4rTG1ylr9blDKTSRUHhAocZfkWMZq0s9ByVubj8i6d7tiYXF Lb36xyowO8x/xIWLIGNVEIfJ30xc6ujMYxOj52SRTIhz8qeKrGtWkTOqoD/2NSdU9KgLOT5Tosq q8jMVPHC7VGIQAopnFzK2/iR/gMLaBapCN6xzihouTmLbSIQUDV4zUhMtlB2o7brfRCJgCUE2Tf Nr7ClsN9DLiVR6CUWdwXNpczBaCdjDIgw81zXsbvPUMgi7b/dZz3S/WrJFNy2iwDts/2dpSO45/ hxiTSWd+VoB8nn7XaTBl6ISP9B3fnMYkaPgjdqF6E13jddxl8F2L+560NLnfBWEblfnevq4q0hz icBCyKJ9htDxTyDA3eg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-08_05,2026-02-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602090072 Content-Type: text/plain; charset="utf-8" Add build system support for PowerPC feature fixup processing: - Add HAVE_OBJTOOL_FTR_FIXUP config option for architectures that support build-time feature fixup processing - Integrate objtool feature fixup processing into vmlinux build Suggested-by: Masahiro Yamada Signed-off-by: Sathvika Vasireddy --- Makefile | 7 +++++++ scripts/Makefile.lib | 4 ++-- scripts/Makefile.vmlinux | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 665b79aa21b8..383e35b39a15 100644 --- a/Makefile +++ b/Makefile @@ -1451,6 +1451,13 @@ ifdef CONFIG_OBJTOOL prepare: tools/objtool endif =20 +# CONFIG_OBJTOOL and CONFIG_HAVE_OBJTOOL_FTR_FIXUP are unrelated, separate +# options. It was integrated in objtool in order to borrow the elf parser, +# but this is different from how the other objtool commands are used. +ifdef CONFIG_HAVE_OBJTOOL_FTR_FIXUP +prepare: tools/objtool +endif + ifdef CONFIG_BPF ifdef CONFIG_DEBUG_INFO_BTF prepare: tools/bpf/resolve_btfids diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 28a1c08e3b22..dc090b11bdf2 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -169,10 +169,10 @@ cpp_flags =3D -Wp,-MMD,$(depfile) $(NOSTDINC_FLA= GS) $(LINUXINCLUDE) \ =20 ld_flags =3D $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) =20 -ifdef CONFIG_OBJTOOL - objtool :=3D $(objtree)/tools/objtool/objtool =20 +ifdef CONFIG_OBJTOOL + objtool-args-$(CONFIG_HAVE_JUMP_LABEL_HACK) +=3D --hacks=3Djump_label objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) +=3D --hacks=3Dnoinstr objtool-args-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) +=3D --hacks=3Dskyla= ke diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index cd788cac9d91..e3dd7fc62f20 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -65,7 +65,8 @@ ARCH_POSTLINK :=3D $(wildcard $(srctree)/arch/$(SRCARCH)/= Makefile.postlink) # Final link of vmlinux with optional arch pass after final link cmd_link_vmlinux =3D \ $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ - $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) + $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true); \ + $(if $(CONFIG_HAVE_OBJTOOL_FTR_FIXUP), $(objtool) --ftr-fixup --link $@, = true) =20 targets +=3D vmlinux.unstripped .vmlinux.export.o vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o .vmlinux.export.o $(= KBUILD_LDS) FORCE --=20 2.43.0 From nobody Tue Feb 10 09:22:11 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EC402DC77E; Mon, 9 Feb 2026 08:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626982; cv=none; b=CYskoenMyceQxItBNdnSKOTs5ysCoodbKNesrDnRUj69encrfyCq0svuuVqWFloqgAh24T9ErGynStbZG3QsGmAbmK6/tkwd45O/kHJMttcSRahAMAfIMAaFEIGycHnr3Awbb1cgsk9okM27aRDJPEzKEmXghpgZ2ECuFoA+2HI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770626982; c=relaxed/simple; bh=3IuTcTExlcru3YTsk+SAa46ZIl8gDT/yEaK1io4hJcQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mtQI5InLiTqedQnUjIUh3rtAWi94Nn4+hnEb8J92DLtOnSiBDcxmSB8Q1a4kbujmaM5d8bSDePzSSV5FnKJhpHnuXqjpr7gpwer6tFUntumZBLFgCKTF2aU9Nm6uPml8APU0G+QiQk81JFSS1O9dNC7YzS3s0cmXz23GhKILbpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=fF1AoKqL; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="fF1AoKqL" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 618MsFKb369791; Mon, 9 Feb 2026 08:49:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=swzmicMpwiMbx8mDS bwNndtctxSKq8Ub8sOhW5HI1og=; b=fF1AoKqLfdckc6vWgvjkz+PHgASRx8aRT kq7waiXEZ3Fm+TipOyUA9tnie5ar1mRydD+O2H6D7ugu7a+lDTfrRs0jq6PD1MA6 FltUBiKh0gWkGZhctJolKtuxhFBdt9w88ZrYxO0hAKURpw0XNV1yGwv6ylMHazuw K+8NWNkxEpNyuKZLZI4DhTOMXzuTEhChNIDh7Y0Zc0HfCZ6htnR0uoHyMCdgMx2v BPuQZ/yFE4r3T8fToa50w2tQU2sSlvLmbI4X4DNej6RmkHUdIWEhrOE4DnaLG/uU WSpses+2nSPa4jveyXFFiO71aP6tkV4hoJFCpA1XluCUmiLcQ4q6w== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4c696wn121-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:19 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 6193F7Ef012996; Mon, 9 Feb 2026 08:49:19 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4c6h7k4bc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Feb 2026 08:49:19 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6198nE9129557040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Feb 2026 08:49:14 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 159FA2005A; Mon, 9 Feb 2026 08:49:14 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DEB320043; Mon, 9 Feb 2026 08:49:10 +0000 (GMT) Received: from li-2fa77bcc-2701-11b2-a85c-cd621c23b6bd.in.ibm.com (unknown [9.79.195.233]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Feb 2026 08:49:09 +0000 (GMT) From: Sathvika Vasireddy To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: nathan@kernel.org, masahiroy@kernel.org, kees@kernel.org, naveen@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, npiggin@gmail.com, maddy@linux.ibm.com, segher@kernel.crashing.org, christophe.leroy@csgroup.eu, mingo@kernel.org, mpe@ellerman.id.au, sv@linux.ibm.com, nsc@kernel.org Subject: [RFC PATCH v3 6/6] powerpc: Enable build-time feature fixup processing by default Date: Mon, 9 Feb 2026 14:18:20 +0530 Message-ID: <20260209084820.57298-7-sv@linux.ibm.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260209084820.57298-1-sv@linux.ibm.com> References: <20260209084820.57298-1-sv@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=WZYBqkhX c=1 sm=1 tr=0 ts=69899f90 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=CCpqsmhAAAAA:8 a=pGLkceISAAAA:8 a=VnNF1IyMAAAA:8 a=VskAbI2hzQZqgVltqkQA:9 a=ul9cdbp4aOFLsgKbc677:22 X-Proofpoint-GUID: OKeoAZ_qGQIChqA9D9J6OY22ZY98-8Pe X-Proofpoint-ORIG-GUID: _e2wpXSxv9mlaPRqxf5o3pOZrAJ7h1if X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjA5MDA3MiBTYWx0ZWRfX4sKG2cWTbN0G aAfUTY1xWxqWq89QeCu8Jv3K7bEYb0FFWTMsLcY6U6xxy37EsVI5LUC3mAk+407DqyOy+8Nv07K uYccfshHtpMRJe/aJ4VdXi64BG+waABEFT65T2m6Xq8Mnv1xGc7dhQWxW8WuT5IqPjwRY3eMeUT LQN+JSbKAXIWTQq0+9GrJURg29Q6cel16U17Txck3+8IDgFzWHw13Rm4zsv94AtJyoDFP7zEie9 Z4BFF/NTOw7B2y0O+gweRBw/Nt5tLUfRaVgydPGRZsU2fzSd/oNzH1SKmhx4fWBiSHEKLS2TuU2 zqNEg/wMVUlss9bacH1O2ozdaT1jLvFiygq8OWSpkdlAg9Ny1rUaTUh1ZQ0Mh3ju5xqewOF4b5G M5EMsPjuekHjZjJFSsWDwOR/7R6Im23bVIjwF+TCXsPJNCYLWW4NbhtNdtLARVz1NtABjh9prxb vke6nj6QTp48jeHXxeA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-08_05,2026-02-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602090072 Content-Type: text/plain; charset="utf-8" Enable HAVE_OBJTOOL_FTR_FIXUP by default on PowerPC architecture. - Remove runtime branch translation logic from patch_alt_instruction() - Add --emit-relocs linker flags for post-link fixup processing - Update ftr_alt section attributes to include executable flag - Strip the --emit-relocs relocation sections (.rel*) from the final vmlinux after processing Co-developed-by: Nicholas Piggin Signed-off-by: Nicholas Piggin Signed-off-by: Sathvika Vasireddy --- arch/powerpc/Kconfig | 3 +++ arch/powerpc/Makefile | 5 +++++ arch/powerpc/include/asm/feature-fixups.h | 2 +- arch/powerpc/kernel/vmlinux.lds.S | 8 ++++++-- arch/powerpc/lib/feature-fixups.c | 12 ------------ scripts/Makefile.vmlinux | 5 +++++ 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index b8d36a261009..aedb11912672 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -23,6 +23,9 @@ config 64BIT bool default y if PPC64 =20 +config HAVE_OBJTOOL_FTR_FIXUP + def_bool y + config LIVEPATCH_64 def_bool PPC64 depends on LIVEPATCH diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index a58b1029592c..8e1dab5f3c9a 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -105,6 +105,11 @@ LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) :=3D -pie --no-d= ynamic-linker LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) +=3D -z notext LDFLAGS_vmlinux :=3D $(LDFLAGS_vmlinux-y) =20 +# --emit-relocs required for post-link fixup of alternate feature +# text section relocations. +LDFLAGS_vmlinux +=3D --emit-relocs +KBUILD_LDFLAGS_MODULE +=3D --emit-relocs + ifdef CONFIG_PPC64 ifndef CONFIG_PPC_KERNEL_PCREL # -mcmodel=3Dmedium breaks modules because it uses 32bit offsets from diff --git a/arch/powerpc/include/asm/feature-fixups.h b/arch/powerpc/inclu= de/asm/feature-fixups.h index 756a6c694018..d6ae92a292ec 100644 --- a/arch/powerpc/include/asm/feature-fixups.h +++ b/arch/powerpc/include/asm/feature-fixups.h @@ -32,7 +32,7 @@ =20 #define FTR_SECTION_ELSE_NESTED(label) \ label##2: \ - .pushsection __ftr_alt_##label,"a"; \ + .pushsection __ftr_alt_##label, "ax"; \ .align 2; \ label##3: =20 diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinu= x.lds.S index 15850296c0a9..70a4de464b34 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S @@ -99,8 +99,8 @@ SECTIONS .text : AT(ADDR(.text) - LOAD_OFFSET) { ALIGN_FUNCTION(); #endif - /* careful! __ftr_alt_* sections need to be close to .text */ - *(.text.hot .text.hot.* TEXT_MAIN .text.fixup .text.unlikely .text.unlik= ely.* .fixup __ftr_alt_* .ref.text); + *(.text.hot .text.hot.* TEXT_MAIN .text.fixup .text.unlikely + .text.unlikely.* .fixup .ref.text); *(.tramp.ftrace.text); NOINSTR_TEXT SCHED_TEXT @@ -267,6 +267,10 @@ SECTIONS _einittext =3D .; } :text =20 + .__ftr_alternates.text : AT(ADDR(.__ftr_alternates.text) - LOAD_OFFSET) { + *(__ftr_alt*); + } + /* .exit.text is discarded at runtime, not link time, * to deal with references from __bug_table */ diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-f= ixups.c index 587c8cf1230f..269e992b1631 100644 --- a/arch/powerpc/lib/feature-fixups.c +++ b/arch/powerpc/lib/feature-fixups.c @@ -53,22 +53,10 @@ static u32 *calc_addr(struct fixup_entry *fcur, long of= fset) =20 static int patch_alt_instruction(u32 *src, u32 *dest, u32 *alt_start, u32 = *alt_end) { - int err; ppc_inst_t instr; =20 instr =3D ppc_inst_read(src); =20 - if (instr_is_relative_branch(ppc_inst_read(src))) { - u32 *target =3D (u32 *)branch_target(src); - - /* Branch within the section doesn't need translating */ - if (target < alt_start || target > alt_end) { - err =3D translate_branch(&instr, dest, src); - if (err) - return 1; - } - } - raw_patch_instruction(dest, instr); =20 return 0; diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index e3dd7fc62f20..3d2a203b8908 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -88,6 +88,11 @@ remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D = '.rel*' '!.rel*.dyn' # https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;h=3Dc12d9fa2= afe7abcbe407a00e15719e1a1350c2a7 remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D '.rel.*' =20 +# --emit-relocs produces .rela.* sections needed by objtool --ftr-fixup; +# strip them from vmlinux after fixup processing is complete. +remove-section-$(CONFIG_HAVE_OBJTOOL_FTR_FIXUP) +=3D '.rel*' '!.rel*.dy= n' +remove-section-$(CONFIG_HAVE_OBJTOOL_FTR_FIXUP) +=3D '.rel.*' + remove-symbols :=3D -w --strip-unneeded-symbol=3D'__mod_device_table__*' =20 # To avoid warnings: "empty loadable segment detected at ..." from GNU obj= copy, --=20 2.43.0