Re: [PATCH 1/2] objtool: Rename rela to reloc
On Fri, May 29, 2020 at 05:52:44PM -0700, Matt Helsley wrote: > So I was rebasing my future patches and I found a few spots where > objtool warning strings and code comments weren't fixed-up to > consistent. Here's the new, complete regex -- it includes the original > changes and the missed bits (e.g. note the new substitution for @rela > comments): Thanks, fixed. -- Josh
Re: [PATCH 1/2] objtool: Rename rela to reloc
On Fri, May 29, 2020 at 06:22:00PM -0500, Josh Poimboeuf wrote: > On Fri, May 29, 2020 at 02:01:13PM -0700, Matt Helsley wrote: > > Before supporting additional relocation types rename the relevant > > types and functions from "rela" to "reloc". This work be done with > > the following regex: > > > > sed -i -e 's/struct rela/struct reloc/g' \ > > -e 's/\([_\*]\)rela\(s\{0,1\}\)/\1reloc\2/g' \ > > -e 's/tmprela\(s\{0,1\}\)/tmpreloc\1/g' \ > > -e 's/relasec/relocsec/g' \ > > -e 's/rela_list/reloc_list/g' \ > > -e 's/rela_hash/reloc_hash/g' \ > > -e 's/add_rela/add_reloc/g' \ > > -e 's/rela->/reloc->/g' \ > > -e '/rela[,\.]/{ s/\([^\.>]\)rela\([\.,]\)/\1reloc\2/g ; }' \ > > -e 's/rela =/reloc =/g' \ > > -e 's/relas =/relocs =/g' \ > > -e 's/relas\[/relocs[/g' \ > > -e 's/relaname =/relocname =/g' \ > > -e 's/= rela\;/= reloc\;/g' \ > > -e 's/= relas\;/= relocs\;/g' \ > > -e 's/= relaname\;/= relocname\;/g' \ > > -e 's/, rela)/, reloc)/g' \ > > -e 's/, relaname/, relocname/g' \ > > -e 's/sec->rela/sec->reloc/g' \ > > -e 's/(\(!\{0,1\}\)rela/(\1reloc/g' \ > > arch.h \ > > arch/x86/decode.c \ > > check.c \ > > check.h \ > > elf.c \ > > elf.h \ > > orc_gen.c \ > > special.c \ > > Holy regex! Thanks for doing that :-) So I was rebasing my future patches and I found a few spots where objtool warning strings and code comments weren't fixed-up to consistent. Here's the new, complete regex -- it includes the original changes and the missed bits (e.g. note the new substitution for @rela comments): sed -i -e 's/struct rela/struct reloc/g' \ -e 's/\([_\*]\)rela\(s\{0,1\}\)/\1reloc\2/g' \ -e 's/tmprela\(s\{0,1\}\)/tmpreloc\1/g' \ -e 's/relasec/relocsec/g' \ -e 's/rela_list/reloc_list/g' \ -e 's/rela_hash/reloc_hash/g' \ -e 's/add_rela/add_reloc/g' \ -e 's/rela->/reloc->/g' \ -e '/rela[,\.]/{ s/\([^\.>]\)rela\([\.,]\)/\1reloc\2/g ; }' \ -e 's/rela =/reloc =/g' \ -e 's/relas =/relocs =/g' \ -e 's/relas\[/relocs[/g' \ -e 's/relaname =/relocname =/g' \ -e 's/= rela\;/= reloc\;/g' \ -e 's/= relas\;/= relocs\;/g' \ -e 's/= relaname\;/= relocname\;/g' \ -e 's/, rela)/, reloc)/g' \ -e 's/\([ @]\)rela\([ "]\)/\1reloc\2/g' \ -e 's/ rela$/ reloc/g' \ -e 's/, relaname/, relocname/g' \ -e 's/sec->rela/sec->reloc/g' \ -e 's/(\(!\{0,1\}\)rela/(\1reloc/g' \ arch.h \ arch/x86/decode.c \ check.c \ check.h \ elf.c \ elf.h \ orc_gen.c \ special.c If you want to fixup this commit you could just re-run the regex after applying it but before applying the next commit. Cheers, -Matt Helsley
Re: [PATCH 1/2] objtool: Rename rela to reloc
On Fri, May 29, 2020 at 02:01:13PM -0700, Matt Helsley wrote: > Before supporting additional relocation types rename the relevant > types and functions from "rela" to "reloc". This work be done with > the following regex: > > sed -i -e 's/struct rela/struct reloc/g' \ > -e 's/\([_\*]\)rela\(s\{0,1\}\)/\1reloc\2/g' \ > -e 's/tmprela\(s\{0,1\}\)/tmpreloc\1/g' \ > -e 's/relasec/relocsec/g' \ > -e 's/rela_list/reloc_list/g' \ > -e 's/rela_hash/reloc_hash/g' \ > -e 's/add_rela/add_reloc/g' \ > -e 's/rela->/reloc->/g' \ > -e '/rela[,\.]/{ s/\([^\.>]\)rela\([\.,]\)/\1reloc\2/g ; }' \ > -e 's/rela =/reloc =/g' \ > -e 's/relas =/relocs =/g' \ > -e 's/relas\[/relocs[/g' \ > -e 's/relaname =/relocname =/g' \ > -e 's/= rela\;/= reloc\;/g' \ > -e 's/= relas\;/= relocs\;/g' \ > -e 's/= relaname\;/= relocname\;/g' \ > -e 's/, rela)/, reloc)/g' \ > -e 's/, relaname/, relocname/g' \ > -e 's/sec->rela/sec->reloc/g' \ > -e 's/(\(!\{0,1\}\)rela/(\1reloc/g' \ > arch.h \ > arch/x86/decode.c \ > check.c \ > check.h \ > elf.c \ > elf.h \ > orc_gen.c \ > special.c \ Holy regex! Thanks for doing that :-) I'll run these through testing and merge. -- Josh
[PATCH 1/2] objtool: Rename rela to reloc
Before supporting additional relocation types rename the relevant types and functions from "rela" to "reloc". This work be done with the following regex: sed -i -e 's/struct rela/struct reloc/g' \ -e 's/\([_\*]\)rela\(s\{0,1\}\)/\1reloc\2/g' \ -e 's/tmprela\(s\{0,1\}\)/tmpreloc\1/g' \ -e 's/relasec/relocsec/g' \ -e 's/rela_list/reloc_list/g' \ -e 's/rela_hash/reloc_hash/g' \ -e 's/add_rela/add_reloc/g' \ -e 's/rela->/reloc->/g' \ -e '/rela[,\.]/{ s/\([^\.>]\)rela\([\.,]\)/\1reloc\2/g ; }' \ -e 's/rela =/reloc =/g' \ -e 's/relas =/relocs =/g' \ -e 's/relas\[/relocs[/g' \ -e 's/relaname =/relocname =/g' \ -e 's/= rela\;/= reloc\;/g' \ -e 's/= relas\;/= relocs\;/g' \ -e 's/= relaname\;/= relocname\;/g' \ -e 's/, rela)/, reloc)/g' \ -e 's/, relaname/, relocname/g' \ -e 's/sec->rela/sec->reloc/g' \ -e 's/(\(!\{0,1\}\)rela/(\1reloc/g' \ arch.h \ arch/x86/decode.c \ check.c \ check.h \ elf.c \ elf.h \ orc_gen.c \ special.c \ Notable exceptions which complicate the regex include gelf_* library calls and standard/expected section names which still use "rela" because they encode the type of relocation expected. Also, keep "rela" in the struct because it encodes a specific type of relocation we currently expect. It will eventually turn into a member of an anonymous union when a susequent patch adds implicit addend, or "rel", relocation support. Signed-off-by: Matt Helsley --- tools/objtool/arch.h| 2 +- tools/objtool/arch/x86/decode.c | 2 +- tools/objtool/check.c | 190 tools/objtool/check.h | 2 +- tools/objtool/elf.c | 134 +++--- tools/objtool/elf.h | 22 ++-- tools/objtool/orc_gen.c | 44 tools/objtool/special.c | 22 ++-- 8 files changed, 209 insertions(+), 209 deletions(-) diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h index eda15a5a285e..d0969a9328c2 100644 --- a/tools/objtool/arch.h +++ b/tools/objtool/arch.h @@ -82,6 +82,6 @@ bool arch_callee_saved_reg(unsigned char reg); unsigned long arch_jump_destination(struct instruction *insn); -unsigned long arch_dest_rela_offset(int addend); +unsigned long arch_dest_reloc_offset(int addend); #endif /* _ARCH_H */ diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 4b504fc90bbb..fe83d4c92825 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -67,7 +67,7 @@ bool arch_callee_saved_reg(unsigned char reg) } } -unsigned long arch_dest_rela_offset(int addend) +unsigned long arch_dest_reloc_offset(int addend) { return addend + 4; } diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 63d65a702900..4c39734b29ed 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -352,7 +352,7 @@ static struct instruction *find_last_insn(struct objtool_file *file, static int add_dead_ends(struct objtool_file *file) { struct section *sec; - struct rela *rela; + struct reloc *reloc; struct instruction *insn; /* @@ -370,24 +370,24 @@ static int add_dead_ends(struct objtool_file *file) if (!sec) goto reachable; - list_for_each_entry(rela, >rela_list, list) { - if (rela->sym->type != STT_SECTION) { + list_for_each_entry(reloc, >reloc_list, list) { + if (reloc->sym->type != STT_SECTION) { WARN("unexpected relocation symbol type in %s", sec->name); return -1; } - insn = find_insn(file, rela->sym->sec, rela->addend); + insn = find_insn(file, reloc->sym->sec, reloc->addend); if (insn) insn = list_prev_entry(insn, list); - else if (rela->addend == rela->sym->sec->len) { - insn = find_last_insn(file, rela->sym->sec); + else if (reloc->addend == reloc->sym->sec->len) { + insn = find_last_insn(file, reloc->sym->sec); if (!insn) { WARN("can't find unreachable insn at %s+0x%x", -rela->sym->sec->name, rela->addend); +reloc->sym->sec->name, reloc->addend); return -1; } } else { WARN("can't find unreachable insn at %s+0x%x", -rela->sym->sec->name,