Skip to contentSkip to conversation

objtool: Enable and implement --mcount option on powerpc

RFC PATCH In review Christophe Leroy 4 participants 22 messages May 24, 2022 – Jun 24, 2022

Subsystems (4)
lore
Share & tools
lore
#6 lore raw

RFC PATCH v2 5/7 objtool: Enable objtool to run only on files with ftrace enabled

In reply to Christophe Leroy

From: Sathvika Vasireddy <[email protected]>

This patch makes sure objtool runs only on the object files that have ftrace enabled, instead of running on all the object files.

---
 scripts/Makefile.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.build +2 -2
index 2e0c3f9c1459..06ceffd92921 100644
@@ -258,8 +258,8 @@ else
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
 
-$(obj)/%.o: objtool-enabled = $(if $(filter-out y%, \
-	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
+$(obj)/%.o: objtool-enabled = $(and $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y),        \
+        $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),y),y)
 
 endif
 
Signature · 1 line
2.35.3
#1 lore raw

RFC PATCH v2 1/7 objtool: Fix SEGFAULT

In reply to Christophe Leroy
---
 tools/objtool/check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/objtool/check.c +1 -1
index 190b2f6e360a..6cb07e151588 100644
@@ -203,7 +203,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
 		return false;
 
 	insn = find_insn(file, func->sec, func->offset);
-	if (!insn->func)
+	if (!insn || !insn->func)
 		return false;
 
 	func_for_each_insn(file, func, insn) {
Signature · 1 line
2.35.3
#3 lore raw

RFC PATCH v2 3/7 objtool: Use target file class size instead of a compiled constant

In reply to Christophe Leroy

In order to allow using objtool on cross-built kernels, determine size of long from elf data instead of using sizeof(long) at build time.

For the time being this covers only mcount.

---
 tools/objtool/check.c               | 16 +++++++++-------
 tools/objtool/elf.c                 |  8 ++++++--
 tools/objtool/include/objtool/elf.h |  8 ++++++++
 3 files changed, 23 insertions(+), 9 deletions(-)
tools/objtool/check.c +9 -7
index cef1dd54d505..fabc0ea88747 100644
@@ -802,9 +802,9 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file)
 static int create_mcount_loc_sections(struct objtool_file *file)
 {
 	struct section *sec;
-	unsigned long *loc;
 	struct instruction *insn;
 	int idx;
+	int size = elf_class_size(file->elf);
 
 	sec = find_section_by_name(file->elf, "__mcount_loc");
 	if (sec) {
@@ -820,23 +820,25 @@ static int create_mcount_loc_sections(struct objtool_file *file)
 	list_for_each_entry(insn, &file->mcount_loc_list, call_node)
 		idx++;
 
-	sec = elf_create_section(file->elf, "__mcount_loc", 0, sizeof(unsigned long), idx);
+	sec = elf_create_section(file->elf, "__mcount_loc", 0, size, idx);
 	if (!sec)
 		return -1;
 
+	sec->sh.sh_addralign = size;
+
 	idx = 0;
 	list_for_each_entry(insn, &file->mcount_loc_list, call_node) {
+		void *loc;
 
-		loc = (unsigned long *)sec->data->d_buf + idx;
-		memset(loc, 0, sizeof(unsigned long));
+		loc = sec->data->d_buf + idx;
+		memset(loc, 0, size);
 
-		if (elf_add_reloc_to_insn(file->elf, sec,
-					  idx * sizeof(unsigned long),
+		if (elf_add_reloc_to_insn(file->elf, sec, idx,
 					  R_X86_64_64,
 					  insn->sec, insn->offset))
 			return -1;
 
-		idx++;
+		idx += size;
 	}
 
 	return 0;
tools/objtool/elf.c +6 -2
index c25e957c1e52..63218f5799c2 100644
@@ -1124,6 +1124,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 {
 	char *relocname;
 	struct section *sec;
+	int size = elf_class_size(elf);
 
 	relocname = malloc(strlen(base->name) + strlen(".rela") + 1);
 	if (!relocname) {
@@ -1133,7 +1134,10 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 	strcpy(relocname, ".rela");
 	strcat(relocname, base->name);
 
-	sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0);
+	if (size == sizeof(u32))
+		sec = elf_create_section(elf, relocname, 0, sizeof(Elf32_Rela), 0);
+	else
+		sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0);
 	free(relocname);
 	if (!sec)
 		return NULL;
@@ -1142,7 +1146,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec
 	sec->base = base;
 
 	sec->sh.sh_type = SHT_RELA;
-	sec->sh.sh_addralign = 8;
+	sec->sh.sh_addralign = size;
 	sec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx;
 	sec->sh.sh_info = base->idx;
 	sec->sh.sh_flags = SHF_INFO_LINK;
tools/objtool/include/objtool/elf.h +8 -0
index adebfbc2b518..c720c4476828 100644
@@ -141,6 +141,14 @@ static inline bool has_multiple_files(struct elf *elf)
 	return elf->num_files > 1;
 }
 
+static inline int elf_class_size(struct elf *elf)
+{
+	if (elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32)
+		return sizeof(u32);
+	else
+		return sizeof(u64);
+}
+
 struct elf *elf_open_read(const char *name, int flags);
 struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
 
Signature · 1 line
2.35.3
#13 lore raw

RFC PATCH v2 7/7 objtool/powerpc: Add --mcount specific implementation

In reply to Christophe Leroy

From: Sathvika Vasireddy <[email protected]>

This patch enables objtool --mcount on powerpc, and adds implementation specific to powerpc.

---
 arch/powerpc/Kconfig                |  1 +
 tools/objtool/arch/powerpc/decode.c | 14 ++++++++++++++
 tools/objtool/check.c               | 12 +++++++-----
 tools/objtool/elf.c                 | 15 +++++++++++++++
 tools/objtool/include/objtool/elf.h |  1 +
 5 files changed, 38 insertions(+), 5 deletions(-)
arch/powerpc/Kconfig +1 -0
index 7c01229dd2e3..5ef8bf8eb202 100644
@@ -233,6 +233,7 @@ config PPC
 	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
 	select HAVE_OPTPROBES
 	select HAVE_OBJTOOL
+	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_EVENTS_NMI		if PPC64
 	select HAVE_PERF_REGS
tools/objtool/arch/powerpc/decode.c +14 -0
index eb1542d155fe..048bb4cd2838 100644
@@ -41,12 +41,26 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
 			    struct list_head *ops_list)
 {
 	u32 insn;
+	unsigned int opcode;
 
 	*immediate = 0;
 	insn = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
 	*len = 4;
 	*type = INSN_OTHER;
 
+	opcode = (insn >> 26);
+
+	switch (opcode) {
+	case 18: /* bl */
+		if ((insn & 3) == 1) {
+			*type = INSN_CALL;
+			*immediate = insn & 0x3fffffc;
+			if (*immediate & 0x2000000)
+				*immediate -= 0x4000000;
+		}
+		break;
+	}
+
 	return 0;
 }
 
tools/objtool/check.c +7 -5
index 7f0dc504dd92..70be5a72e838 100644
@@ -834,7 +834,7 @@ static int create_mcount_loc_sections(struct objtool_file *file)
 		memset(loc, 0, size);
 
 		if (elf_add_reloc_to_insn(file->elf, sec, idx,
-					  R_X86_64_64,
+					  elf_reloc_type_long(file->elf),
 					  insn->sec, insn->offset))
 			return -1;
 
@@ -2185,7 +2185,7 @@ static int classify_symbols(struct objtool_file *file)
 			if (arch_is_retpoline(func))
 				func->retpoline_thunk = true;
 
-			if (!strcmp(func->name, "__fentry__"))
+			if ((!strcmp(func->name, "__fentry__")) || (!strcmp(func->name, "_mcount")))
 				func->fentry = true;
 
 			if (is_profiling_func(func->name))
@@ -2261,9 +2261,11 @@ static int decode_sections(struct objtool_file *file)
 	 * Must be before add_jump_destinations(), which depends on 'func'
 	 * being set for alternatives, to enable proper sibling call detection.
 	 */
-	ret = add_special_section_alts(file);
-	if (ret)
-		return ret;
+	if (opts.stackval || opts.orc || opts.uaccess || opts.noinstr) {
+		ret = add_special_section_alts(file);
+		if (ret)
+			return ret;
+	}
 
 	ret = add_jump_destinations(file);
 	if (ret)
tools/objtool/elf.c +15 -0
index 63218f5799c2..34b1c6817a5e 100644
@@ -793,6 +793,21 @@ elf_create_section_symbol(struct elf *elf, struct section *sec)
 	return sym;
 }
 
+int elf_reloc_type_long(struct elf *elf)
+{
+	switch (elf->ehdr.e_machine) {
+	case EM_X86_64:
+		return R_X86_64_64;
+	case EM_PPC64:
+		return R_PPC64_ADDR64;
+	case EM_PPC:
+		return R_PPC_ADDR32;
+	default:
+		WARN("unknown machine...");
+		exit(-1);
+	}
+}
+
 int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
 			  unsigned long offset, unsigned int type,
 			  struct section *insn_sec, unsigned long insn_off)
