Skip to content

Commit 894e48c

Browse files
author
Ingo Molnar
committed
objtool: Constify 'struct elf *' parameters
In preparation to parallelize certain parts of objtool, map out which uses of various data structures are read-only vs. read-write. As a first step constify 'struct elf' pointer passing, most of the secondary uses of it in find_symbol_*() methods are read-only. Also, while at it, better group the 'struct elf' handling methods in elf.h. Acked-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sami Tolvanen <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0cc9ac8 commit 894e48c

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

tools/objtool/elf.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int symbol_by_offset(const void *key, const struct rb_node *node)
127127
return 0;
128128
}
129129

130-
struct section *find_section_by_name(struct elf *elf, const char *name)
130+
struct section *find_section_by_name(const struct elf *elf, const char *name)
131131
{
132132
struct section *sec;
133133

@@ -217,7 +217,7 @@ struct symbol *find_func_containing(struct section *sec, unsigned long offset)
217217
return NULL;
218218
}
219219

220-
struct symbol *find_symbol_by_name(struct elf *elf, const char *name)
220+
struct symbol *find_symbol_by_name(const struct elf *elf, const char *name)
221221
{
222222
struct symbol *sym;
223223

@@ -228,7 +228,7 @@ struct symbol *find_symbol_by_name(struct elf *elf, const char *name)
228228
return NULL;
229229
}
230230

231-
struct rela *find_rela_by_dest_range(struct elf *elf, struct section *sec,
231+
struct rela *find_rela_by_dest_range(const struct elf *elf, struct section *sec,
232232
unsigned long offset, unsigned int len)
233233
{
234234
struct rela *rela, *r = NULL;
@@ -257,7 +257,7 @@ struct rela *find_rela_by_dest_range(struct elf *elf, struct section *sec,
257257
return NULL;
258258
}
259259

260-
struct rela *find_rela_by_dest(struct elf *elf, struct section *sec, unsigned long offset)
260+
struct rela *find_rela_by_dest(const struct elf *elf, struct section *sec, unsigned long offset)
261261
{
262262
return find_rela_by_dest_range(elf, sec, offset, 1);
263263
}
@@ -769,7 +769,7 @@ int elf_rebuild_rela_section(struct section *sec)
769769
return 0;
770770
}
771771

772-
int elf_write(struct elf *elf)
772+
int elf_write(const struct elf *elf)
773773
{
774774
struct section *sec;
775775
Elf_Scn *s;

tools/objtool/elf.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,22 @@ static inline u32 rela_hash(struct rela *rela)
114114
}
115115

116116
struct elf *elf_read(const char *name, int flags);
117-
struct section *find_section_by_name(struct elf *elf, const char *name);
117+
struct section *elf_create_section(struct elf *elf, const char *name, size_t entsize, int nr);
118+
struct section *elf_create_rela_section(struct elf *elf, struct section *base);
119+
void elf_add_rela(struct elf *elf, struct rela *rela);
120+
int elf_write(const struct elf *elf);
121+
void elf_close(struct elf *elf);
122+
123+
struct section *find_section_by_name(const struct elf *elf, const char *name);
118124
struct symbol *find_func_by_offset(struct section *sec, unsigned long offset);
119125
struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset);
120-
struct symbol *find_symbol_by_name(struct elf *elf, const char *name);
126+
struct symbol *find_symbol_by_name(const struct elf *elf, const char *name);
121127
struct symbol *find_symbol_containing(struct section *sec, unsigned long offset);
122-
struct rela *find_rela_by_dest(struct elf *elf, struct section *sec, unsigned long offset);
123-
struct rela *find_rela_by_dest_range(struct elf *elf, struct section *sec,
128+
struct rela *find_rela_by_dest(const struct elf *elf, struct section *sec, unsigned long offset);
129+
struct rela *find_rela_by_dest_range(const struct elf *elf, struct section *sec,
124130
unsigned long offset, unsigned int len);
125131
struct symbol *find_func_containing(struct section *sec, unsigned long offset);
126-
struct section *elf_create_section(struct elf *elf, const char *name, size_t
127-
entsize, int nr);
128-
struct section *elf_create_rela_section(struct elf *elf, struct section *base);
129132
int elf_rebuild_rela_section(struct section *sec);
130-
int elf_write(struct elf *elf);
131-
void elf_close(struct elf *elf);
132-
void elf_add_rela(struct elf *elf, struct rela *rela);
133133

134134
#define for_each_sec(file, sec) \
135135
list_for_each_entry(sec, &file->elf->sections, list)

0 commit comments

Comments
 (0)