1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 07:13:36 +02:00

The __builtin_return_address() internal logic, on PA-Risc, tries to read the

code at the tentative return address in order to check for a possible
inter-space thunk ("export stub" as called by HP), and in this case, unfolds
a bit more to retrieve the stub return address.

When the code pages are not readable, which is the case by default under
OpenBSD/hppa, this causes an immediate segmentation fault. But there is no
use of multiple space registers under OpenBSD either, so such thunks are
never created by ld(1). We can therefore override the logic by simply
returning the tentative return address, which is correct and does not require
read permission on the code pages.

ok jca@
This commit is contained in:
miod
2025-10-22 18:44:06 +00:00
parent 4f26fb48b3
commit f752a3e5bd
+10
View File
@@ -195,3 +195,13 @@ Boston, MA 02111-1307, USA. */
%{!nopie:rcrt0%O%s}}}} crtbegin%O%s} %{shared:crtbeginS%O%s}"
#undef ENDFILE_SPEC
#define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
/* Find the return address associated with the frame given by
FRAMEADDR.
The default code in pa.h invokes return_addr_rtx(), which attemps to
read code at the return pointer in order to check for an export stub.
This is not possible under OpenBSD as code is not readable; but such
export stubs are not used under OpenBSD anymay. */
#undef RETURN_ADDR_RTX
#define RETURN_ADDR_RTX(COUNT, FRAMEADDR) \
((COUNT) == 0 ? get_hard_reg_initial_val (Pmode, 2) : NULL_RTX)