[Ltrace-devel] [PATCH 3/8] Break out the symbol info gathering into a backend call

Petr Machata pmachata at redhat.com
Wed Sep 26 23:29:11 UTC 2012


edgar.iglesias at gmail.com writes:

> +/* The following callback has to be implemented in backend if arch.h
> + * defines ARCH_HAVE_GET_SYM_INFO.
> + *
> + * This is called for every PLT relocation R in ELF file LTE, that
> + * ltrace is about to add to it's internal representation of the
> + * program under trace.
> + * The corresponding PLT entry is for sym_index-th relocation in the file.
> + *
> + * If this function returns plt_default, PLT address is obtained by
> + * calling arch_plt_sym_val, and symbol is allocated.  If plt_ok or
> + * plt_default are returned, the chain of symbols passed back in RET
> + * is added to library under construction.  */
> +int arch_get_sym_info(struct ltelf *lte, const char *filename,
> +		      GElf_Rela *rela, GElf_Sym *sym, size_t sym_index);
> +

The last paragraph doesn't seem to apply to this function.  The comment
also doesn't really explain what the function should do and what are
legitimate return values.  Presumably it should initialize RELA and SYM?
If that is so, then sym_index (as input argument) should come before
them.

I'm fine with the overall intention of making this configurable.

> +		err = arch_get_sym_info(lte, filename, &rela, &sym, i);
> +		if (err)
> +			continue; /* Skip this entry.  */

Error signalling should be 0 for success or a negative value for
failure.  That's how it's done in other cases.  This particular code
should be:

+		if (arch_get_sym_info(lte, filename, &rela, &sym, i) < 0)
+			continue; /* Skip this entry.  */

Thanks,
PM



More information about the Ltrace-devel mailing list