1124758Semax/* SPDX-License-Identifier: GPL-2.0-or-later */
2124758Semax/*
3124758Semax * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
4124758Semax */
5124758Semax#ifndef _ORC_LOOKUP_H
6124758Semax#define _ORC_LOOKUP_H
7124758Semax
8124758Semax/*
9124758Semax * This is a lookup table for speeding up access to the .orc_unwind table.
10124758Semax * Given an input address offset, the corresponding lookup table entry
11124758Semax * specifies a subset of the .orc_unwind table to search.
12124758Semax *
13124758Semax * Each block represents the end of the previous range and the start of the
14124758Semax * next range.  An extra block is added to give the last range an end.
15124758Semax *
16124758Semax * The block size should be a power of 2 to avoid a costly 'div' instruction.
17124758Semax *
18124758Semax * A block size of 256 was chosen because it roughly doubles unwinder
19124758Semax * performance while only adding ~5% to the ORC data footprint.
20124758Semax */
21124758Semax#define LOOKUP_BLOCK_ORDER	8
22124758Semax#define LOOKUP_BLOCK_SIZE	(1 << LOOKUP_BLOCK_ORDER)
23124758Semax
24124758Semax#ifndef LINKER_SCRIPT
25124758Semax
26124758Semaxextern unsigned int orc_lookup[];
27124758Semaxextern unsigned int orc_lookup_end[];
28124758Semax
29124758Semax#define LOOKUP_START_IP		(unsigned long)_stext
30124758Semax#define LOOKUP_STOP_IP		(unsigned long)_etext
31124758Semax
32124758Semax#endif /* LINKER_SCRIPT */
33124758Semax
34124758Semax#endif /* _ORC_LOOKUP_H */
35124758Semax