lkml.org 
[lkml]   [2022]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 5/8] objtool: reduce memory usage of struct reloc
Hi Rong,

On Thu, Dec 29, 2022 at 09:33:32AM +0800, Rong Tao wrote:
> Is this likely to cause most RELOC failures? As shown in the following
> example:
>
> #include <bfd.h>
> #include <stdio.h>
>
> int main(void)
> {
> printf("%d\n", BFD_RELOC_S12Z_OPR);
> return 0;
> }
>
> The BFD_RELOC_S12Z_OPR equal to 2366.

I'm not familiar with libbfd, so please correct me if I'm wrong.

To me BFD_RELOC_S12Z_OPR looks like a value that is only used by libbfd.
objtool does not use libbfd.

The only values that objtools should see for the relocation types are
the R_* constants from elf.h as they are used by the compiler and linker
in the raw elf binary files.

These never exceed the value 255, one byte. Indeed they seem to have
been explicitly chosen like this.

$ grep 'define R_.*NUM' /usr/include/elf.h
#define R_68K_NUM 43
#define R_386_NUM 44
#define R_SPARC_NUM 253
#define R_MIPS_NUM 128
#define R_ALPHA_NUM 46
#define R_ARM_NUM 256
#define R_390_NUM 62
#define R_CRIS_NUM 20
#define R_X86_64_NUM 43
#define R_MN10300_NUM 35
#define R_M32R_NUM 256 /* Keep this the last entry. */
#define R_TILEPRO_NUM 130
#define R_TILEGX_NUM 130
#define R_RISCV_NUM 59

These _NUM constants are the highest actually used values, plus one.
So all real values are smaller than 256.

Thomas

\
 
 \ /
  Last update: 2023-03-26 23:22    [W:0.086 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site