1*44889fb9Sskrll /* $NetBSD: symbol_hppa.c,v 1.1 2022/06/25 06:51:37 skrll Exp $ */
2*44889fb9Sskrll
3*44889fb9Sskrll /*-
4*44889fb9Sskrll * Copyright (c) 2022 The NetBSD Foundation, Inc.
5*44889fb9Sskrll * All rights reserved.
6*44889fb9Sskrll *
7*44889fb9Sskrll * This code is derived from software contributed to The NetBSD Foundation
8*44889fb9Sskrll * by Nick Hudson.
9*44889fb9Sskrll *
10*44889fb9Sskrll * Redistribution and use in source and binary forms, with or without
11*44889fb9Sskrll * modification, are permitted provided that the following conditions
12*44889fb9Sskrll * are met:
13*44889fb9Sskrll * 1. Redistributions of source code must retain the above copyright
14*44889fb9Sskrll * notice, this list of conditions and the following disclaimer.
15*44889fb9Sskrll * 2. Redistributions in binary form must reproduce the above copyright
16*44889fb9Sskrll * notice, this list of conditions and the following disclaimer in the
17*44889fb9Sskrll * documentation and/or other materials provided with the distribution.
18*44889fb9Sskrll *
19*44889fb9Sskrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*44889fb9Sskrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*44889fb9Sskrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*44889fb9Sskrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*44889fb9Sskrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*44889fb9Sskrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*44889fb9Sskrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*44889fb9Sskrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*44889fb9Sskrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*44889fb9Sskrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*44889fb9Sskrll * POSSIBILITY OF SUCH DAMAGE.
30*44889fb9Sskrll */
31*44889fb9Sskrll
32*44889fb9Sskrll #include <sys/cdefs.h>
33*44889fb9Sskrll __RCSID("$NetBSD: symbol_hppa.c,v 1.1 2022/06/25 06:51:37 skrll Exp $");
34*44889fb9Sskrll
35*44889fb9Sskrll #include "symbol.h"
36*44889fb9Sskrll
37*44889fb9Sskrll #define HPPA_IS_PLABEL(addr) (((uintptr_t)(addr)) & (1 << 1))
38*44889fb9Sskrll #define HPPA_GET_PLABEL(addr) ((hppa_plabel *) (((uintptr_t)addr) & ~3))
39*44889fb9Sskrll
40*44889fb9Sskrll typedef struct {
41*44889fb9Sskrll uintptr_t pl_pc;
42*44889fb9Sskrll uintptr_t pl_sl;
43*44889fb9Sskrll } hppa_plabel;
44*44889fb9Sskrll
45*44889fb9Sskrll
46*44889fb9Sskrll uintptr_t
symbol_canonicalize_md(const void * addr)47*44889fb9Sskrll symbol_canonicalize_md(const void *addr)
48*44889fb9Sskrll {
49*44889fb9Sskrll return HPPA_IS_PLABEL(addr) ?
50*44889fb9Sskrll HPPA_GET_PLABEL(addr)->pl_pc : (uintptr_t)addr;
51*44889fb9Sskrll }
52