lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <832fe56f-1688-d128-50dd-3f668815a248@loongson.cn>
Date: Wed, 11 Dec 2024 11:11:28 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: Huacai Chen <chenhuacai@...nel.org>, Peter Zijlstra
 <peterz@...radead.org>, loongarch@...ts.linux.dev,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 02/10] objtool: Handle different entry size of rodata

On 12/10/2024 03:54 AM, Josh Poimboeuf wrote:
> On Sat, Dec 07, 2024 at 09:59:07AM +0800, Tiezhu Yang wrote:
>> +__weak unsigned int arch_reloc_size(struct reloc *reloc)
>> +{
>> +	return 8;
>> +}
>
> Instead of making a weak function, each arch should have an explicit
> definition of this function, as it's not always 8:
>
> - x86 has R_X86_64_PC32 and R_X86_64_PLT32 which are 4 bytes.
>
> - 32-bit powerpc
>
> - 64-bit powerpc has R_PPC64_REL32

For x86, like this, I am not sure "case R_X86_64_32" is necessary,
leave it as is if no objections, please let me know if it should be
removed.

unsigned int arch_reloc_size(struct reloc *reloc)
{
         switch (reloc_type(reloc)) {
         case R_X86_64_32:
         case R_X86_64_PC32:
         case R_X86_64_PLT32:
                 return 4;
         default:
                 return 8;
         }
}

For ppc, like this:

unsigned int arch_reloc_size(struct reloc *reloc)
{
         switch (reloc_type(reloc)) {
         case R_PPC_REL32:
         case R_PPC64_REL32:
                 return 4;
         default:
                 return 8;
         }
}

>
>> @@ -1967,8 +1973,10 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
>>  		if (reloc != table && reloc == next_table)
>>  			break;
>>
>> +		entry_size = arch_reloc_size(reloc);
>> +
>>  		/* Make sure the table entries are consecutive: */
>> -		if (prev_offset && reloc_offset(reloc) != prev_offset + 8)
>> +		if (prev_offset && reloc_offset(reloc) != prev_offset + entry_size)
>>  			break;
>
> No need to use a variable here, just call arch_reloc_size() directly.

OK, will do it.

Thanks,
Tiezhu


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