1.1 --- a/libexec/include/exec/segment.h Thu Jun 02 01:09:30 2022 +0200
1.2 +++ b/libexec/include/exec/segment.h Fri Jun 03 00:21:10 2022 +0200
1.3 @@ -30,7 +30,7 @@
1.4
1.5
1.6
1.7 -/* Program segment abstraction. */
1.8 +/* Program segment abstractions. */
1.9
1.10 class Segment
1.11 {
1.12 @@ -42,29 +42,24 @@
1.13 char *_buf;
1.14 l4re_ds_t _ds;
1.15
1.16 - /* Segment base and corresponding region base. */
1.17 + /* Segment region base. */
1.18
1.19 - l4_addr_t _base, _region_base;
1.20 + l4_addr_t _region_base;
1.21
1.22 - /* Segment size and corresponding region size. */
1.23 + /* Segment region size. */
1.24
1.25 - offset_t _size, _region_size;
1.26 + offset_t _region_allocated_size;
1.27
1.28 /* Offset of segment content within the region. */
1.29
1.30 - offset_t _region_offset;
1.31 -
1.32 - /* Access flags. */
1.33 + offset_t _region_content_offset;
1.34
1.35 - l4re_rm_flags_t _flags;
1.36 + /* Common initialisation. */
1.37
1.38 - /* File access details. */
1.39 -
1.40 - offset_t _file_offset, _file_contents;
1.41 + void init();
1.42
1.43 public:
1.44 - explicit Segment(l4_addr_t base, offset_t size, l4re_rm_flags_t flags,
1.45 - offset_t file_offset = 0, offset_t file_contents = 0);
1.46 + virtual ~Segment();
1.47
1.48 char *address();
1.49
1.50 @@ -86,8 +81,46 @@
1.51
1.52 /* Generic property access. */
1.53
1.54 + virtual bool loadable() = 0;
1.55 + virtual offset_t file_contents() = 0;
1.56 + virtual offset_t file_offset() = 0;
1.57 + virtual l4_addr_t region_address() = 0;
1.58 + virtual offset_t region_size() = 0;
1.59 + virtual l4re_rm_flags_t region_flags() = 0;
1.60 +};
1.61 +
1.62 +
1.63 +
1.64 +class ExplicitSegment : public Segment
1.65 +{
1.66 +protected:
1.67 + /* Segment base. */
1.68 +
1.69 + l4_addr_t _base;
1.70 +
1.71 + /* Segment size. */
1.72 +
1.73 + offset_t _size;
1.74 +
1.75 + /* Access flags. */
1.76 +
1.77 + l4re_rm_flags_t _flags;
1.78 +
1.79 + /* File access details. */
1.80 +
1.81 + offset_t _file_offset, _file_contents;
1.82 +
1.83 +public:
1.84 + explicit ExplicitSegment(l4_addr_t base, offset_t size, l4re_rm_flags_t flags,
1.85 + offset_t file_offset = 0, offset_t file_contents = 0);
1.86 +
1.87 + /* Generic property access. */
1.88 +
1.89 + bool loadable();
1.90 offset_t file_contents();
1.91 -
1.92 + offset_t file_offset();
1.93 + l4_addr_t region_address();
1.94 + offset_t region_size();
1.95 l4re_rm_flags_t region_flags();
1.96 };
1.97