[PATCH v2] readelf: Don't change the symbol table
H.J. Lu
hjl.tools@gmail.com
Wed Sep 3 13:48:37 GMT 2025
On Wed, Sep 3, 2025 at 6:19 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 03.09.2025 15:05, H.J. Lu wrote:
> > @@ -1880,13 +1879,13 @@ dump_relr_relocations (Filedata * filedata,
> > uint64_t relr_size,
> > int relr_entsize,
> > uint64_t relr_offset,
> > - Elf_Internal_Sym * symtab,
> > + uint64_t * relrs,
>
> With this effectively owned by the caller, if you really want to keep
> freeing it at the bottom of this function, I think at the very least
> at the call site the variable would want setting to NULL after the
> call, even if that's just for documentation (as the compiler may be
> able to figure out that it can drop that assignment).
Fixed in the v3 patch.
> > @@ -2076,12 +2079,14 @@ dump_relr_relocations (Filedata * filedata,
> > break;
> > }
> >
> > - if (symtab != NULL)
> > + Elf_Internal_Sym *symtab = NULL;
> > + if (symtab_p != NULL)
> > {
> > /* Symbol tables are not sorted on address, but we want a quick lookup
> > for the symbol associated with each address computed below, so sort
> > - the table then filter out unwanted entries. FIXME: This assumes that
> > - the symbol table will not be used later on for some other purpose. */
> > + the table then filter out unwanted entries. */
> > + symtab = xmalloc (nsyms * sizeof (*symtab));
> > + memcpy (symtab, symtab_p, nsyms * sizeof (*symtab));
>
> As before - xmemdup()?
>
Fixed in the v3 patch.
Thanks.
--
H.J.
More information about the Binutils
mailing list