[PATCH] readelf: Don't change the symbol table
H.J. Lu
hjl.tools@gmail.com
Wed Sep 3 13:08:40 GMT 2025
On Tue, Sep 2, 2025 at 11:09 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 02.09.2025 23:30, H.J. Lu wrote:
> > 1. Update dump_relr_relocations not to change the symbol table.
>
> I think it would nice to make such more explicit, by ...
>
> > @@ -1880,13 +1879,13 @@ dump_relr_relocations (Filedata * filedata,
> > uint64_t relr_size,
> > int relr_entsize,
> > uint64_t relr_offset,
> > + uint64_t * relrs,
> > Elf_Internal_Sym * symtab,
>
> ... making both of these pointer-to-const. That'll require some adjustment
> further down afaict. (For relrs the freeing then may want leaving to the
> caller when non-NULL was passed in, as casting away const-ness is awkward.)
I changed to
static bool
dump_relr_relocations (Filedata * filedata,
uint64_t relr_size,
int relr_entsize,
uint64_t relr_offset,
uint64_t * relrs,
const Elf_Internal_Sym * symtab_p,
uint64_t nsyms,
char * strtab,
uint64_t strtablen,
bool dump_reloc)
in the v2 patch. I kept "free (relrs)" in dump_relr_relocations since
it may be malloced in dump_relr_relocations.
> As a nit: The * on the newly added line look misplaced, compared to the
> other ones visible above as well as ...
>
> > uint64_t nsyms,
> > char * strtab,
>
> ... this one.
>
> Jan
--
H.J.
More information about the Binutils
mailing list