]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/target-section.h
Finalized intl-update patches
[thirdparty/binutils-gdb.git] / gdb / target-section.h
CommitLineData
7b466b10
TT
1/* Target sections.
2
213516ef 3 Copyright (C) 2020-2023 Free Software Foundation, Inc.
7b466b10
TT
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20#ifndef GDB_TARGET_SECTION_H
21#define GDB_TARGET_SECTION_H
22
0e17d3fc
SM
23struct bfd;
24struct objfile;
25struct shobj;
26
27/* A union representing the possible owner types of a target_section. */
28
29union target_section_owner
30{
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 shobj *shobj) : shobj (shobj) {}
35
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
41 {
42 void *tmp;
43 memcpy (&tmp, this, sizeof (*this));
44 return tmp;
45 }
46
47 const struct bfd *bfd;
48 const struct objfile *objfile;
49 const struct shobj *shobj;
50
51private:
52 const void *m_v;
53};
54
7b466b10
TT
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). */
58
59struct target_section
60{
6be2a9ab 61 target_section (CORE_ADDR addr_, CORE_ADDR end_, struct bfd_section *sect_,
0e17d3fc 62 target_section_owner owner_ = {})
6be2a9ab
TT
63 : addr (addr_),
64 endaddr (end_),
65 the_bfd_section (sect_),
66 owner (owner_)
67 {
68 }
69
7b466b10
TT
70 /* Lowest address in section. */
71 CORE_ADDR addr;
72 /* Highest address in section, plus 1. */
73 CORE_ADDR endaddr;
74
75 /* The BFD section. */
76 struct bfd_section *the_bfd_section;
77
78 /* The "owner" of the section.
0e17d3fc
SM
79
80 It is set by add_target_sections and used by remove_target_sections.
7b466b10 81 For example, for executables it is a pointer to exec_bfd and
0e17d3fc
SM
82 for shlibs it is the shobj pointer. */
83 target_section_owner owner;
7b466b10
TT
84};
85
7b466b10 86#endif /* GDB_TARGET_SECTION_H */