-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libc/riscv: fix link errors with GCC 12
Dynamically linked functions can not be called directly with jump ("j", "jal") and friends. Calls must go through the PLT. issue #4827
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
a4d148016cfbc4c494b277e164d67617cf540e31 | ||
dfcf0321f6f20fb8051954bc3fb4e661467a3434 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Back port from FreeBSD 13.1. required for GCC 12 | ||
|
||
Fixes ld error message: "relocation R_RISCV_JAL against `setjmp' which may bind | ||
externally can not be used when making a shared object" which means that there | ||
can not be a direct jump ("j", "jal", etc.) to a function is a jump slot (in | ||
PLT). So do not use the "j" calls. | ||
|
||
--- src/lib/libc/lib/libc/riscv/gen/sigsetjmp.S | ||
+++ src/lib/libc/lib/libc/riscv/gen/sigsetjmp.S | ||
@@ -38,20 +38,24 @@ __FBSDID("$FreeBSD: releng/12.0/lib/libc/riscv/gen/sigsetjmp.S 294227 2016-01-17 | ||
#include <machine/setjmp.h> | ||
|
||
ENTRY(sigsetjmp) | ||
- beqz a1, _C_LABEL(_setjmp) | ||
- j _C_LABEL(setjmp) | ||
+ beqz a1, 1f | ||
+tail _C_LABEL(setjmp) | ||
+ 1: | ||
+ tail _C_LABEL(_setjmp) | ||
END(sigsetjmp) | ||
|
||
ENTRY(siglongjmp) | ||
/* Load the _setjmp magic */ | ||
ld a2, .Lmagic | ||
- ld a3, 0(a0) | ||
+ld a3, 0(a0) | ||
|
||
/* Check the magic */ | ||
- beq a2, a3, _C_LABEL(_longjmp) | ||
- j _C_LABEL(longjmp) | ||
+ beq a2, a3, 1f | ||
+tail _C_LABEL(longjmp) | ||
+ 1: | ||
+tail _C_LABEL(_longjmp) | ||
|
||
.align 3 | ||
-.Lmagic: | ||
+ .Lmagic: | ||
.quad _JB_MAGIC__SETJMP | ||
END(siglongjmp) |