arm, objdump: print obsolote warning when 26-bit set in instructions
[binutils-gdb.git] / gdb / arch / i386-linux-tdesc.c
blob9f12e59d2140a156697db46ef8896ae5d83e0b21
1 /* Target description related code for GNU/Linux i386.
3 Copyright (C) 2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "arch/x86-linux-tdesc.h"
21 #include "arch/i386-linux-tdesc.h"
22 #include "arch/i386.h"
23 #include "arch/x86-linux-tdesc-features.h"
25 /* See arch/i386-linux-tdesc.h. */
27 const target_desc *
28 i386_linux_read_description (uint64_t xcr0)
30 /* Cache of previously seen i386 target descriptions, indexed by the xcr0
31 value that created the target description. This needs to be static
32 within this function to ensure it is initialised before first use. */
33 static std::unordered_map<uint64_t, const target_desc_up> i386_tdesc_cache;
35 /* Only some bits are checked when creating a tdesc, but the XCR0 value
36 contains other feature bits that are not relevant for tdesc creation.
37 When indexing into the I386_TDESC_CACHE we need to use a consistent
38 xcr0 value otherwise we might fail to find an existing tdesc which has
39 the same set of relevant bits set. */
40 xcr0 &= x86_linux_i386_xcr0_feature_mask ();
42 const auto it = i386_tdesc_cache.find (xcr0);
43 if (it != i386_tdesc_cache.end ())
44 return it->second.get ();
46 /* Create the previously unseen target description. */
47 target_desc_up tdesc (i386_create_target_description (xcr0, true, false));
48 x86_linux_post_init_tdesc (tdesc.get (), false);
50 /* Add to the cache, and return a pointer borrowed from the
51 target_desc_up. This is safe as the cache (and the pointers contained
52 within it) are not deleted until GDB exits. */
53 target_desc *ptr = tdesc.get ();
54 i386_tdesc_cache.emplace (xcr0, std::move (tdesc));
55 return ptr;