Bug 28509 - ld riscv: R_RISCV_JAL referencing a preemptible symbol should be rejected
Summary: ld riscv: R_RISCV_JAL referencing a preemptible symbol should be rejected
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Nelson Chu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-28 01:00 UTC by Fangrui Song
Modified: 2021-11-03 09:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-10-28 01:00:50 UTC
j __sigsetjmp

.globl __sigsetjmp
__sigsetjmp:
  ret

riscv64-linux-gnu-as a.s -o a.o
riscv64-linux-gnu-ld -shared a.o -o a.so  # should fail


The default visibility __sigsetjmp definition is preemptible by default when linking a shared object. Such a symbol cannot be referenced by non-PLT by-GOT.


% riscv64-linux-gnu-objdump -d a.so

a.so:     file format elf64-littleriscv


Disassembly of section .text:

00000000000001b8 <__sigsetjmp-0x4>:
 1b8:   0040006f                j       1bc <__sigsetjmp>

00000000000001bc <__sigsetjmp>:
 1bc:   00008067                ret

On many architectures there is a diagnostic like R_X86_64_PC32.
Comment 1 Fangrui Song 2021-10-28 18:42:58 UTC
glibc commit https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b ("riscv: Fix incorrect jal with HIDDEN_JUMPTARGET") could have been avoided if such an error had been implemented.