From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753705AbcBCN5C (ORCPT ); Wed, 3 Feb 2016 08:57:02 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35568 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751837AbcBCN5A (ORCPT ); Wed, 3 Feb 2016 08:57:00 -0500 Date: Wed, 3 Feb 2016 22:55:51 +0900 From: Namhyung Kim To: "Wangnan (F)" Cc: acme@kernel.org, adrian.hunter@intel.com, dev@codyps.com, hekuang@huawei.com, kirr@nexedi.com, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Jiri Olsa , Masami Hiramatsu , Li Zefan , pi3orama@163.com Subject: Re: [PATCH 2/2] perf tools: Adjust symbol for shared objects Message-ID: <20160203135551.GA2068@danjae.kornet> References: <1454403366-27055-1-git-send-email-wangnan0@huawei.com> <1454403366-27055-3-git-send-email-wangnan0@huawei.com> <20160202151814.GD4627@danjae.kornet> <56B1621B.9070100@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <56B1621B.9070100@huawei.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Feb 03, 2016 at 10:12:43AM +0800, Wangnan (F) wrote: > > > On 2016/2/2 23:18, Namhyung Kim wrote: > >On Tue, Feb 02, 2016 at 08:56:06AM +0000, Wang Nan wrote: > >>He Kuang reported a problem that perf fails to get correct symbol on > >>Android platform in [1]. The problem can be reproduced on normal x86_64 > >>platform. I will describe the reproducing steps in detail at the end of > >>commit message. > >> > >>The reason of this problem is the missing of symbol adjustment for normal > >>shared objects. In most of the cases it works correctly, but when > >>'.text' section have different 'address' and 'offset' the result is > >>wrong. I checked all shared objects in my working platform, only wine > >>dll objects and debug objects (in .debug) have this problem. However, > >>it is common on Android. For example: > >> > >> $ readelf -S ./libsurfaceflinger.so | grep \.text > >> [10] .text PROGBITS 0000000000029030 00012030 > >> > >>This patch enables symbol adjustment for dynamic objects so the symbol > >>address got from elfutils would be adjusted correctly. > >> > >>Steps to reproduce the problem: > >> > >> $ cat << EOF > ./Makefile > >>PWD := $(shell pwd) > >>LDFLAGS += "-Wl,-rpath=$(PWD)" > >>CFLAGS += -g > >>main: main.c libbuggy.so > >>libbuggy.so: buggy.c > >> gcc -g -shared -fPIC -Wl,-Ttext-segment=0x200000 $< -o $@ > >>clean: > >> rm -rf main libbuggy.so *.o > >>EOF > >> > >> $ cat << EOF > ./buggy.c > >>int fib(int x) > >>{ > >> return (x == 0) ? 1 : (x == 1) ? 1 : fib(x - 1) + fib(x - 2); > >>} > >>EOF > >> > >> $ cat << EOF > ./main.c > >> #include > >> > >>extern int fix(int x); > >s/fix/fib/ ? > > Thank you. Have you really tested this program? Nope, but I've been thinking that the symbol resolution code needs to be updated or fixed. Thanks, Namhyung