3 Copyright (C) 2020-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 #ifndef GDB_TARGET_SECTION_H
21 #define GDB_TARGET_SECTION_H
27 /* A union representing the possible owner types of a target_section. */
29 union target_section_owner
31 target_section_owner () : m_v (nullptr) {}
32 target_section_owner (const bfd
*bfd
) : bfd (bfd
) {}
33 target_section_owner (const objfile
*objfile
) : objfile (objfile
) {}
34 target_section_owner (const solib
*solib
) : solib (solib
) {}
36 /* Use this to access the type-erased version of the owner, for
37 comparisons, printing, etc. We don't access the M_V member
38 directly, because pedantically it is not valid to access a
39 non-active union member. */
40 const void *v () const
43 memcpy (&tmp
, this, sizeof (*this));
47 const struct bfd
*bfd
;
48 const struct objfile
*objfile
;
49 const struct solib
*solib
;
55 /* Struct target_section maps address ranges to file sections. It is
56 mostly used with BFD files, but can be used without (e.g. for handling
57 raw disks, or files not in formats handled by BFD). */
61 target_section (CORE_ADDR addr_
, CORE_ADDR end_
, struct bfd_section
*sect_
,
62 target_section_owner owner_
= {})
65 the_bfd_section (sect_
),
70 /* Lowest address in section. */
72 /* Highest address in section, plus 1. */
75 /* The BFD section. */
76 struct bfd_section
*the_bfd_section
;
78 /* The "owner" of the section.
80 It is set by add_target_sections and used by remove_target_sections.
81 For example, for executables it is a pointer to exec_bfd and
82 for shlibs it is the solib pointer. */
83 target_section_owner owner
;
86 #endif /* GDB_TARGET_SECTION_H */