linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Sathvika Vasireddy <sv@linux.vnet.ibm.com>
Cc: "peterz@infradead.org" <peterz@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	"aik@ozlabs.ru" <aik@ozlabs.ru>,
	Sathvika Vasireddy <sv@linux.ibm.com>,
	"jpoimboe@redhat.com" <jpoimboe@redhat.com>,
	"naveen.n.rao@linux.vnet.ibm.com"
	<naveen.n.rao@linux.vnet.ibm.com>,
	"mbenes@suse.cz" <mbenes@suse.cz>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	Chen Zhongjin <chenzhongjin@huawei.com>
Subject: Re: [RFC PATCH 4/4] objtool/powerpc: Add --mcount specific implementation
Date: Tue, 31 May 2022 08:20:41 +0200	[thread overview]
Message-ID: <c1e2cf35-2a8d-87e6-3a7e-7f144392db23@csgroup.eu> (raw)
In-Reply-To: <f1decbb7-b441-a241-469a-4ba118e08212@csgroup.eu>



Le 25/05/2022 à 19:27, Christophe Leroy a écrit :
> 
> 
> Le 24/05/2022 à 15:33, Christophe Leroy a écrit :
>>
>>
>> Le 24/05/2022 à 13:00, Sathvika Vasireddy a écrit :
>>>>
>>>>> +{
>>>>> +    switch (elf->ehdr.e_machine) {
>>>>> +    case EM_X86_64:
>>>>> +            return R_X86_64_64;
>>>>> +    case EM_PPC64:
>>>>> +            return R_PPC64_ADDR64;
>>>>> +    default:
>>>>> +            WARN("unknown machine...");
>>>>> +            exit(-1);
>>>>> +    }
>>>>> +}
>>>> Wouldn't it be better to make that function arch specific ?
>>>
>>> This is so that we can support cross architecture builds.
>>>
>>
>>
>> I'm not sure I follow you here.
>>
>> This is only based on the target, it doesn't depend on the build host so
>> I can't the link with cross arch builds.
>>
>> The same as you have arch_decode_instruction(), you could have
>> arch_elf_reloc_type_long()
>> It would make sense indeed, because there is no point in supporting X86
>> relocation when you don't support X86 instruction decoding.
>>
> 
> Could simply be some macro defined in 
> tools/objtool/arch/powerpc/include/arch/elf.h and 
> tools/objtool/arch/x86/include/arch/elf.h
> 
> The x86 version would be:
> 
> #define R_ADDR(elf) R_X86_64_64
> 
> And the powerpc version would be:
> 
> #define R_ADDR(elf) (elf->ehdr.e_machine == EM_PPC64 ? R_PPC64_ADDR64 : 
> R_PPC_ADDR32)
> 

Well, looking once more, and taking into account the patch from Chen 
https://lore.kernel.org/lkml/20220531020744.236970-4-chenzhongjin@huawei.com/

It would be easier to just define two macros:

#define R_ABS64 R_PPC64_ADDR64
#define R_ABS32 R_PPC_ADDR32

And then in the caller, as we know the size, do something like

	size == sizeof(u64) ? R_ABS64 : R_ABS32;

Christophe

  reply	other threads:[~2022-05-31  6:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23 17:55 [RFC PATCH 0/4] objtool: Enable and implement --mcount option on powerpc Sathvika Vasireddy
2022-05-23 17:55 ` [RFC PATCH 1/4] objtool: Add --mnop as an option to --mcount Sathvika Vasireddy
2022-05-24  8:54   ` Christophe Leroy
2022-05-24 10:15     ` Naveen N. Rao
2022-05-24 10:20       ` Christophe Leroy
2022-05-24 10:31         ` Naveen N. Rao
2022-05-25 11:36           ` Peter Zijlstra
2022-05-26 11:51             ` Naveen N. Rao
2022-05-23 17:55 ` [RFC PATCH 2/4] objtool: Enable objtool to run only on files with ftrace enabled Sathvika Vasireddy
2022-05-24  8:57   ` Christophe Leroy
2022-05-24 10:53     ` Sathvika Vasireddy
2022-05-24 13:28       ` Christophe Leroy
2022-05-23 17:55 ` [RFC PATCH 3/4] objtool/powerpc: Enable objtool to be built on ppc Sathvika Vasireddy
2022-05-24  9:13   ` Christophe Leroy
2022-05-23 17:55 ` [RFC PATCH 4/4] objtool/powerpc: Add --mcount specific implementation Sathvika Vasireddy
2022-05-24  9:35   ` Christophe Leroy
2022-05-24 11:00     ` Sathvika Vasireddy
2022-05-24 13:33       ` Christophe Leroy
2022-05-25 17:27         ` Christophe Leroy
2022-05-31  6:20           ` Christophe Leroy [this message]
2022-06-16 13:34             ` Naveen N. Rao
2022-06-16 13:40               ` Christophe Leroy
2022-06-16 13:57                 ` Peter Zijlstra
2022-06-16 14:06                   ` Christophe Leroy
2022-06-17 14:04                     ` Naveen N. Rao

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=c1e2cf35-2a8d-87e6-3a7e-7f144392db23@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=aik@ozlabs.ru \
    --cc=chenzhongjin@huawei.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mbenes@suse.cz \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sv@linux.ibm.com \
    --cc=sv@linux.vnet.ibm.com \
    /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).