[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_8AACB6DF7CFB7A9826455C093C0903B15207@qq.com>
Date: Tue, 13 May 2025 22:49:59 +0800
From: laokz <laokz@...mail.com>
To: Josh Poimboeuf <jpoimboe@...nel.org>, x86@...nel.org
Cc: linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.com>,
Miroslav Benes <mbenes@...e.cz>, Joe Lawrence <joe.lawrence@...hat.com>,
live-patching@...r.kernel.org, Song Liu <song@...nel.org>,
Jiri Kosina <jikos@...nel.org>, Marcos Paulo de Souza <mpdesouza@...e.com>,
Weinan Liu <wnliu@...gle.com>, Fazla Mehrab <a.mehrab@...edance.com>,
Chen Zhongjin <chenzhongjin@...wei.com>, Puranjay Mohan <puranjay@...nel.org>
Subject: Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for
diffing object files
On 5/10/2025 4:17 AM, Josh Poimboeuf wrote:
> +
> +#define sym_for_each_reloc(elf, sym, reloc) \
> + for (reloc = find_reloc_by_dest_range(elf, sym->sec, \
> + sym->offset, sym->len); \
> + reloc && reloc_offset(reloc) < sym->offset + sym->len; \
> + reloc = rsec_next_reloc(sym->sec->rsec, reloc))
This macro intents to walk through ALL relocations for the 'sym'. It
seems we have the assumption that, there is at most one single
relocation for the same offset and find_reloc_by_dest_range only needs
to do 'less than' offset comparison:
elf_hash_for_each_possible(reloc, reloc, hash,
sec_offset_hash(rsec, o)) {
if (reloc->sec != rsec)
continue;
if (reloc_offset(reloc) >= offset &&
reloc_offset(reloc) < offset + len) {
less than ==> if (!r || reloc_offset(reloc) < reloc_offset(r))
r = reloc;
Because if there were multiple relocations for the same offset, the
returned one would be the last one in section entry order(hash list has
reverse order against section order), then broken the intention.
Right?
Thanks,
laokz
Powered by blists - more mailing lists