tools/objtool/include/objtool/elf.h +1 -0
index c720c4476828..d10f4701715b 100644
@@ -152,6 +152,7 @@ static inline int elf_class_size(struct elf *elf)
 struct elf *elf_open_read(const char *name, int flags);
 struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
 
+int elf_reloc_type_long(struct elf *elf);
 int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
 		  unsigned int type, struct symbol *sym, s64 addend);
 int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
Signature · 1 line
2.35.3
#0 lore raw

v2 cover objtool: Enable and implement --mcount option on powerpc

This draft series adds PPC32 support to Sathvika's series. Verified on pmac32 on QEMU.

It should in principle also work for PPC64 BE but for the time being something goes wrong. In the beginning I had a segfaut hence the first patch. But I still get no mcount section in the files.

Christophe Leroy (3):
objtool: Fix SEGFAULT
objtool: Use target file endianness instead of a compiled constant
objtool: Use target file class size instead of a compiled constant

Sathvika Vasireddy (4):
objtool: Add --mnop as an option to --mcount
objtool: Enable objtool to run only on files with ftrace enabled objtool/powerpc: Enable objtool to be built on ppc objtool/powerpc: Add --mcount specific implementation

 Makefile                                      |  4 +-
 arch/powerpc/Kconfig                          |  2 +
 arch/x86/Kconfig                              |  1 +
 scripts/Makefile.build                        |  5 +-
 tools/objtool/arch/powerpc/Build              |  2 +
 tools/objtool/arch/powerpc/decode.c           | 88 +++++++++++++++++++
 .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
 tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
 .../arch/powerpc/include/arch/special.h       | 21 +++++
 tools/objtool/arch/powerpc/special.c          | 19 ++++
 .../arch/x86/include/arch/endianness.h        |  9 --
 tools/objtool/builtin-check.c                 | 14 +++
 tools/objtool/check.c                         | 51 ++++++-----
 tools/objtool/elf.c                           | 23 ++++-
 tools/objtool/include/objtool/builtin.h       |  1 +
 tools/objtool/include/objtool/elf.h           |  9 ++
 tools/objtool/include/objtool/endianness.h    | 29 +++---
 tools/objtool/orc_dump.c                      | 11 ++-
 tools/objtool/orc_gen.c                       |  4 +-
 tools/objtool/special.c                       |  3 +-
 20 files changed, 257 insertions(+), 58 deletions(-)
 create mode 100644 tools/objtool/arch/powerpc/Build
 create mode 100644 tools/objtool/arch/powerpc/decode.c
 create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
 create mode 100644 tools/objtool/arch/powerpc/special.c
 delete mode 100644 tools/objtool/arch/x86/include/arch/endianness.h
