[Bug ld/24685] New: [RISCV] R_RISCV_CALL_PLT should not create a canonical PLT in -no-pie mode

2019-06-15 Thread maskray at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24685

Bug ID: 24685
   Summary: [RISCV] R_RISCV_CALL_PLT should not create a canonical
PLT in -no-pie mode
   Product: binutils
   Version: 2.33 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: maskray at google dot com
  Target Milestone: ---

A canonical PLT (the term is not widely used. I just saw it used by a few
people) in an executable has a section index of SHN_UNDEF but a non-zero
st_value. It is only used for pointer equality. Dynamic loaders
(musl/glibc/etc) resolve the symbol value to the canonical PLT.

% cat a.c
#include 
int main(){puts("hello");}

% riscv-gcc -fuse-ld=bfd -fpie -pie a.c -o a && readelf -W --dyn-s a | grep
puts
 2:  0 FUNCGLOBAL DEFAULT  UND puts
% riscv-gcc -fuse-ld=bfd -fpie -no-pie a.c -o a && readelf -W --dyn-s a | grep
puts
 1: 00010420 0 FUNCGLOBAL DEFAULT  UND puts

-fpie/-fpic produces an R_RISCV_CALL_PLT relocation. Because puts is not taken
address, its address in the executable is insignificant, the canonical PLT is
not necessary.

Other architectures (e.g. R_386_PC32 R_X86_64_PLT32 R_PPC64_REL24) don't create
a canonical PLT in this case, e.g.:

% gcc -fuse-ld=bfd -fpie -pie a.c -o a && readelf -W --dyn-s a | grep puts
 2:  0 FUNCGLOBAL DEFAULT  UND puts@GLIBC_2.2.5 (2)
% gcc -fuse-ld=bfd -fpie -no-pie a.c -o a && readelf -W --dyn-s a | grep puts
 1:  0 FUNCGLOBAL DEFAULT  UND puts@GLIBC_2.2.5 (2)


The semantics of R_RISCV_CALL_PLT need some refinement. A proposal to deprecate
R_RISCV_CALL is reported at
https://github.com/riscv/riscv-elf-psabi-doc/issues/98

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/24685] [RISCV] R_RISCV_CALL_PLT should not create a canonical PLT in -no-pie mode

2019-06-15 Thread maskray at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24685

Fangrui Song  changed:

   What|Removed |Added

 Target||riscv*-*-*

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils