xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/target-section.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
1*6881a400Schristos /* Target sections.
2*6881a400Schristos 
3*6881a400Schristos    Copyright (C) 2020-2023 Free Software Foundation, Inc.
4*6881a400Schristos 
5*6881a400Schristos    This file is part of GDB.
6*6881a400Schristos 
7*6881a400Schristos    This program is free software; you can redistribute it and/or modify
8*6881a400Schristos    it under the terms of the GNU General Public License as published by
9*6881a400Schristos    the Free Software Foundation; either version 3 of the License, or
10*6881a400Schristos    (at your option) any later version.
11*6881a400Schristos 
12*6881a400Schristos    This program is distributed in the hope that it will be useful,
13*6881a400Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*6881a400Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*6881a400Schristos    GNU General Public License for more details.
16*6881a400Schristos 
17*6881a400Schristos    You should have received a copy of the GNU General Public License
18*6881a400Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19*6881a400Schristos 
20*6881a400Schristos #ifndef GDB_TARGET_SECTION_H
21*6881a400Schristos #define GDB_TARGET_SECTION_H
22*6881a400Schristos 
23*6881a400Schristos /* Struct target_section maps address ranges to file sections.  It is
24*6881a400Schristos    mostly used with BFD files, but can be used without (e.g. for handling
25*6881a400Schristos    raw disks, or files not in formats handled by BFD).  */
26*6881a400Schristos 
27*6881a400Schristos struct target_section
28*6881a400Schristos {
29*6881a400Schristos   target_section (CORE_ADDR addr_, CORE_ADDR end_, struct bfd_section *sect_,
30*6881a400Schristos 		  void *owner_ = nullptr)
31*6881a400Schristos     : addr (addr_),
32*6881a400Schristos       endaddr (end_),
33*6881a400Schristos       the_bfd_section (sect_),
34*6881a400Schristos       owner (owner_)
35*6881a400Schristos   {
36*6881a400Schristos   }
37*6881a400Schristos 
38*6881a400Schristos   /* Lowest address in section.  */
39*6881a400Schristos   CORE_ADDR addr;
40*6881a400Schristos   /* Highest address in section, plus 1.  */
41*6881a400Schristos   CORE_ADDR endaddr;
42*6881a400Schristos 
43*6881a400Schristos   /* The BFD section.  */
44*6881a400Schristos   struct bfd_section *the_bfd_section;
45*6881a400Schristos 
46*6881a400Schristos   /* The "owner" of the section.
47*6881a400Schristos      It can be any unique value.  It is set by add_target_sections
48*6881a400Schristos      and used by remove_target_sections.
49*6881a400Schristos      For example, for executables it is a pointer to exec_bfd and
50*6881a400Schristos      for shlibs it is the so_list pointer.  */
51*6881a400Schristos   void *owner;
52*6881a400Schristos };
53*6881a400Schristos 
54*6881a400Schristos /* Holds an array of target sections.  */
55*6881a400Schristos 
56*6881a400Schristos using target_section_table = std::vector<target_section>;
57*6881a400Schristos 
58*6881a400Schristos #endif /* GDB_TARGET_SECTION_H */
59