Просмотр исходного кода

riscv: setcontext: fix linking error

Following error occurs when ucontext is activated:
ld: relocation R_RISCV_JAL against `__setcontext' which may bind externally
can not be used when making a shared object; recompile with -fPIC

Fix it like glibc does it:
https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b

Thanks to Charles Mirabile for the hint.
Waldemar Brodkorb 3 дней назад
Родитель
Сommit
50c470ef4e

+ 3 - 2
libc/sysdeps/linux/riscv32/setcontext.S

@@ -95,6 +95,7 @@ LEAF (__setcontext)
 99:	j	__syscall_error
 
 PSEUDO_END (__setcontext)
+libc_hidden_def (__setcontext)
 weak_alias (__setcontext, setcontext)
 
 LEAF (__start_context)
@@ -108,7 +109,7 @@ LEAF (__start_context)
 	/* Invoke subsequent context if present, else exit(0).  */
 	mv	a0, s2
 	beqz	s2, 1f
-	jal	__setcontext
-1:	j	exit
+	jal	HIDDEN_JUMPTARGET (__setcontext)
+1:	j	HIDDEN_JUMPTARGET (exit)
 
 PSEUDO_END (__start_context)

+ 3 - 2
libc/sysdeps/linux/riscv64/setcontext.S

@@ -95,6 +95,7 @@ LEAF (__setcontext)
 99:	j	__syscall_error
 
 PSEUDO_END (__setcontext)
+libc_hidden_def (__setcontext)
 weak_alias (__setcontext, setcontext)
 
 LEAF (__start_context)
@@ -108,7 +109,7 @@ LEAF (__start_context)
 	/* Invoke subsequent context if present, else exit(0).  */
 	mv	a0, s2
 	beqz	s2, 1f
-	jal	__setcontext
-1:	j	exit
+	jal	HIDDEN_JUMPTARGET (__setcontext)
+1:	j	HIDDEN_JUMPTARGET (exit)
 
 PSEUDO_END (__start_context)