Signature · 1 line
2.35.3
#2 lore raw

RFC PATCH v2 2/7 objtool: Use target file endianness instead of a compiled constant

Some architectures like powerpc support both endianness, it's therefore not possible to fix the endianness via arch/endianness.h because there is no easy way to get the target endianness at build time.

Use the endianness recorded in the file objtool is working on.

---
 .../arch/x86/include/arch/endianness.h        |  9 ------
 tools/objtool/check.c                         |  2 +-
 tools/objtool/include/objtool/endianness.h    | 29 +++++++++----------
 tools/objtool/orc_dump.c                      | 11 +++++--
 tools/objtool/orc_gen.c                       |  4 +--
 tools/objtool/special.c                       |  3 +-
 6 files changed, 27 insertions(+), 31 deletions(-)
 delete mode 100644 tools/objtool/arch/x86/include/arch/endianness.h
tools/objtool/arch/x86/include/arch/endianness.h deleted +0 -9
deleted file mode 100644
index 7c362527da20..000000000000
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _ARCH_ENDIANNESS_H
-#define _ARCH_ENDIANNESS_H
-
-#include <endian.h>
-
-#define __TARGET_BYTE_ORDER __LITTLE_ENDIAN
-
-#endif /* _ARCH_ENDIANNESS_H */
tools/objtool/check.c +1 -1
index 6cb07e151588..cef1dd54d505 100644
@@ -1971,7 +1971,7 @@ static int read_unwind_hints(struct objtool_file *file)
 			return -1;
 		}
 
-		cfi.cfa.offset = bswap_if_needed(hint->sp_offset);
+		cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset);
 		cfi.type = hint->type;
 		cfi.end = hint->end;
 
tools/objtool/include/objtool/endianness.h +13 -16
index 10241341eff3..ab0515ba0538 100644
@@ -2,33 +2,30 @@
 #ifndef _OBJTOOL_ENDIANNESS_H
 #define _OBJTOOL_ENDIANNESS_H
 
-#include <arch/endianness.h>
 #include <linux/kernel.h>
 #include <endian.h>
-
-#ifndef __TARGET_BYTE_ORDER
-#error undefined arch __TARGET_BYTE_ORDER
-#endif
-
-#if __BYTE_ORDER != __TARGET_BYTE_ORDER
-#define __NEED_BSWAP 1
-#else
-#define __NEED_BSWAP 0
-#endif
+#include <objtool/elf.h>
 
 /*
- * Does a byte swap if target endianness doesn't match the host, i.e. cross
+ * Does a byte swap if target file endianness doesn't match the host, i.e. cross
  * compilation for little endian on big endian and vice versa.
  * To be used for multi-byte values conversion, which are read from / about
  * to be written to a target native endianness ELF file.
  */
