1 /* GDB generic memory tagging functions.
3 Copyright (C) 2022-2023 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/>. */
27 get_next_core_memtag_section (bfd
*abfd
, asection
*section
,
28 CORE_ADDR address
, memtag_section_info
&info
)
30 /* If the caller provided no SECTION to start from, search from the
32 if (section
== nullptr)
33 section
= bfd_get_section_by_name (abfd
, "memtag");
35 /* Go through all the memtag sections and figure out if ADDRESS
36 falls within one of the memory ranges that contain tags. */
37 while (section
!= nullptr)
39 size_t memtag_range_size
= section
->rawsize
;
40 size_t tags_size
= bfd_section_size (section
);
42 /* Empty memory range or empty tag dump should not happen. Warn about
43 it but keep going through the sections. */
44 if (memtag_range_size
== 0 || tags_size
== 0)
46 warning (_("Found memtag section with empty memory "
47 "range or empty tag dump"));
52 CORE_ADDR start_address
= bfd_section_vma (section
);
53 CORE_ADDR end_address
= start_address
+ memtag_range_size
;
55 /* Is the address within [start_address, end_address)? */
56 if (address
>= start_address
57 && address
< end_address
)
59 info
.start_address
= start_address
;
60 info
.end_address
= end_address
;
61 info
.memtag_section
= section
;
65 section
= bfd_get_next_section_by_name (abfd
, section
);