Use 'const char *' where applicable. Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx> --- tools/objtool/arch/loongarch/decode.c | 2 +- tools/objtool/arch/powerpc/decode.c | 2 +- tools/objtool/arch/x86/decode.c | 2 +- tools/objtool/elf.c | 6 +++--- tools/objtool/include/objtool/arch.h | 2 +- tools/objtool/include/objtool/elf.h | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/objtool/arch/loongarch/decode.c b/tools/objtool/arch/loongarch/decode.c index aee479d2191c..ef09996c772e 100644 --- a/tools/objtool/arch/loongarch/decode.c +++ b/tools/objtool/arch/loongarch/decode.c @@ -10,7 +10,7 @@ #define EM_LOONGARCH 258 #endif -int arch_ftrace_match(char *name) +int arch_ftrace_match(const char *name) { return !strcmp(name, "_mcount"); } diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c index 53b55690f320..29e05ad1b8b6 100644 --- a/tools/objtool/arch/powerpc/decode.c +++ b/tools/objtool/arch/powerpc/decode.c @@ -9,7 +9,7 @@ #include <objtool/builtin.h> #include <objtool/endianness.h> -int arch_ftrace_match(char *name) +int arch_ftrace_match(const char *name) { return !strcmp(name, "_mcount"); } diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 3a1d80a7878d..1b24b05eff09 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -23,7 +23,7 @@ #include <objtool/builtin.h> #include <arch/elf.h> -int arch_ftrace_match(char *name) +int arch_ftrace_match(const char *name) { return !strcmp(name, "__fentry__"); } diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 3d27983dc908..b42ee4ef7015 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -814,7 +814,7 @@ elf_create_section_symbol(struct elf *elf, struct section *sec) return sym; } -static int elf_add_string(struct elf *elf, struct section *strtab, char *str); +static int elf_add_string(struct elf *elf, struct section *strtab, const char *str); struct symbol * elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size) @@ -1048,7 +1048,7 @@ struct elf *elf_open_read(const char *name, int flags) return NULL; } -static int elf_add_string(struct elf *elf, struct section *strtab, char *str) +static int elf_add_string(struct elf *elf, struct section *strtab, const char *str) { Elf_Data *data; Elf_Scn *s; @@ -1073,7 +1073,7 @@ static int elf_add_string(struct elf *elf, struct section *strtab, char *str) return -1; } - data->d_buf = str; + data->d_buf = strdup(str); data->d_size = strlen(str) + 1; data->d_align = 1; diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h index 0b303eba660e..f48f5109abb1 100644 --- a/tools/objtool/include/objtool/arch.h +++ b/tools/objtool/include/objtool/arch.h @@ -69,7 +69,7 @@ struct stack_op { struct instruction; -int arch_ftrace_match(char *name); +int arch_ftrace_match(const char *name); void arch_initial_func_cfi_state(struct cfi_init_state *state); diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index 2b8a69de4db8..a027fc34d605 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -40,7 +40,7 @@ struct section { struct section *base, *rsec; struct symbol *sym; Elf_Data *data; - char *name; + const char *name; int idx; bool _changed, text, rodata, noinstr, init, truncate; struct reloc *relocs; @@ -53,7 +53,7 @@ struct symbol { struct elf_hash_node name_hash; GElf_Sym sym; struct section *sec; - char *name; + const char *name; unsigned int idx, len; unsigned long offset; unsigned long __subtree_last; @@ -84,7 +84,7 @@ struct elf { GElf_Ehdr ehdr; int fd; bool changed; - char *name; + const char *name; unsigned int num_files; struct list_head sections; unsigned long num_relocs; -- 2.45.2