Skip to content

Commit

Permalink
s390/tools: handle rela R_390_GOTPCDBL/R_390_GOTOFF64
Browse files Browse the repository at this point in the history
lkp test robot reported unhandled relocation type: R_390_GOTPCDBL, when
kernel is built with -fno-PIE. relocs tool reads vmlinux and handles
absolute relocations.  PC relative relocs doesn't need adjustment.

Also, the R_390_GOTPCDBL/R_390_GOTOFF64 relocations are present
currently only when KASAN is enabled.

The following program can create a R_390_GOTPCDBL/R_390_GOTOFF64 reloc
(with fPIE/fPIC).

void funcb(int *b) {
  *b = *b + 100;
}

void gen_gotoff(void)
{
  int b = 10;
  funcb (&b);
}

gcc -c sample.c -fPIC -fsanitize=kernel-address --param asan-stack=1

The above example (built with -fPIC) was linked to one of the
built-in.a (built with -fno-PIE) and checked for correctness with kaslr
enabled. Both the relocs turns out relative and can be skipped.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402221404.T2TGs8El-lkp@intel.com/
Fixes: 55dc65b ("s390: add relocs tool")
Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
  • Loading branch information
Sumanth Korikkar authored and Heiko Carstens committed Mar 7, 2024
1 parent cb0cd4e commit fa9e313
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/s390/tools/relocs.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ static int do_reloc(struct section *sec, Elf_Rel *rel)
case R_390_PC32DBL:
case R_390_PLT32DBL:
case R_390_GOTENT:
case R_390_GOTPCDBL:
case R_390_GOTOFF64:
break;
case R_390_64:
add_reloc(&relocs64, offset);
Expand Down

0 comments on commit fa9e313

Please sign in to comment.