File: irepform.h

package info (click to toggle)
dwarfutils 20201201-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,868 kB
  • sloc: ansic: 104,667; sh: 5,947; cpp: 4,675; python: 878; makefile: 646; awk: 11
file content (738 lines) | stat: -rw-r--r-- 25,093 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
/*
  Copyright (C) 2010-2018 David Anderson.  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are met:
  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
  * Neither the name of the example nor the
    names of its contributors may be used to endorse or promote products
    derived from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY David Anderson ''AS IS'' AND ANY
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  DISCLAIMED. IN NO EVENT SHALL David Anderson BE LIABLE FOR ANY
  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/


//
// irepform.h
//
//
class IRCUdata;
class IRDie;
class IRAttr;
class IRFormInterface;

// An Abstract class.
class IRForm {
public:
    //virtual void emitvalue() = 0;
    //IRForm & operator=(const IRForm &r);
    virtual IRForm * clone() const  =0;
    virtual ~IRForm() {};
    IRForm() {};
    virtual enum Dwarf_Form_Class getFormClass() const = 0;
private:
};

class IRFormUnknown : public IRForm {
public:
    IRFormUnknown():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_UNKNOWN)
        {}
    ~IRFormUnknown() {};
    IRFormUnknown(IRFormInterface *);
    IRFormUnknown(const IRFormUnknown &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
    }
    virtual IRFormUnknown * clone() const {
        return new IRFormUnknown(*this);
    }
    IRFormUnknown & operator=(const IRFormUnknown &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        return *this;
    };
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
};
// An address class entry refers to some part
// (normally a loadable) section of the object file.
// Not to DWARF info. Typically into .text or .data for example.
// We therefore want a section number and offset (generally useless for us)
// or preferably  an elf symbol as that has a value
// and an elf section number.
// We often/usually know neither here so we do not even try.
// Later we will make one up if we have to.
class IRFormAddress : public IRForm {
public:
    IRFormAddress():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_ADDRESS),
        address_(0)
        {};
    IRFormAddress(IRFormInterface *);
    ~IRFormAddress() {};
    IRFormAddress & operator=(const IRFormAddress &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        address_ = r.address_;
        return *this;
    };
    IRFormAddress(const IRFormAddress &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        address_ = r.address_;
    }
    virtual IRFormAddress * clone() const {
        return new IRFormAddress(*this);
    };
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    Dwarf_Addr  getAddress() { return address_;};
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    void setAddress(Dwarf_Addr addr) { address_ = addr; };
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    Dwarf_Addr address_;
};
class IRFormBlock : public IRForm {
public:
    IRFormBlock():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_BLOCK),
        fromloclist_(0),sectionoffset_(0)
        {}
    IRFormBlock(IRFormInterface *);
    ~IRFormBlock() {};
    IRFormBlock & operator=(const IRFormBlock &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        blockdata_ = r.blockdata_;
        fromloclist_ = r.fromloclist_;
        sectionoffset_ = r.sectionoffset_;
        return *this;
    };
    IRFormBlock(const IRFormBlock &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        blockdata_ = r.blockdata_;
        fromloclist_ = r.fromloclist_;
        sectionoffset_ = r.sectionoffset_;
    }
    virtual IRFormBlock * clone() const {
        return new IRFormBlock(*this);
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    Dwarf_Unsigned getBlockLen() {return blockdata_.size();}
    Dwarf_Small* getBlockBytes() {
        // Standard guarantees vector content is simply array.
        return &blockdata_[0];
    };
    enum Dwarf_Form_Class getFormClass() const {
        return formclass_;
    };
    void insertBlock(Dwarf_Block *bl) {
        Dwarf_Small *d = static_cast<Dwarf_Small *>(bl->bl_data);
        Dwarf_Unsigned len = bl->bl_len;
        blockdata_.clear();
        blockdata_.insert(blockdata_.end(),d+0,d+len);
        fromloclist_ = bl->bl_from_loclist;
        sectionoffset_ = bl->bl_section_offset;
    };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    std::vector<Dwarf_Small> blockdata_;
    Dwarf_Small fromloclist_;
    Dwarf_Unsigned sectionoffset_;
};
class IRFormConstant : public IRForm {
public:
    enum Signedness {SIGN_NOT_SET,SIGN_UNKNOWN,UNSIGNED, SIGNED };
    IRFormConstant():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_CONSTANT),
        signedness_(SIGN_NOT_SET),
        uval_(0), sval_(0)
        { memset(&data16_,0,sizeof(data16_)); };
    IRFormConstant(IRFormInterface *);
    ~IRFormConstant() {};
    IRFormConstant(Dwarf_Half finalform,
        Dwarf_Half initialform,
        enum Dwarf_Form_Class formclass,
        IRFormConstant::Signedness signedness,
        Dwarf_Unsigned uval,
        Dwarf_Signed sval) {
        finalform_ = finalform;
        initialform_ = initialform;
        formclass_ = formclass;
        signedness_ = signedness;
        uval_ = uval;
        sval_ = sval;
    };
    IRFormConstant(Dwarf_Half finalform,
        Dwarf_Half initialform,
        enum Dwarf_Form_Class formclass UNUSEDARG,
        Dwarf_Form_Data16 & data16) {
        finalform_ = finalform;
        initialform_ = initialform;
        formclass_ = DW_FORM_CLASS_CONSTANT;
        signedness_ = SIGN_UNKNOWN;
        uval_ = 0;
        sval_ = 0;
        data16_ = data16;
    };
    IRFormConstant & operator=(const IRFormConstant &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        signedness_ = r.signedness_;
        uval_ = r.uval_;
        sval_ = r.sval_;
        data16_ = r.data16_;
        return *this;
    };
    IRFormConstant(const IRFormConstant &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        signedness_ = r.signedness_;
        uval_ = r.uval_;
        sval_ = r.sval_;
        data16_ = r.data16_;
    }
    virtual IRFormConstant * clone() const {
        return new IRFormConstant(*this);
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    Dwarf_Form_Class getFormClass() const { return formclass_; };
    Signedness getSignedness() const {return signedness_; };
    Dwarf_Signed getSignedVal() const {return sval_;};
    Dwarf_Unsigned getUnsignedVal() const {return uval_;};
    Dwarf_Form_Data16 getData16Val() const {return data16_;};
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    // Starts at SIGN_NOT_SET.
    // SIGN_UNKNOWN means it was a DW_FORM_data* of some
    // kind so we do not really know.
    Signedness signedness_;
    // Both uval_ and sval_ are always set to the same bits.
    Dwarf_Unsigned uval_;
    Dwarf_Signed sval_;
    Dwarf_Form_Data16 data16_;

    void setValues16(Dwarf_Form_Data16 *v,
        enum Signedness s UNUSEDARG) {
        uval_ = 0;
        sval_ = 0;
        data16_ = *v;
    }
    void setValues(Dwarf_Signed sval, Dwarf_Unsigned uval,
        enum Signedness s) {
        signedness_ = s;
        uval_ = uval;
        sval_ = sval;
    }
};

class IRFormExprloc : public IRForm {
public:
    IRFormExprloc():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_EXPRLOC)
        {};
    IRFormExprloc(IRFormInterface *);
    ~IRFormExprloc() {};
    IRFormExprloc & operator=(const IRFormExprloc &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        exprlocdata_ = r.exprlocdata_;
        return *this;
    };
    IRFormExprloc(const IRFormExprloc &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        exprlocdata_ = r.exprlocdata_;

    }
    virtual IRFormExprloc * clone() const {
        return new IRFormExprloc(*this);
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    std::vector<char> exprlocdata_;
    void insertBlock(Dwarf_Unsigned len, Dwarf_Ptr data) {
        char *d = static_cast<char *>(data);
        exprlocdata_.clear();
        exprlocdata_.insert(exprlocdata_.end(),d+0,d+len);
    };
};


class IRFormFlag : public IRForm {
public:
    IRFormFlag():
        initialform_(0),
        finalform_(0),
        formclass_(DW_FORM_CLASS_FLAG),
        flagval_(0)
        {};
    IRFormFlag(IRFormInterface*);
    ~IRFormFlag() {};
    IRFormFlag & operator=(const IRFormFlag &r) {
        if(this == &r) return *this;
        initialform_ = r.initialform_;
        finalform_ = r.finalform_;
        formclass_ = r.formclass_;
        flagval_ = r.flagval_;
        return *this;
    };
    IRFormFlag(const IRFormFlag &r) {
        initialform_ = r.initialform_;
        finalform_ = r.finalform_;
        formclass_ = r.formclass_;
        flagval_ = r.flagval_;
    }
    virtual IRFormFlag * clone() const {
        return new IRFormFlag(*this);
    }
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    void setFlagVal(Dwarf_Bool v) { flagval_ = v;}
    Dwarf_Bool getFlagVal() { return flagval_; }
private:
    Dwarf_Half initialform_;
    // In most cases initialform_ == finalform_.
    // Otherwise, initialform == DW_FORM_indirect.
    Dwarf_Half finalform_;
    enum Dwarf_Form_Class formclass_;
    Dwarf_Bool flagval_;
};


class IRFormLinePtr : public IRForm {
public:
    IRFormLinePtr():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_LINEPTR),
        debug_line_offset_(0)
        {};
    IRFormLinePtr(IRFormInterface *);
    ~IRFormLinePtr() {};
    IRFormLinePtr & operator=(const IRFormLinePtr &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        debug_line_offset_ = r.debug_line_offset_;
        return *this;
    };
    IRFormLinePtr(const IRFormLinePtr &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        debug_line_offset_ = r.debug_line_offset_;
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm(void) {return finalform_; }
    virtual IRFormLinePtr * clone() const {
        return new IRFormLinePtr(*this);
    }
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    Dwarf_Off debug_line_offset_;

    void setOffset(Dwarf_Unsigned uval) {
        debug_line_offset_ = uval;
    };
};


class IRFormLoclistPtr : public IRForm {
public:
    IRFormLoclistPtr():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_LOCLISTPTR),
        loclist_offset_(0)
        {};
    IRFormLoclistPtr(IRFormInterface *);
    ~IRFormLoclistPtr() {};
    IRFormLoclistPtr & operator=(const IRFormLoclistPtr &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        loclist_offset_ = r.loclist_offset_;
        return *this;
    };
    IRFormLoclistPtr(const IRFormLoclistPtr &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        loclist_offset_ = r.loclist_offset_;
    }
    virtual IRFormLoclistPtr * clone() const {
        return new IRFormLoclistPtr(*this);
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    Dwarf_Off loclist_offset_;

    void setOffset(Dwarf_Unsigned uval) {
        loclist_offset_ = uval;
    };
};


class IRFormMacPtr : public IRForm {
public:
    IRFormMacPtr():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_MACPTR),
        macro_offset_(0)
        {};
    IRFormMacPtr(IRFormInterface *);
    ~IRFormMacPtr() {};
    IRFormMacPtr & operator=(const IRFormMacPtr &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        macro_offset_ = r.macro_offset_;
        return *this;
    };
    IRFormMacPtr(const IRFormMacPtr &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        macro_offset_ = r.macro_offset_;
    }
    virtual IRFormMacPtr * clone() const {
        return new IRFormMacPtr(*this);
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    Dwarf_Off macro_offset_;

    void setOffset(Dwarf_Unsigned uval) {
        macro_offset_ = uval;
    };
};


class IRFormRangelistPtr : public IRForm {
public:
    IRFormRangelistPtr():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_RANGELISTPTR),
        rangelist_offset_(0)
        {};
    IRFormRangelistPtr(IRFormInterface *);
    ~IRFormRangelistPtr() {};
    IRFormRangelistPtr & operator=(const IRFormRangelistPtr &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        rangelist_offset_ = r.rangelist_offset_;
        return *this;
    };
    IRFormRangelistPtr(const IRFormRangelistPtr &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        rangelist_offset_ = r.rangelist_offset_;
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    virtual IRFormRangelistPtr * clone() const {
        return new IRFormRangelistPtr(*this);
    }
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    Dwarf_Off rangelist_offset_;

    void setOffset(Dwarf_Unsigned uval) {
        rangelist_offset_ = uval;
    };
};

class IRFormFramePtr : public IRForm {
public:
    IRFormFramePtr():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_FRAMEPTR),
        frame_offset_(0)
        {};
    IRFormFramePtr(IRFormInterface *);
    ~IRFormFramePtr() {};
    IRFormFramePtr & operator=(const IRFormFramePtr &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        frame_offset_ = r.frame_offset_;
        return *this;
    };
    IRFormFramePtr(const IRFormFramePtr &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        frame_offset_ = r.frame_offset_;
    }
    virtual IRFormFramePtr * clone() const {
        return new IRFormFramePtr(*this);
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    Dwarf_Off frame_offset_;

    void setOffset(Dwarf_Unsigned uval) {
        frame_offset_ = uval;
    };
};



class IRFormReference : public IRForm {
public:
    IRFormReference():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_REFERENCE),
        reftype_(RT_NONE),
        globalOffset_(0),cuRelativeOffset_(0),
        targetInputDie_(0),
        target_die_(0)
        {initSig8();};
    IRFormReference(IRFormInterface *);
    ~IRFormReference() {};
    IRFormReference & operator=(const IRFormReference &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        reftype_ = r.reftype_;
        globalOffset_ = r.globalOffset_;
        cuRelativeOffset_ = r.cuRelativeOffset_;
        typeSig8_ = r.typeSig8_;
        targetInputDie_ = r.targetInputDie_;
        target_die_ = r.target_die_;
        return *this;
    };
    IRFormReference(const IRFormReference &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        reftype_ = r.reftype_;
        globalOffset_ = r.globalOffset_;
        cuRelativeOffset_ = r.cuRelativeOffset_;
        typeSig8_ = r.typeSig8_;
        targetInputDie_ = r.targetInputDie_;
        target_die_ = r.target_die_;
    }
    virtual IRFormReference * clone() const {
        return new IRFormReference(*this);
    }
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    void setOffset(Dwarf_Off off) { globalOffset_ = off;
        reftype_ = RT_GLOBAL;};
    void setCUOffset(Dwarf_Off off) { cuRelativeOffset_= off;
        reftype_ = RT_CUREL;};
    void setSignature(Dwarf_Sig8 * sig) { typeSig8_ = *sig;
        reftype_ = RT_SIG;};
    const Dwarf_Sig8 *getSignature() { return &typeSig8_;};
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
    enum RefType { RT_NONE,RT_GLOBAL, RT_CUREL,RT_SIG };
    enum RefType getReferenceType() { return reftype_;};
    Dwarf_P_Die getTargetGenDie() { return target_die_;};
    IRDie * getTargetInDie() { return targetInputDie_;};
    void setTargetGenDie(Dwarf_P_Die targ) { target_die_ = targ; };
    void setTargetInDie(IRDie* targ) { targetInputDie_ = targ; };

private:
    void initSig8();

    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    enum RefType reftype_;

    // gobalOffset_ on input target set if and only if RT_GLOBAL
    Dwarf_Off globalOffset_;
    // cuRelativeOffset_  on input targetset if and only if RT_CUREL
    Dwarf_Off cuRelativeOffset_;
    // typeSig8_ on input target set if and only if RT_SIG
    Dwarf_Sig8 typeSig8_;

    // For RT_SIG we do not need extra data.
    // For RT_CUREL and RT_GLOBAL we do.

    // For RT_CUREL.  Points at the target input DIE
    // after all input DIEs set up for a CU .
    IRDie * targetInputDie_;
    // FIXME
    Dwarf_P_Die target_die_; //for RT_CUREL, this is known
        // for sure only after all target DIEs generated!

    // RT_GLOBAL. FIXME
};


class IRFormString: public IRForm {
public:
    IRFormString():
        finalform_(0), initialform_(0),
        formclass_(DW_FORM_CLASS_STRING),
        strpoffset_(0) {};
    ~IRFormString() {};
    IRFormString(IRFormInterface *);
    IRFormString(const IRFormString &r) {
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        formdata_= r.formdata_;
        strpoffset_= r.strpoffset_;
    }
    virtual IRFormString * clone() const {
        return new IRFormString(*this);
    }
    IRFormString & operator=(const IRFormString &r) {
        if(this == &r) return *this;
        finalform_ = r.finalform_;
        initialform_ = r.initialform_;
        formclass_ = r.formclass_;
        formdata_ = r.formdata_;
        strpoffset_ = r.strpoffset_;
        return *this;
    };
    void setInitialForm(Dwarf_Half v) { initialform_ = v;}
    void setFinalForm(Dwarf_Half v) { finalform_ = v;}
    Dwarf_Half getInitialForm() { return initialform_;}
    Dwarf_Half getFinalForm() {return finalform_;}
    void setString(const char *s) {formdata_ = s; };
    const std::string & getString() const {return formdata_; };
    enum Dwarf_Form_Class getFormClass() const { return formclass_; };
private:
    Dwarf_Half finalform_;
    // In most cases directform == indirect form.
    // Otherwise, directform == DW_FORM_indirect.
    Dwarf_Half initialform_;
    enum Dwarf_Form_Class formclass_;
    std::string formdata_;
    Dwarf_Unsigned strpoffset_;
};


// Factory Method.
IRForm *formFactory(Dwarf_Debug dbg, Dwarf_Attribute attr,
    IRCUdata &cudata,IRAttr & irattr);