linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Tong Shen <endlessroad@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: Fix Symbol Address for ET_DYN
Date: Thu, 11 Sep 2014 12:01:23 -0300	[thread overview]
Message-ID: <20140911150123.GH10158@kernel.org> (raw)
In-Reply-To: <CAPp4yYwTHbXiypxR_1WJGS9DYQNJ24t_Ykdo_sfQ48Ak-K3Z7g@mail.gmail.com>

Em Fri, Sep 05, 2014 at 11:38:02AM -0700, Tong Shen escreveu:
> Hi linux-perf-users,
> 
> It's actually a patch, and I didn't find a development mailing list
> for perf, so I just post it here. If this is not the right place to

You can post it here, but please add the maintainers to the CC list, so
that we can more quickly see your message.

Comments below:

> post patches, could someone direct me to it? Thanks in advance!
> 
> In tools/perf/util/symbol-elf.c, we don't adjust symbol address for
> ET_DYN type of ELF files because we think ET_DYN is always
> relocatable.
> 
> But that's not necessarily true; there are some non-relocatable ET_DYN
> ELF files. For those files, we should still adjust symbol address.
 
> Suggested patch: (HTML subpart now allowed in this mailing list...)
 
> +++ b/perf-3.12.0/tools/perf/util/symbol-elf.c
> @@ -915,7 +915,10 @@ int dso__load_sym(struct dso *dso, struct map *map,

>  		if ((used_opd && runtime_ss->adjust_symbols)
> -				|| (!used_opd && syms_ss->adjust_symbols)) {
> +				|| (!used_opd && syms_ss->adjust_symbols)
> +				|| (syms_ss->ehdr.e_type == et_dyn
> +					&& shdr.sh_addr != shdr.sh_offset
> +					&& elf_sec__is_text(&shdr, secstrs))) {

Please try to follow kernel coding style in these tools, i.e. the &&
should be at the end, the expression on each line should be aligned just
after the opening parens.

If, like in this case, you find something not following that style, take
the opportunity to fix it :-)

But back to your change, I'll have to look at this code further, just
looking at the excerpt above I find it way too confusing, and your patch
makes it even more so...

Can you introduce some suitably named helper that has those extra
conditions you're adding now and then add it to this conditional?

I.e. make it somethine like:

-               if ((used_opd && runtime_ss->adjust_symbols)
-                               || (!used_opd && syms_ss->adjust_symbols)) {
+               if ((used_opd && runtime_ss->adjust_symbols) ||
+                   (!used_opd && syms_ss->adjust_symbols)   ||
+                   syms__some_suitable_name(syms_ss, &shdr)) {

And then add your explanation of these kinds of files as a comment over
this new function, please?

>  			pr_debug4("%s: adjusting symbol: st_value: %#" PRIx64 " "
>  				  "sh_addr: %#" PRIx64 " sh_offset: %#" PRIx64 "\n", __func__,
>  				  (u64)sym.st_value, (u64)shdr.sh_addr,

Best regards,

- Arnaldo

  parent reply	other threads:[~2014-09-11 15:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 18:38 Fix Symbol Address for ET_DYN Tong Shen
2014-09-05 18:40 ` Tong Shen
2014-09-11 15:01 ` Arnaldo Carvalho de Melo [this message]
2014-09-11 18:21   ` Tong Shen
2014-09-11 20:38     ` [PATCH 1/1] perf tools: " Arnaldo Carvalho de Melo
2014-09-15 18:06       ` Tong Shen
2014-09-25  0:28         ` Tong Shen
2014-09-26  5:45           ` Namhyung Kim
2014-09-26  5:53             ` Tong Shen
2014-09-29  2:33               ` Namhyung Kim
2014-09-29 18:13                 ` Tong Shen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140911150123.GH10158@kernel.org \
    --to=acme@kernel.org \
    --cc=endlessroad@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).