Next: , Previous: , Up: Dumping phase   [Contents][Index]


12.4.2 Address allocation

The next step is to allocate the offsets of each of the objects in the final dump file. This is done by pdump_allocate_offset() which is called indirectly by pdump_scan_by_alignment().

The strategy to deal with alignment problems uses these facts:

  1. real world alignment requirements are powers of two.
  2. the C compiler is required to adjust the size of a struct so that you can have an array of them next to each other. This means you can have an upper bound of the alignment requirements of a given structure by looking at which power of two its size is a multiple.
  3. the non-variant part of variable size lrecords has an alignment requirement of 4.

Hence, for each lrecord type, C struct type or opaque data block the alignment requirement is computed as a power of two, with a minimum of 2^2 for lrecords. pdump_scan_by_alignment() then scans all the pdump_entry_list_elmt’s, the ones with the highest requirements first. This ensures the best packing.

The maximum alignment requirement we take into account is 2^8.

pdump_allocate_offset() only has to do a linear allocation, starting at offset 256 (this leaves room for the header and keeps the alignments happy).