[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241126064458.7ugwqfx5vhnwzvbi@jpoimboe>
Date: Mon, 25 Nov 2024 22:44:58 -0800
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: Huacai Chen <chenhuacai@...nel.org>,
Peter Zijlstra <peterz@...radead.org>, loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 01/10] objtool: Handle various symbol types of rodata
On Fri, Nov 22, 2024 at 12:49:56PM +0800, Tiezhu Yang wrote:
> @@ -2094,12 +2095,19 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
> if (prev_offset && reloc_offset(reloc) != prev_offset + 8)
> break;
>
> + if (reloc->sym->type == STT_SECTION) {
> + /* Addend field in the relocation entry associated with the symbol */
> + offset = reloc_addend(reloc);
> + } else {
> + /* The address of the symbol in the relocation entry */
> + offset = reloc->sym->offset;
The comments don't seem helpful.
In the case of STT_SECTION, sym->offset is always zero. Therefore the
if-else can be converted to a simple unconditional statement:
offset = reloc->sym->offset + reloc_addend(reloc);
'prev_offset' needs to be updated as well.
> @@ -2137,6 +2145,7 @@ static struct reloc *find_jump_table(struct objtool_file *file,
> {
> struct reloc *table_reloc;
> struct instruction *dest_insn, *orig_insn = insn;
> + unsigned long offset;
>
> /*
> * Backward search using the @first_jump_src links, these help avoid
> @@ -2160,7 +2169,16 @@ static struct reloc *find_jump_table(struct objtool_file *file,
> table_reloc = arch_find_switch_table(file, insn);
> if (!table_reloc)
> continue;
> - dest_insn = find_insn(file, table_reloc->sym->sec, reloc_addend(table_reloc));
> +
> + if (table_reloc->sym->type == STT_SECTION) {
> + /* Addend field in the relocation entry associated with the symbol */
> + offset = reloc_addend(table_reloc);
> + } else {
> + /* The address of the symbol in the relocation entry */
> + offset = table_reloc->sym->offset;
> + }
Same comment here.
--
Josh
Powered by blists - more mailing lists