-#define bswap_if_needed(val)						\
+static inline bool need_bswap(struct elf *elf)
+{
+	return (__BYTE_ORDER == __LITTLE_ENDIAN) ^
+	       (elf->ehdr.e_ident[EI_DATA] == ELFDATA2LSB);
+}
+
+#define bswap_if_needed(elf, val)					\
 ({									\
 	__typeof__(val) __ret;						\
+	bool __need_bswap = need_bswap(elf);				\
 	switch (sizeof(val)) {						\
-	case 8: __ret = __NEED_BSWAP ? bswap_64(val) : (val); break;	\
-	case 4: __ret = __NEED_BSWAP ? bswap_32(val) : (val); break;	\
-	case 2: __ret = __NEED_BSWAP ? bswap_16(val) : (val); break;	\
+	case 8: __ret = __need_bswap ? bswap_64(val) : (val); break;	\
+	case 4: __ret = __need_bswap ? bswap_32(val) : (val); break;	\
+	case 2: __ret = __need_bswap ? bswap_16(val) : (val); break;	\
 	default:							\
 		BUILD_BUG(); break;					\
 	}								\
tools/objtool/orc_dump.c +9 -2
index f5a8508c42d6..4f1211fec82c 100644
@@ -76,6 +76,7 @@ int orc_dump(const char *_objname)
 	GElf_Rela rela;
 	GElf_Sym sym;
 	Elf_Data *data, *symtab = NULL, *rela_orc_ip = NULL;
+	struct elf dummy_elf = {};
 
 
 	objname = _objname;
@@ -94,6 +95,12 @@ int orc_dump(const char *_objname)
 		return -1;
 	}
 
+	if (!elf64_getehdr(elf)) {
+		WARN_ELF("elf64_getehdr");
+		return -1;
+	}
+	memcpy(&dummy_elf.ehdr, elf64_getehdr(elf), sizeof(dummy_elf.ehdr));
+
 	if (elf_getshdrnum(elf, &nr_sections)) {
 		WARN_ELF("elf_getshdrnum");
 		return -1;
@@ -198,11 +205,11 @@ int orc_dump(const char *_objname)
 
 		printf(" sp:");
 
-		print_reg(orc[i].sp_reg, bswap_if_needed(orc[i].sp_offset));
+		print_reg(orc[i].sp_reg, bswap_if_needed(&dummy_elf, orc[i].sp_offset));
 
 		printf(" bp:");
 
-		print_reg(orc[i].bp_reg, bswap_if_needed(orc[i].bp_offset));
+		print_reg(orc[i].bp_reg, bswap_if_needed(&dummy_elf, orc[i].bp_offset));
 
 		printf(" type:%s end:%d\n",
 		       orc_type_name(orc[i].type), orc[i].end);
tools/objtool/orc_gen.c +2 -2
index dd3c64af9db2..1f22b7ebae58 100644
@@ -97,8 +97,8 @@ static int write_orc_entry(struct elf *elf, struct section *orc_sec,
 	/* populate ORC data */
 	orc = (struct orc_entry *)orc_sec->data->d_buf + idx;
 	memcpy(orc, o, sizeof(*orc));
-	orc->sp_offset = bswap_if_needed(orc->sp_offset);
-	orc->bp_offset = bswap_if_needed(orc->bp_offset);
+	orc->sp_offset = bswap_if_needed(elf, orc->sp_offset);
+	orc->bp_offset = bswap_if_needed(elf, orc->bp_offset);
 
 	/* populate reloc for ip */
 	if (elf_add_reloc_to_insn(elf, ip_sec, idx * sizeof(int), R_X86_64_PC32,
tools/objtool/special.c +2 -1
index e2223dd91c37..9c8d827f69af 100644
@@ -87,7 +87,8 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
 	if (entry->feature) {
 		unsigned short feature;
 
-		feature = bswap_if_needed(*(unsigned short *)(sec->data->d_buf +
+		feature = bswap_if_needed(elf,
+					  *(unsigned short *)(sec->data->d_buf +
 							      offset +
 							      entry->feature));
 		arch_handle_alternative(feature, alt);
Signature · 1 line
2.35.3
#12 lore raw

RFC PATCH v2 6/7 objtool/powerpc: Enable objtool to be built on ppc

In reply to Christophe Leroy

From: Sathvika Vasireddy <[email protected]>

This patch adds [stub] implementations for required functions, inorder to enable objtool build on powerpc.

---
 arch/powerpc/Kconfig                          |  1 +
 tools/objtool/arch/powerpc/Build              |  2 +
 tools/objtool/arch/powerpc/decode.c           | 74 +++++++++++++++++++
 .../arch/powerpc/include/arch/cfi_regs.h      | 11 +++
 tools/objtool/arch/powerpc/include/arch/elf.h |  8 ++
 .../arch/powerpc/include/arch/special.h       | 21 ++++++
 tools/objtool/arch/powerpc/special.c          | 19 +++++
 7 files changed, 136 insertions(+)
 create mode 100644 tools/objtool/arch/powerpc/Build
 create mode 100644 tools/objtool/arch/powerpc/decode.c
 create mode 100644 tools/objtool/arch/powerpc/include/arch/cfi_regs.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/elf.h
 create mode 100644 tools/objtool/arch/powerpc/include/arch/special.h
 create mode 100644 tools/objtool/arch/powerpc/special.c
arch/powerpc/Kconfig +1 -0
index 174edabb74fa..7c01229dd2e3 100644
@@ -232,6 +232,7 @@ config PPC
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAVE_NMI				if PERF_EVENTS || (PPC64 && PPC_BOOK3S)
 	select HAVE_OPTPROBES
+	select HAVE_OBJTOOL
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_EVENTS_NMI		if PPC64
 	select HAVE_PERF_REGS
tools/objtool/arch/powerpc/Build new file +2 -0
new file mode 100644
index 000000000000..d24d5636a5b8
@@ -0,0 +1,2 @@
+objtool-y += decode.o
+objtool-y += special.o
tools/objtool/arch/powerpc/decode.c new file +74 -0

74 lines not on this page · raw message

tools/objtool/arch/powerpc/include/arch/cfi_regs.h new file +11 -0
new file mode 100644
index 000000000000..59638ebeafc8
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _OBJTOOL_CFI_REGS_H
+#define _OBJTOOL_CFI_REGS_H
+
+#define CFI_BP 1
+#define CFI_SP CFI_BP
+#define CFI_RA 32
+#define CFI_NUM_REGS 33
+
+#endif
tools/objtool/arch/powerpc/include/arch/elf.h new file +8 -0
new file mode 100644
index 000000000000..3c8ebb7d2a6b
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _OBJTOOL_ARCH_ELF
+#define _OBJTOOL_ARCH_ELF
+
+#define R_NONE R_PPC_NONE
+
+#endif /* _OBJTOOL_ARCH_ELF */
tools/objtool/arch/powerpc/include/arch/special.h new file +21 -0
new file mode 100644
index 000000000000..ffef9ada7133
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _PPC_ARCH_SPECIAL_H
+#define _PPC_ARCH_SPECIAL_H
+
+#define EX_ENTRY_SIZE 8
+#define EX_ORIG_OFFSET 0
+#define EX_NEW_OFFSET 4
+
+#define JUMP_ENTRY_SIZE 16
+#define JUMP_ORIG_OFFSET 0
+#define JUMP_NEW_OFFSET 4
+#define JUMP_KEY_OFFSET 8
+
+#define ALT_ENTRY_SIZE 12
+#define ALT_ORIG_OFFSET 0
+#define ALT_NEW_OFFSET 4
+#define ALT_FEATURE_OFFSET 8
+#define ALT_ORIG_LEN_OFFSET 10
+#define ALT_NEW_LEN_OFFSET 11
+
+#endif /* _PPC_ARCH_SPECIAL_H */
tools/objtool/arch/powerpc/special.c new file +19 -0
new file mode 100644
index 000000000000..e3e75cbab858
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <string.h>
+
+#include <objtool/special.h>
+#include <objtool/builtin.h>
+
+
+bool arch_support_alt_relocation(struct special_alt *special_alt,
+				 struct instruction *insn,
+				 struct reloc *reloc)
+{
+	return false;
+}
+
+struct reloc *arch_find_switch_table(struct objtool_file *file,
+				    struct instruction *insn)
+{
+	return NULL;
+}
Signature · 1 line
2.35.3
#5 lore raw

RFC PATCH v2 4/7 objtool: Add --mnop as an option to --mcount

In reply to Christophe Leroy

From: Sathvika Vasireddy <[email protected]>

Architectures can select HAVE_NOP_MCOUNT if they choose to nop out mcount call sites. If that config option is selected, then --mnop is passed as an option to objtool, along with --mcount.

Also, make sure that --mnop can be passed as an option to objtool only when --mcount is passed.

---
 Makefile                                |  4 +++-
 arch/x86/Kconfig                        |  1 +
 scripts/Makefile.build                  |  1 +
 tools/objtool/builtin-check.c           | 14 ++++++++++++++
 tools/objtool/check.c                   | 19 ++++++++++---------
 tools/objtool/include/objtool/builtin.h |  1 +
 6 files changed, 30 insertions(+), 10 deletions(-)
Makefile +3 -1
index 250707647359..acaf88e3c694 100644
@@ -851,7 +851,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC
   endif
 endif
 ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
-  CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
+  ifdef CONFIG_HAVE_NOP_MCOUNT
+    CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
+  endif
 endif
 ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
   ifdef CONFIG_HAVE_C_RECORDMCOUNT
arch/x86/Kconfig +1 -0
index 1847d6e974a1..4a41bfb644f0 100644
@@ -189,6 +189,7 @@ config X86
 	select HAVE_CONTEXT_TRACKING_OFFSTACK	if HAVE_CONTEXT_TRACKING
 	select HAVE_C_RECORDMCOUNT
 	select HAVE_OBJTOOL_MCOUNT		if HAVE_OBJTOOL
+	select HAVE_NOP_MCOUNT			if HAVE_OBJTOOL_MCOUNT
 	select HAVE_BUILDTIME_MCOUNT_SORT
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DMA_CONTIGUOUS
scripts/Makefile.build +1 -0
index ac8167227bc0..2e0c3f9c1459 100644
@@ -231,6 +231,7 @@ objtool_args =								\
 	$(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr)		\
 	$(if $(CONFIG_X86_KERNEL_IBT), --ibt)				\
 	$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount)		\
+	$(if $(CONFIG_HAVE_NOP_MCOUNT), --mnop)				\
 	$(if $(CONFIG_UNWINDER_ORC), --orc)				\
 	$(if $(CONFIG_RETPOLINE), --retpoline)				\
 	$(if $(CONFIG_SLS), --sls)					\
tools/objtool/builtin-check.c +14 -0
index f4c3a5091737..b05e2108c0c3 100644
@@ -80,6 +80,7 @@ const struct option check_options[] = {
 	OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"),
 	OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"),
 	OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"),
+	OPT_BOOLEAN(0, "mnop", &opts.mnop, "nop out mcount call sites"),
 	OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"),
 	OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
 	OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
@@ -142,6 +143,16 @@ static bool opts_valid(void)
 	return false;
 }
 
+static bool mnop_opts_valid(void)
+{
+	if (opts.mnop && !opts.mcount) {
+		ERROR("--mnop requires --mcount");
+		return false;
+	}
+
+	return true;
+}
+
 static bool link_opts_valid(struct objtool_file *file)
 {
 	if (opts.link)
@@ -185,6 +196,9 @@ int objtool_run(int argc, const char **argv)
 	if (!file)
 		return 1;
 
+	if (!mnop_opts_valid())
+		return 1;
+
 	if (!link_opts_valid(file))
 		return 1;
 
tools/objtool/check.c +10 -9
index fabc0ea88747..7f0dc504dd92 100644
@@ -1177,17 +1177,18 @@ static void annotate_call_site(struct objtool_file *file,
 	if (opts.mcount && sym->fentry) {
 		if (sibling)
 			WARN_FUNC("Tail call to __fentry__ !?!?", insn->sec, insn->offset);
+		if (opts.mnop) {
+			if (reloc) {
+				reloc->type = R_NONE;
+				elf_write_reloc(file->elf, reloc);
+			}
 
-		if (reloc) {
-			reloc->type = R_NONE;
-			elf_write_reloc(file->elf, reloc);
-		}
-
-		elf_write_insn(file->elf, insn->sec,
-			       insn->offset, insn->len,
-			       arch_nop_insn(insn->len));
+			elf_write_insn(file->elf, insn->sec,
+				       insn->offset, insn->len,
+				       arch_nop_insn(insn->len));
 
-		insn->type = INSN_NOP;
+			insn->type = INSN_NOP;
+		}
 
 		list_add_tail(&insn->call_node, &file->mcount_loc_list);
 		return;
tools/objtool/include/objtool/builtin.h +1 -0
index 280ea18b7f2b..71ed3152a18e 100644
@@ -29,6 +29,7 @@ struct opts {
 	bool backup;
 	bool dryrun;
 	bool link;
+	bool mnop;
 	bool module;
 	bool no_unreachable;
 	bool sec_address;
Signature · 1 line
2.35.3
maintainer
#4 lore raw

Re: [RFC PATCH v2 3/7] objtool: Use target file class size instead of a compiled constant

In reply to Christophe Leroy

tools/objtool/elf.c static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec · line 1140

Quoted 5 lines · Christophe Leroy
tools/objtool/elf.c +4 -1
-	sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0);
+	if (size == sizeof(u32))
+		sec = elf_create_section(elf, relocname, 0, sizeof(Elf32_Rela), 0);
+	else
+		sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0);

Probably best to use Elf64_* here instead of GElf_*.

maintainer
#7 lore raw

Re: [RFC PATCH v2 5/7] objtool: Enable objtool to run only on files with ftrace enabled

In reply to Christophe Leroy
Quoted 18 lines · Christophe Leroy

From: Sathvika Vasireddy <[email protected]>

This patch makes sure objtool runs only on the object files that have ftrace enabled, instead of running on all the object files.

---
 scripts/Makefile.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.build +0 -0
index 2e0c3f9c1459..06ceffd92921 100644

scripts/Makefile.build else · line 262

Quoted 7 lines
scripts/Makefile.build +2 -2
@@ -258,8 +258,8 @@ else
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
 
-$(obj)/%.o: objtool-enabled = $(if $(filter-out y%, \
-	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
+$(obj)/%.o: objtool-enabled = $(and $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y),        \
+        $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),y),y)

I think this breaks x86, quite a bit of files have ftrace disabled but very much must run objtool anyway.

maintainer
#8 lore raw

Re: [RFC PATCH v2 5/7] objtool: Enable objtool to run only on files with ftrace enabled

Quoted 22 lines · Peter Zijlstra
Quoted 21 lines · Christophe Leroy

From: Sathvika Vasireddy <[email protected]>

This patch makes sure objtool runs only on the object files that have ftrace enabled, instead of running on all the object files.

---
 scripts/Makefile.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.build +0 -0
index 2e0c3f9c1459..06ceffd92921 100644
@@ -258,8 +258,8 @@ else
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
 
Quoted 7 lines

scripts/Makefile.build else · line 262

Quoted 4 lines
scripts/Makefile.build +2 -2
-$(obj)/%.o: objtool-enabled = $(if $(filter-out y%, \
-	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
+$(obj)/%.o: objtool-enabled = $(and $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y),        \
+        $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),y),y)

I think this breaks x86, quite a bit of files have ftrace disabled but very much must run objtool anyway.

Also; since the Changelog gives 0 clue as to what problem it's trying to solve, I can't suggest anything.

#9 lore raw

Re: [RFC PATCH v2 5/7] objtool: Enable objtool to run only on files with ftrace enabled

Le 24/05/2022 à 20:02, Peter Zijlstra a écrit :

Quoted 31 lines · Peter Zijlstra
Quoted 22 lines · Christophe Leroy
Quoted 21 lines

From: Sathvika Vasireddy <[email protected]>

This patch makes sure objtool runs only on the object files that have ftrace enabled, instead of running on all the object files.

---
  scripts/Makefile.build | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.build +0 -0
index 2e0c3f9c1459..06ceffd92921 100644
@@ -258,8 +258,8 @@ else
  # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
  # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
 
Quoted 7 lines

scripts/Makefile.build else · line 262

Quoted 4 lines
scripts/Makefile.build +2 -2
-$(obj)/%.o: objtool-enabled = $(if $(filter-out y%, \
-	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
+$(obj)/%.o: objtool-enabled = $(and $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y),        \
+        $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),y),y)

I think this breaks x86, quite a bit of files have ftrace disabled but very much must run objtool anyway.

Quoted 2 lines

Also; since the Changelog gives 0 clue as to what problem it's trying to solve, I can't suggest anything.

I asked Sathvika on the previous series, see
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/

He says it is to solve the problem I reported at
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/#2861128

Christophe

maintainer
#10 lore raw

Re: [RFC PATCH v2 5/7] objtool: Enable objtool to run only on files with ftrace enabled

Quoted 34 lines · Christophe Leroy

Le 24/05/2022 à 20:02, Peter Zijlstra a écrit :

Quoted 31 lines · Peter Zijlstra
Quoted 29 lines · Christophe Leroy
Quoted 18 lines

From: Sathvika Vasireddy <[email protected]>

This patch makes sure objtool runs only on the object files that have ftrace enabled, instead of running on all the object files.

---
  scripts/Makefile.build | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.build +0 -0
index 2e0c3f9c1459..06ceffd92921 100644

scripts/Makefile.build else · line 262

Quoted 7 lines
scripts/Makefile.build +2 -2
@@ -258,8 +258,8 @@ else
  # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
  # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
 
-$(obj)/%.o: objtool-enabled = $(if $(filter-out y%, \
-	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
+$(obj)/%.o: objtool-enabled = $(and $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y),        \
+        $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),y),y)

I think this breaks x86, quite a bit of files have ftrace disabled but very much must run objtool anyway.

Quoted 8 lines
Quoted 2 lines

Also; since the Changelog gives 0 clue as to what problem it's trying to solve, I can't suggest anything.

I asked Sathvika on the previous series, see
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/

He says it is to solve the problem I reported at
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/#2861128

So on x86 we have:

arch/x86/entry/vdso/Makefile:OBJECT_FILES_NON_STANDARD := y

to kill objtool for the whole of the VDSO. When we run objtool on vmlinux it isn't a problem, because the VDSO ends up as a data section through linker scripts.

#14 lore raw
In reply to Christophe Leroy

Hi Christophe,

Quoted 6 lines · Christophe Leroy

This draft series adds PPC32 support to Sathvika's series. Verified on pmac32 on QEMU.

It should in principle also work for PPC64 BE but for the time being something goes wrong. In the beginning I had a segfaut hence the first patch. But I still get no mcount section in the files.

Since PPC64 BE uses older elfv1 ABI, it prepends a dot to symbols. And so, the relocation records in case of PPC64BE point to "._mcount", rather than just "_mcount". We should be looking for "._mcount" to be able to generate mcount_loc section in the files.

Like:

tools/objtool/check.c +0 -0
index 70be5a72e838..7da5bf8c7236 100644
@@ -2185,7 +2185,7 @@ static int classify_symbols(struct objtool_file *file)

                        if (arch_is_retpoline(func)) func->retpoline_thunk = true;

-                       if ((!strcmp(func->name, "__fentry__")) || (!strcmp(func->name, "_mcount")))
+                       if ((!strcmp(func->name, "__fentry__")) || (!strcmp(func->name, "_mcount")) || (!strcmp(func->name, "._mcount")))

                                func->fentry = true;

                        if (is_profiling_func(func->name))

With this change, I could see __mcount_loc section being generated in individual ppc64be object files.

- Sathvika

#11 lore raw

Re: [RFC PATCH v2 5/7] objtool: Enable objtool to run only on files with ftrace enabled

In reply to Peter Zijlstra

Hi Peter,

Quoted 39 lines · Peter Zijlstra
Quoted 31 lines · Christophe Leroy

Le 24/05/2022 à 20:02, Peter Zijlstra a écrit :

Quoted 29 lines · Peter Zijlstra
Quoted 28 lines · Christophe Leroy
Quoted 18 lines

From: Sathvika Vasireddy<[email protected]>

This patch makes sure objtool runs only on the object files that have ftrace enabled, instead of running on all the object files.

---
   scripts/Makefile.build | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.build +0 -0
index 2e0c3f9c1459..06ceffd92921 100644

scripts/Makefile.build else · line 262

Quoted 7 lines
scripts/Makefile.build +2 -2
@@ -258,8 +258,8 @@ else
   # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
   # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
 
-$(obj)/%.o: objtool-enabled = $(if $(filter-out y%, \
-	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
+$(obj)/%.o: objtool-enabled = $(and $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y),        \
+        $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),y),y)

I think this breaks x86, quite a bit of files have ftrace disabled but very much must run objtool anyway.

Quoted 7 lines
Quoted 2 lines

Also; since the Changelog gives 0 clue as to what problem it's trying to solve, I can't suggest anything.

I asked Sathvika on the previous series, see
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/

He says it is to solve the problem I reported at
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/#2861128

Quoted 7 lines

So on x86 we have:

arch/x86/entry/vdso/Makefile:OBJECT_FILES_NON_STANDARD := y

to kill objtool for the whole of the VDSO. When we run objtool on vmlinux it isn't a problem, because the VDSO ends up as a data section through linker scripts.

Right.. Like you and Christophe mentioned, arch/powerpc/kernel/vdso/Makefile:OBJECT_FILES_NON_STANDARD := y should solve it for powerpc as well.

I'll drop this patch and replace it with the above change as part of next revision series.

Thanks for reviewing!

- Sathvika

#15 lore raw
In reply to Sathvika Vasireddy
Quoted 11 lines · Sathvika Vasireddy
Quoted 6 lines · Christophe Leroy

This draft series adds PPC32 support to Sathvika's series. Verified on pmac32 on QEMU.

It should in principle also work for PPC64 BE but for the time being something goes wrong. In the beginning I had a segfaut hence the first patch. But I still get no mcount section in the files.

Since PPC64 BE uses older elfv1 ABI, it prepends a dot to symbols. And so, the relocation records in case of PPC64BE point to "._mcount", rather than just "_mcount". We should be looking for "._mcount" to be able to generate mcount_loc section in the files.

The dotted symbol is on the actual function. The "normal" symbol is on the "official procedure descriptor" (opd), which is what you get if you (in C) take the address of a function. A procedure descriptor holds one or two more pointers, the GOT and environment pointers. We don't use the environment one, but the GOT pointer is necessary everywhere :-)

Segher

#16 lore raw
In reply to Sathvika Vasireddy

Hi Sathvika,

Le 25/05/2022 à 12:14, Sathvika Vasireddy a écrit :

Quoted 31 lines

Hi Christophe,

Quoted 6 lines · Christophe Leroy

This draft series adds PPC32 support to Sathvika's series. Verified on pmac32 on QEMU.

It should in principle also work for PPC64 BE but for the time being something goes wrong. In the beginning I had a segfaut hence the first patch. But I still get no mcount section in the files.

Since PPC64 BE uses older elfv1 ABI, it prepends a dot to symbols. And so, the relocation records in case of PPC64BE point to "._mcount", rather than just "_mcount". We should be looking for "._mcount" to be able to generate mcount_loc section in the files.

Like:

tools/objtool/check.c +1 -1
index 70be5a72e838..7da5bf8c7236 100644
@@ -2185,7 +2185,7 @@ static int classify_symbols(struct objtool_file 
 *file)
                         if (arch_is_retpoline(func))
                                 func->retpoline_thunk = true;
 
-                       if ((!strcmp(func->name, "__fentry__")) || 
 (!strcmp(func->name, "_mcount")))
+                       if ((!strcmp(func->name, "__fentry__")) || 
 (!strcmp(func->name, "_mcount")) || (!strcmp(func->name, "._mcount")))

                                func->fentry = true;

Quoted 6 lines

                        if (is_profiling_func(func->name))

With this change, I could see __mcount_loc section being generated in individual ppc64be object files.

Or should we implement an equivalent of arch_ftrace_match_adjust() in objtool ?

Christophe

#17 lore raw
Quoted 34 lines · Christophe Leroy

Hi Sathvika,

Le 25/05/2022 à 12:14, Sathvika Vasireddy a écrit :

Quoted 31 lines

Hi Christophe,

Quoted 6 lines · Christophe Leroy

This draft series adds PPC32 support to Sathvika's series. Verified on pmac32 on QEMU.

It should in principle also work for PPC64 BE but for the time being something goes wrong. In the beginning I had a segfaut hence the first patch. But I still get no mcount section in the files.

Since PPC64 BE uses older elfv1 ABI, it prepends a dot to symbols. And so, the relocation records in case of PPC64BE point to "._mcount", rather than just "_mcount". We should be looking for "._mcount" to be able to generate mcount_loc section in the files.

Like:

tools/objtool/check.c +1 -1
index 70be5a72e838..7da5bf8c7236 100644
@@ -2185,7 +2185,7 @@ static int classify_symbols(struct objtool_file
 *file)
                          if (arch_is_retpoline(func))
                                  func->retpoline_thunk = true;
 
-                       if ((!strcmp(func->name, "__fentry__")) ||
 (!strcmp(func->name, "_mcount")))
+                       if ((!strcmp(func->name, "__fentry__")) ||
 (!strcmp(func->name, "_mcount")) || (!strcmp(func->name, "._mcount")))
                                  func->fentry = true;
Quoted 8 lines
Quoted 6 lines

                        if (is_profiling_func(func->name))

With this change, I could see __mcount_loc section being generated in individual ppc64be object files.

Or should we implement an equivalent of arch_ftrace_match_adjust() in objtool ?

Yeah, I think it makes more sense if we make it arch specific. Thanks for the suggestion. I'll make this change in next revision :-)

- Sathvika

#18 lore raw

Le 25/05/2022 à 20:12, Sathvika Vasireddy a écrit :

Quoted 39 lines · Christophe Leroy
Quoted 37 lines

Hi Sathvika,

Le 25/05/2022 à 12:14, Sathvika Vasireddy a écrit :

Quoted 34 lines

Hi Christophe,

Quoted 6 lines · Christophe Leroy

This draft series adds PPC32 support to Sathvika's series. Verified on pmac32 on QEMU.

It should in principle also work for PPC64 BE but for the time being something goes wrong. In the beginning I had a segfaut hence the first patch. But I still get no mcount section in the files.

Since PPC64 BE uses older elfv1 ABI, it prepends a dot to symbols. And so, the relocation records in case of PPC64BE point to "._mcount", rather than just "_mcount". We should be looking for "._mcount" to be able to generate mcount_loc section in the files.

Like:

tools/objtool/check.c +1 -1
index 70be5a72e838..7da5bf8c7236 100644
@@ -2185,7 +2185,7 @@ static int classify_symbols(struct objtool_file
 *file)
                           if (arch_is_retpoline(func))
                                   func->retpoline_thunk = true;
 
-                       if ((!strcmp(func->name, "__fentry__")) ||
 (!strcmp(func->name, "_mcount")))
+                       if ((!strcmp(func->name, "__fentry__")) ||
 (!strcmp(func->name, "_mcount")) || (!strcmp(func->name, "._mcount")))

                                  func->fentry = true;

                          if (is_profiling_func(func->name))

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

With this change, I could see __mcount_loc section being generated in individual ppc64be object files.

Or should we implement an equivalent of arch_ftrace_match_adjust() in objtool ?

Yeah, I think it makes more sense if we make it arch specific. Thanks for the suggestion. I'll make this change in next revision :-)

Do you have any idea when you plan to send next revision ?

I'm really looking forward to submitting the inline static calls on top of your series.

Thanks
Christophe

#19 lore raw

Hi Christophe,

Quoted 4 lines · Christophe Leroy

Do you have any idea when you plan to send next revision ?

I'm really looking forward to submitting the inline static calls on top of your series.

I'm planning to send RFC v3 next week.

- Sathvika

#20 lore raw

Hi Sathvika

Le 18/06/2022 à 06:56, Sathvika Vasireddy a écrit :

Quoted 10 lines

Hi Christophe,

Quoted 4 lines · Christophe Leroy

Do you have any idea when you plan to send next revision ?

I'm really looking forward to submitting the inline static calls on top of your series.

I'm planning to send RFC v3 next week.

Is everything going ok ? Don't hesitate if you need help.

Christophe