On Tue, May 13, 2025 at 10:49:59PM +0800, laokz wrote: > 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. Is that a problem? I don't believe I've ever seen two relocations for the same offset. -- Josh