1 \chapter[Split DWARF Object Files (Informative)]{Split DWARF Object Files (Informative)}
2 \label{app:splitdwarfobjectsinformative}
3 \addtoindexx{DWARF compression}
4 \addtoindexx{DWARF duplicate elimination|see{\textit{also} DWARF compression}}
5 \addtoindexx{DWARF duplicate elimination|see{\textit{also} split DWARF object file}}
6 With the traditional DWARF format, debug information is designed
7 with the expectation that it will be processed by the linker to
8 produce an output binary with complete debug information, and
9 with fully-resolved references to locations within the
10 application. For very large applications, however, this approach
11 can result in excessively large link times and excessively large
14 Several vendors have independently developed
15 proprietary approaches that allow the debug information to remain
16 in the relocatable object files, so that the linker does not have
17 to process the debug information or copy it to the output file.
18 These approaches have all required that additional information be
19 made available to the debug information consumer, and that the
20 consumer perform some minimal amount of relocation in order to
21 interpret the debug info correctly. The additional information
22 required, in the form of load maps or symbol tables, and the
23 details of the relocation are not covered by the DWARF
24 specification, and vary with each vendor's implementation.
26 Section \refersec{datarep:splitdwarfobjectfiles} describes a
27 platform-independent mechanism that allows a producer to
28 split the debugging information into relocatable and
29 non-relocatable partitions. This Appendix describes the use
30 of \splitDWARFobjectfile{s} and provides some illustrative
34 \label{app:splitoverview}
35 \DWARFVersionV{} introduces an optional set of debugging sections
36 that allow the compiler to partition the debugging information
37 into a set of (small) sections that require link-time relocation
38 and a set of (large) sections that do not. The sections that
39 require relocation are written to the relocatable object file as
40 usual, and are linked into the final executable. The sections
41 that do not require relocation, however, can be written to the
42 relocatable object (.o) file but ignored by the linker, or they
43 can be written to a separate DWARF object (.dwo{})
44 \addtoindexx{\texttt{.dwo} file extension} file.
47 The optional set of debugging sections includes the following:
50 \dotdebugabbrevdwo{} - Contains the abbreviations table(s) used by
51 the \dotdebuginfodwo{} section.
53 \dotdebuginfodwo{} - Contains the \DWTAGcompileunit{} and
54 \DWTAGtypeunit{} DIEs and
55 their descendants. This is the bulk of the debugging
56 information for the compilation unit that is normally found
57 in the \dotdebuginfo{} section.
59 \dotdebugloclistsdwo{} - Contains the location lists referenced by
60 the debugging information entries in the \dotdebuginfodwo{}
61 section. This contains the location lists normally found in
62 the \dotdebugloclists{} section, with a
63 modified format to eliminate the need for relocations.
65 \dotdebugstrdwo{} - Contains the string table for all indirect
66 strings referenced by the debugging information in the
67 \dotdebuginfodwo{} sections.
69 \dotdebugstroffsetsdwo{} - Contains the string offsets table
70 for the strings in the \dotdebugstrdwo{}{} section.
72 \dotdebugmacrodwo{} - Contains macro definition information,
73 normally found in the \dotdebugmacro{} section.
75 \dotdebuglinedwo{} - Contains \addtoindex{specialized line number table}s
76 for the type units in the \dotdebuginfodwo{} section. These tables
77 contain only the directory and filename lists needed to
78 interpret \DWATdeclfile{} attributes in the debugging
79 information entries. Actual line number tables remain in the
80 \dotdebugline{} section, and remain in the relocatable object
85 In a \texttt{.dwo} file, there is no benefit to having a separate string
86 section for directories and file names because the primary
87 string table will never be stripped. Accordingly, no
88 \texttt{.debug\_line\_str.dwo} section is defined. Content descriptions
89 corresponding to \DWFORMlinestrp{} in an executable file (for example,
90 in the skeleton compilation unit) instead use \DWFORMstrx. This allows
91 directory and file name strings to be merged with general
92 strings and across compilations in package files
93 (where they are not subject to potential stripping).
95 In a \texttt{.dwo} file, referring to a string using \DWFORMstrp{}
96 is valid, but such use
97 results in a file that cannot be incorporated into a package file
98 (which involves string merging).
100 In order for the consumer to locate and process the debug
101 information, the compiler must produce a small amount of debug
102 information that passes through the linker into the output
103 binary. A skeleton \dotdebuginfo{} section for each compilation unit
104 contains a reference to the corresponding \texttt{.o} or \texttt{.dwo}
105 file, and the \dotdebugline{} section (which is typically small
106 compared to the \dotdebuginfo{} sections) is
107 linked into the output binary, as is the new \dotdebugaddr{}
111 The debug sections that continue to be linked into the
112 output binary include the following:
115 \dotdebugabbrev{} - Contains the abbreviation codes used by the
116 skeleton \dotdebuginfo{} section.
118 \dotdebugaddr{} - Contains references to loadable sections,
119 indexed by attributes of form \DWFORMaddrx{} or location
121 \DWOPaddrx{} opcodes.
123 \dotdebugaranges{} - Contains the accelerated range lookup table
124 for the compilation unit.
126 \dotdebugframe{} - Contains the frame tables.
128 \dotdebuginfo{} - Contains a skeleton \DWTAGcompileunit{} DIE,
131 \dotdebugline{} - Contains the line number tables.
132 (These could be moved to the .dwo file, but in
133 order to do so, each \DWLNEsetaddress{} opcode would need to
134 be replaced by a new opcode that referenced an entry in the
135 \dotdebugaddr{} section. Furthermore, leaving this section in the
136 .o file allows many debug info consumers to remain unaware of
139 \dotdebuglinestr{} - Contains strings for file names used in
140 combination with the \dotdebugline{} section.
142 \dotdebugnames{} - Contains the names for use in
143 building an index section.
144 The section header refers to a
145 compilation unit offset, which is the offset of the
146 skeleton compilation unit in the \dotdebuginfo{} section.
149 \dotdebugstr{} - Contains any strings referenced by the skeleton
150 \dotdebuginfo{} sections (via \DWFORMstrp{} or \DWFORMstrx{}).
152 \dotdebugstroffsets{} - Contains the string offsets table for
153 the strings in the \dotdebugstr{} section (if form \DWFORMstrx{} is used).
157 The skeleton \DWTAGcompileunit{} DIE
158 may have the following attributes:
159 \autocols[0pt]{c}{3}{l}{
169 \DWATstroffsetsbase{}
172 All other attributes of the compilation unit DIE are moved to
173 the full DIE in the \dotdebuginfodwo{} section.
175 The \HFNdwoid{} field is present in headers of the skeleton DIE
176 and the header of the full DIE, so that a consumer
180 Relocations are neither necessary nor useful in
181 \texttt{.dwo} files, because the \texttt{.dwo}
182 files contain only debugging information that does not need to be
183 processed by a linker. Relocations are rendered unnecessary via
186 \begin{enumerate}[1. ]
187 \item Some values needing relocation are kept in the \texttt{.o} file
188 (for example, references to the line number program from the skeleton
191 \item Some values do not need a relocation because they refer from
192 one \dotdwo{} section to another \dotdwo{} section
193 in the same compilation unit.
195 \item Some values that need a relocation to refer to a relocatable
196 program address use the \DWFORMaddrx{} form, referencing a relocatable
197 value in the \dotdebugaddr{} section (which remains in the .o file).
203 Table \refersec{tab:unitattributesbyunitkind} summarizes which
204 attributes are defined for use in the various
205 kinds of compilation units (see Section \refersec{chap:unitentries}).
206 It compares and contrasts both conventional and split object-related
210 \caption{Unit attributes by unit kind}
211 \label{tab:unitattributesbyunitkind}
212 \begin{tabular}{P{5.5cm}|cc|ccc}
214 & \multicolumn{5}{c}{\bfseries Unit Kind} \\
215 & \multicolumn{2}{c}{\bfseries Conventional}
216 & \multicolumn{3}{c}{\bfseries Skeleton and Split} \\
217 \bfseries Attribute & Full \& & Type & Skeleton & Split Full & Split Type \\
220 \DWATaddrbase & \chkmk & & \chkmk & & \\
222 \DWATbasetypes & \chkmk & & & & \\
224 \DWATcompdir & \chkmk & & \chkmk & & \\
226 %\DWATdwoid & & & \chkmk & \chkmk & \\
228 \DWATdwoname & & & \chkmk & & \\
230 \DWATentrypc & \chkmk & & & \chkmk & \\
232 \DWAThighpc & \chkmk & & \chkmk & & \\
234 \DWATidentifiercase & \chkmk & & & \chkmk & \\
236 \DWATlanguage & \chkmk & \chkmk & & \chkmk & \chkmk \\
239 \DWATloclistsbase & \chkmk & & & &
243 \DWATlowpc & \chkmk & & \chkmk & & \\
245 \DWATmacros & \chkmk & & & \chkmk & \\
247 \DWATmainsubprogram & \chkmk & & & \chkmk & \\
249 \DWATname & \chkmk & & & \chkmk & \\
251 \DWATproducer & \chkmk & & & \chkmk & \\
254 \DWATranges \eb & \chkmk & & & \chkmk & \\
257 \DWATrnglistsbase \eb & \chkmk & & & & \\
259 \DWATstmtlist & \chkmk & \chkmk & \chkmk & & \chkmk \\
261 \DWATstroffsetsbase & \chkmk & \chkmk & \chkmk & & \\
263 \DWATuseUTFeight & \chkmk & \chkmk & \chkmk & \chkmk & \chkmk \\
269 The split dwarf object file design depends on having an index of
270 debugging information available to the consumer. For name lookups,
271 the consumer can use the \dotdebugnames{} index section (see
272 Section \refersec{chap:acceleratedaccess}) to
273 locate a skeleton compilation unit. The
274 \DWATcompdir{} and \DWATdwoname{} attributes in the skeleton
275 compilation unit can then be used to locate the corresponding
276 DWARF object file for the compilation unit. Similarly, for an
277 address lookup, the consumer can use the \dotdebugaranges{} table,
278 which will also lead to a skeleton compilation unit. For a file
279 and line number lookup, the skeleton compilation units can be
280 used to locate the line number tables.
284 \section{Split DWARF Object File Example}
285 \label{app:splitdwarfobjectfileexample}
286 \addtoindexx{split DWARF object file!example}
287 Consider the example source code in
288 Figure \refersec{fig:splitobjectexamplesourcefragment1},
289 Figure \refersec{fig:splitobjectexamplesourcefragment2} and
290 Figure \refersec{fig:splitobjectexamplesourcefragment3}.
291 When compiled with split DWARF, we will have two DWARF object files,
292 \texttt{demo1.o} and \texttt{demo2.o}, and two \splitDWARFobjectfile{s},
293 \texttt{demo1.dwo} and \texttt{demo2.dwo}.
297 \textit{File demo1.cc}
301 bool Box::contains(const Point& p) const
303 return (p.x() >= ll_.x() && p.x() <= ur_.x() &&
304 p.y() >= ll_.y() && p.y() <= ur_.y());
307 \caption{Split object example: source fragment \#1}
308 \label{fig:splitobjectexamplesourcefragment1}
312 \textit{File demo2.cc}
316 bool Line::clip(const Box& b)
318 float slope = (end_.y() - start_.y()) / (end_.x() - start_.x());
320 // Trivial acceptance.
321 if (b.contains(start_) && b.contains(end_)) return true;
323 // Trivial rejection.
324 if (start_.x() < b.l() && end_.x() < b.l()) return false;
325 if (start_.x() > b.r() && end_.x() > b.r()) return false;
326 if (start_.y() < b.b() && end_.y() < b.b()) return false;
327 if (start_.y() > b.t() && end_.y() > b.t()) return false;
329 if (b.contains(start_)) {
330 // Swap points so that start_ is outside the clipping
337 if (start_.x() < b.l())
338 start_ = Point(b.l(),
339 start_.y() + (b.l() - start_.x()) * slope);
340 else if (start_.x() > b.r())
341 start_ = Point(b.r(),
342 start_.y() + (b.r() - start_.x()) * slope);
343 else if (start_.y() < b.b())
344 start_ = Point(start_.x() + (b.b() - start_.y()) / slope,
346 else if (start_.y() > b.t())
347 start_ = Point(start_.x() + (b.t() - start_.y()) / slope,
352 \caption{Split object example: source fragment \#2}
353 \label{fig:splitobjectexamplesourcefragment2}
361 Point(float x, float y) : x_(x), y_(y){}
362 float x() const { return x_; }
363 float y() const { return y_; }
371 Line(Point start, Point end) : start_(start), end_(end){}
372 bool clip(const Box& b);
373 Point start() const { return start_; }
374 Point end() const { return end_; }
382 Box(float l, float r, float b, float t) : ll_(l, b), ur_(r, t){}
383 Box(Point ll, Point ur) : ll_(ll), ur_(ur){}
384 bool contains(const Point& p) const;
385 float l() const { return ll_.x(); }
386 float r() const { return ur_.x(); }
387 float b() const { return ll_.y(); }
388 float t() const { return ur_.y(); }
395 \caption{Split object example: source fragment \#3}
396 \label{fig:splitobjectexamplesourcefragment3}
400 \subsection{Contents of the Object File}
401 The object files each contain the following sections of debug
413 The \dotdebugabbrev{} section contains just a single entry describing
414 the skeleton compilation unit DIE.
416 The DWARF description in the \dotdebuginfo{} section
417 contains just a single DIE, the skeleton compilation unit,
419 Figure \referfol{fig:splitdwafexampleskeletondwarfdescription}.
426 \DWATcompdir: (reference to directory name in .debug_str)
427 \DWATdwoname: (reference to "demo1.dwo" in .debug_str)
428 \DWATaddrbase: (reference to .debug_addr section)
429 \DWATstmtlist: (reference to .debug_line section)
434 \caption{Split object example: Skeleton DWARF description}
435 \label{fig:splitdwafexampleskeletondwarfdescription}
438 The \DWATcompdir{} and \DWATdwoname{} attributes provide the
439 location of the corresponding \splitDWARFobjectfile{} that
440 contains the full debug information; that file is normally
441 expected to be in the same directory as the object file itself.
443 The \HFNdwoid{} field in the header of the skeleton unit provides
444 an ID or key for the debug information contained in the
445 DWARF object file. This ID serves
446 two purposes: it can be used to verify that the debug information
447 in the \splitDWARFobjectfile{} matches the information in the object
448 file, and it can be used to find the debug information in a DWARF
451 The \DWATaddrbase{} attribute contains the relocatable offset of
452 this object file's contribution to the \dotdebugaddr{} section.
455 The \DWATstmtlist{} attribute contains the relocatable offset of
456 this file's contribution to the \dotdebugline{} table.
461 The \dotdebugline{} section contains the full line number table for
462 the compiled code in the object file. As shown in
463 Figure \refersec{fig:splitobjectexamplesourcefragment1}, the line
464 number program header lists the two file names, \texttt{demo.h} and
465 \texttt{demo1.cc}, and contains line number programs for
466 \texttt{Box::contains}, \texttt{Point::x}, and \texttt{Point::y}.
468 The \dotdebugstr{} section contains the strings referenced indirectly
469 by the compilation unit DIE and by the line number program.
471 The \dotdebugaddr{} section contains relocatable addresses of
472 locations in the loadable text and data that are referenced by
473 debugging information entries in the split DWARF object. In the
474 example in \refersec{fig:splitobjectexamplesourcefragment3},
475 \texttt{demo1.o} may have three entries:
479 Slot & Location referenced \\
481 0 & low PC value for \texttt{Box::contains} \\
482 1 & low PC value for \texttt{Point::x} \\
483 2 & low PC value for \texttt{Point::y} \\
489 section contains the names defined by the debugging
490 information in the \splitDWARFobjectfile{}
491 (see Section \refersec{chap:contentsofthenameindex}),
492 and references the skeleton compilation unit.
493 When linked together into a final executable,
494 they can be used by a DWARF consumer to lookup a name to find one
495 or more skeleton compilation units that provide information about
496 that name. From the skeleton compilation unit, the consumer can
497 find the \splitDWARFobjectfile{} that it can then read to get the full
500 The \dotdebugaranges{} section contains the PC ranges defined in this
501 compilation unit, and allow a DWARF consumer to map a PC value to
502 a skeleton compilation unit, and then to a \splitDWARFobjectfile.
505 \subsection{Contents of the Split DWARF Object Files}
506 The \splitDWARFobjectfile{s} each contain the following sections:
509 \dotdebuginfodwo{} (for the compilation unit)
510 \dotdebuginfodwo{} (one COMDAT section for each type unit)
515 \dotdebugstroffsetsdwo
518 The \dotdebugabbrevdwo{} section contains the abbreviation
519 declarations for the debugging information entries in the
520 \dotdebuginfodwo{} section.
522 The \dotdebuginfodwo{} section containing the compilation unit
523 contains the full debugging information for the compile unit, and
524 looks much like a normal \dotdebuginfo{} section in a non-split
525 object file, with the following exceptions:
527 \item The \DWTAGcompileunit{} DIE does not need to repeat the
528 \DWATranges, \DWATlowpc, \DWAThighpc, and
529 \DWATstmtlist{} attributes that are provided in the skeleton
532 \item References to strings in the string table use the
533 form code \DWFORMstrx, referring to slots in the
534 \dotdebugstroffsetsdwo{} section.
539 \item References to relocatable addresses in the object file
540 use the form code \DWFORMaddrx, referring to slots in the
541 \dotdebugaddr{} table, relative to the base offset given by
542 \DWATaddrbase{} in the skeleton compilation unit.
546 Figure \referfol{fig:splitobjectexampledemoonedwodwarfexcerpts} presents
547 excerpts from the \dotdebuginfodwo{} section for \texttt{demo1.dwo}.
556 \DWATproducer [\DWFORMstrx]: (slot 15) (producer string)
557 \DWATlanguage: \DWLANGCplusplus
558 \DWATname [\DWFORMstrx]: (slot 7) "demo1.cc"
559 \DWATcompdir [\DWFORMstrx]: (slot 4) (directory name)
561 \DWATname [\DWFORMstrx]: (slot 12) "Point"
562 \DWATsignature [\DWFORMrefsigeight]: 0x2f33248f03ff18ab
563 \DWATdeclaration: true
566 \DWATname [\DWFORMstrx]: (slot 12) "Point"
569 \DWATlinkagename [\DWFORMstrx]: (slot 16) "_ZN5PointC4Eff"
570 \DWATaccessibility: \DWACCESSpublic
571 \DWATdeclaration: true
574 \DWATname [\DWFORMstring]: "Box"
575 \DWATsignature [\DWFORMrefsigeight{}]: 0xe97a3917c5a6529b
576 \DWATdeclaration: true
580 \DWATname [\DWFORMstrx]: (slot 0) "contains"
583 \DWATlinkagename [\DWFORMstrx: (slot 8)
584 "_ZNK3Box8containsERK5Point"
585 \DWATtype: (reference to 7$)
586 \DWATaccessibility: \DWACCESSpublic
587 \DWATdeclaration: true
592 \caption{Split object example: \texttt{demo1.dwo} excerpts}
593 \label{fig:splitobjectexampledemoonedwodwarfexcerpts}
602 \DWATspecification: (reference to 4$)
605 \DWATlowpc [\DWFORMaddrx]: (slot 0)
606 \DWAThighpc [\DWFORMdataeight]: 0xbb
607 \DWATframebase: \DWOPcallframecfa
608 \DWATobjectpointer: (reference to 6$)
609 6$: \DWTAGformalparameter
610 \DWATname [\DWFORMstrx]: (slot 13): "this"
611 \DWATtype: (reference to 8$)
612 \DWATartificial: true
613 \DWATlocation: \DWOPfbreg(-24)
614 \DWTAGformalparameter
615 \DWATname [\DWFORMstring]: "p"
618 \DWATtype: (reference to 11$)
619 \DWATlocation: \DWOPfbreg(-32)
623 \DWATencoding: \DWATEboolean
624 \DWATname [\DWFORMstrx]: (slot 5) "bool"
627 \DWATtype: (reference to 9$)
628 9$: \DWTAGpointertype
630 \DWATtype: (reference to 10$)
632 \DWATtype: (reference to 3$)
635 \DWATtype: (reference to 12$)
636 12$: \DWTAGreferencetype
638 \DWATtype: (reference to 13$)
640 \DWATtype: (reference to 1$)
646 Figure~\ref{fig:splitobjectexampledemoonedwodwarfexcerpts}: Split object example: \texttt{demo1.dwo} DWARF excerpts \textit{(concluded)}
651 In the defining declaration for \texttt{Box::contains} at 5\$, the
652 \DWATlowpc{} attribute is represented with \DWFORMaddrx,
653 referring to slot 0 in the \dotdebugaddr{} table from \texttt{demo1.o}.
654 That slot contains the relocated address of the beginning of the
657 Each type unit is contained in its own COMDAT \dotdebuginfodwo{}
658 section, and looks like a normal type unit in a non-split object,
659 except that the \DWTAGtypeunit{} DIE contains a \DWATstmtlist{}
660 attribute that refers to a specialized \dotdebuglinedwo{}
661 \addtoindexx{type unit!specialized \texttt{.debug\_line.dwo} section in}
662 \addtoindexx{specialized \texttt{.debug\_line.dwo} section}
664 section contains a normal line number
665 program header with a list of include directories and filenames,
666 but no line number program. This section is used only as a
667 reference for filenames needed for \DWATdeclfile{} attributes
668 within the type unit.
670 The \dotdebugstroffsetsdwo{} section contains an entry for each
671 unique string in the string table.
672 Each entry in the table is the offset of the string, which is
673 contained in the \dotdebugstrdwo{} section.
675 In a split DWARF object file, all references to
676 strings go through this table (there are no
677 other offsets to \dotdebugstrdwo{} in a split
678 DWARF object file). That is, there
679 is no use of \DWFORMstrp{} in a split DWARF object file.
681 The offsets in these slots have no associated relocations,
682 because they are not part of a relocatable object file.
685 When combined into a DWARF package file, however, each
686 slot must be adjusted to refer to the appropriate offset
687 within the merged string table (\dotdebugstrdwo{}).
688 The tool that builds the DWARF package file must understand
689 the structure of the \dotdebugstroffsetsdwo{} section in
690 order to apply the necessary adjustments.
691 Section \refersec{app:dwarfpackagefileexample} presents
692 an example of a DWARF package file.
695 The \dotdebugloclistsdwo{} section contains the location lists referenced
696 by \DWATlocation{} attributes in the \dotdebuginfodwo{} section. This
697 section has a similar format to the \bbeb\dotdebugloclists{} section in a
698 non-split object, but it has some small differences as explained
699 in Section \refersec{datarep:locationlists}.
707 \DWATname [\DWFORMstrx]: (slot 20) "Line"
708 \DWATsignature [\DWFORMrefsigeight]: 0x79c7ef0eae7375d1
709 \DWATdeclaration: true
713 \DWATname [\DWFORMstrx]: (slot 19) "clip"
716 \DWATlinkagename [\DWFORMstrx]: (slot 2) "_ZN4Line4clipERK3Box"
717 \DWATtype: (reference to DIE for bool)
718 \DWATaccessibility: \DWACCESSpublic
719 \DWATdeclaration: true
724 \caption{Split object example: \texttt{demo2.dwo} DWARF \dotdebuginfodwo{} excerpts}
725 \label{fig:splitobjectexampledemotwodwodwarfdebuginfodwoexcerpts}
734 \DWATspecification: (reference to 2$)
737 \DWATlowpc [\DWFORMaddrx]: (slot 32)
738 \DWAThighpc [\DWFORMdataeight]: 0x1ec
739 \DWATframebase: \DWOPcallframecfa
740 \DWATobjectpointer: (reference to 4$)
741 4$: \DWTAGformalparameter
742 \DWATname: (indexed string: 0x11): this
743 \DWATtype: (reference to DIE for type const Point* const)
745 \DWATlocation: 0x0 (location list)
746 5$: \DWTAGformalparameter
750 \DWATtype: (reference to DIE for type const Box& const)
751 \DWATlocation [\DWFORMsecoffset]: 0x2a
752 6$: \DWTAGlexicalblock
753 \DWATlowpc [\DWFORMaddrx]: (slot 17)
756 \DWATname [\DWFORMstrx]: (slot 28): "slope"
759 \DWATtype: (reference to DIE for type float)
760 \DWATlocation [\DWFORMsecoffset]: 0x49
766 Figure~\ref{fig:splitobjectexampledemotwodwodwarfdebuginfodwoexcerpts}: Split object example: \texttt{demo2.dwo} DWARF \dotdebuginfodwo{} excerpts \textit{(concluded)}
771 In \texttt{demo2.dwo} as shown in
772 Figure \refersec{fig:splitobjectexampledemotwodwodwarfdebuginfodwoexcerpts},
773 the debugging information for \texttt{Line::clip}
774 starting at \texttt{2\$} describes a local
775 variable \texttt{slope} at \texttt{7\$}
776 whose location varies based on the PC.
777 Figure \refersec{fig:splitobjectexampledemotwodwodwarfdebuglocdwoexcerpts}
778 presents some excerpts from the \dotdebuginfodwo{} section for
783 In Figure \refersec{fig:splitobjectexampledemotwodwodwarfdebuginfodwoexcerpts},
784 the \DWTAGformalparameter{} entries at \texttt{4\$} and \texttt{5\$} refer to the
785 location lists at offset \texttt{0x0} and \texttt{0x2a}, respectively, and the
786 \DWTAGvariable{} entry for \texttt{slope}
787 refers to the location list at offset \texttt{0x49}.
788 Figure \refersec{fig:splitobjectexampledemotwodwodwarfdebuglocdwoexcerpts}
789 shows a representation of the
790 location lists at those offsets in the \dotdebugloclistsdwo{} section.
792 % Special commands for use in the folloing table
793 \newcommand{\XXLLEsl}{\hyperlink{chap:DWLLEstartlength}{start\_length}
794 \index{DW\_LLE\_start\_length}}
795 \newcommand{\XXLLEeol}{\hyperlink{chap:DWLLEendoflist}{end\_of\_list}
796 \index{DW\_LLE\_end\_of\_list}}
801 \begin{tabular}{rl|rr|rl}
802 \multicolumn{2}{c}{\textbf{Entry type}}
803 & \multicolumn{2}{c}{\textbf{Range}}
804 & \multicolumn{2}{l}{\hspace{6mm}\textbf{Counted Location Description}} \\
806 & start& length & length & expression \\
810 0x00 & \XXLLEsl & [9] & 0x002f & 0x0001 & \DWOPregfive~(rdi) \\
811 0x09 & \XXLLEsl & [11] & 0x01b9 & 0x0001 & \DWOPregthree~(rbx) \\
812 0x12 & \XXLLEsl & [29] & 0x0003 & 0x0003 & \DWOPbregtwelve~(r12): -8;\\
813 & & & & & \DWOPstackvalue \\
814 0x1d & \XXLLEsl & [31] & 0x0001 & 0x0003 & \DWOPentryvalue: \\
815 & & & & & (\DWOPregfive~(rdi)); \\
816 & & & & & \DWOPstackvalue \\
817 0x29 & \XXLLEeol &&&& \\
820 0x2a & \XXLLEsl & [9] & 0x002f & 0x0001 & \DWOPregfour~(rsi)) \\
821 0x33 & \XXLLEsl & [11] & 0x01ba & 0x0003 & \DWOPregsix~(rbp)) \\
822 0x3c & \XXLLEsl & [30] & 0x0003 & 0x0003 & \DWOPentryvalue: \\
823 & & & & & (\DWOPregfour~(rsi)); \\
824 & & & & & \DWOPstackvalue \\
825 0x48 & \XXLLEeol &&&& \\
828 0x49 & \XXLLEsl & [10] & 0x0004 & 0x0001 & \DWOPregeighteen~(xmm1) \\
829 0x52 & \XXLLEsl & [11] & 0x01bd & 0x0002 & \DWOPfbreg: -36 \\
830 0x5c & \XXLLEeol &&&& \\
835 \caption{Split object example: \texttt{demo2.dwo} DWARF \dotdebugloclistsdwo{} excerpts}
836 \label{fig:splitobjectexampledemotwodwodwarfdebuglocdwoexcerpts}
840 In each \DWLLEstartlength{} entry,
842 the start field is the index
843 of a slot in the \dotdebugaddr{} section, relative to the base
844 offset defined by the compilations unit's \DWATaddrbase{}
845 attribute. The \dotdebugaddr{} slots referenced by these entries give
846 the relocated address of a label within the function where the
847 address range begins.
848 The following length field gives the length of the
849 address range. The location, consisting of its own length and
850 a DWARF expression, is last.
853 \section{DWARF Package File Example}
854 \label{app:dwarfpackagefileexample}
855 \addtoindexx{DWARF duplicate elimination!examples}
857 A \addtoindex{DWARF package file}
858 (see Section \refersec{datarep:dwarfpackagefiles})
859 is a collection of split DWARF object files.
860 In general, it will be much smaller than the sum of the split
861 DWARF object files, because the packaging process removes duplicate
862 type units and merges the string tables. Aside from those two
863 optimizations, however, each compilation unit and each type unit
864 from a split DWARF object file is copied verbatim into the package
867 The package file contains the same set of sections as a split
868 DWARF object file, plus two additional sections described below.
870 The packaging utility, like a linker, combines sections of the
871 same name by concatenation. While a split DWARF object may
872 contain multiple \dotdebuginfodwo{} sections, one for the
873 compilation unit, and one for each type unit, a package file
874 contains a single \dotdebuginfodwo{} section. The combined
875 \dotdebuginfodwo{} section contains each compilation unit and one
876 copy of each type unit (discarding any duplicate type
879 As part of merging the string tables, the packaging utility
880 treats the \dotdebugstrdwo{} and \dotdebugstroffsetsdwo{}
881 sections specially. Rather than
882 combining them by simple concatenation, it instead builds a new
883 string table consisting of the unique strings from each input
884 string table. Because all references to these strings use
886 the packaging utility only needs to adjust the
887 string offsets in each \dotdebugstroffsetsdwo{} contribution after
888 building the new \dotdebugstrdwo{} section.
890 Each compilation unit or type unit consists of a set of
891 inter-related contributions to each section in the package file.
892 For example, a compilation unit may have contributions in
893 \dotdebuginfodwo{}, \dotdebugabbrevdwo{}, \dotdebuglinedwo{},
894 \dotdebugstroffsetsdwo{}, and so on. In order to maintain the ability
895 for a consumer to follow references between these sections, the
896 package file contains two additional sections: a compilation unit
897 (CU) index, and a type unit (TU) index. These indexes allow a
898 consumer to look up a compilation unit (by its \CUsignature) or
899 a type unit (by its \TUsignature), and locate each contribution
900 that belongs to that unit.
902 For example, consider a package file, \texttt{demo.dwp}, formed by
903 combining \texttt{demo1.dwo} and \texttt{demo2.dwo} from the previous example
904 (see Appendix \refersec{app:splitdwarfobjectfileexample}). The
905 resulting package file would contain the sections shown in Figure
906 \refersec{fig:sectionsandcontributionsinapackagefile},
907 with contributions from each input file as shown.
911 \begin{tabular}{P{4.7cm}|P{8cm}}
913 \bfseries Section & \bfseries Source of section contributions \\
916 & \dotdebugabbrevdwo{} from \texttt{demo1.dwo} \newline
917 \dotdebugabbrevdwo{} from \texttt{demo2.dwo} \\
919 \dotdebuginfodwo{} \newline (for the compilation units and type units)
920 & compilation unit from \texttt{demo1.dwo} \newline
921 compilation unit from \texttt{demo2.dwo} \newline
922 type unit for class \texttt{Box} from \texttt{demo1.dwo} \newline
923 type unit for class \texttt{Point} from \texttt{demo1.dwo} \newline
924 type unit for class \texttt{Line} from \texttt{demo2.dwo} \\
926 \dotdebugloclistsdwo{}
927 & \dotdebugloclistsdwo{} from \texttt{demo1.dwo} \newline
928 \dotdebugloclistsdwo{} from \texttt{demo2.dwo} \\
931 & \dotdebuglinedwo{} from \texttt{demo1.dwo} \newline
932 \dotdebuglinedwo{} from \texttt{demo2.dwo} \\
934 \dotdebugstroffsetsdwo{}
935 & \dotdebugstroffsetsdwo{} from \texttt{demo1.dwo}, \hspace*{6mm}adjusted \newline
936 \dotdebugstroffsetsdwo{} from \texttt{demo2.dwo}, \hspace*{6mm}adjusted \\
939 & merged string table generated by package utility \\
942 & CU index generated by package utility \\
945 & TU index generated by package utility \\
949 \caption{Sections and contributions in example package file \texttt{demo.dwp}}
950 \label{fig:sectionsandcontributionsinapackagefile}
954 The \dotdebugabbrevdwo{}, \dotdebugloclistsdwo{} and \dotdebuglinedwo{}
955 sections are copied over from the two \texttt{.dwo} files as
956 individual contributions to the corresponding sections in the
958 The offset of each contribution within
959 the combined section and the size of each contribution is recorded
960 as part of the CU and TU index sections.
962 The \dotdebuginfodwo{} sections corresponding to each compilation
963 unit are copied as individual contributions to the combined
964 \dotdebuginfodwo{} section, and one copy of each type unit
965 is also copied. The type units for class \texttt{Box} and class
966 \texttt{Point}, for example, are contained in both \texttt{demo1.dwo}
967 and \texttt{demo2.dwo}, but only one instance of each is copied into
970 The \dotdebugstrdwo{} sections from each file are merged to
971 form a new string table with no duplicates, requiring the
972 adjustment of all references to those strings. The
973 \dotdebugstroffsetsdwo{} sections from the \texttt{.dwo} files
974 are copied as individual contributions, but the string table offset
975 in each slot of those contributions is adjusted to point to
976 the correct offset in the merged string table.
979 The \dotdebugcuindex{} and \dotdebugtuindex{} sections provide a
980 directory to these contributions.
981 Figure \referfol{fig:examplecuindexsection} shows an example CU
982 index section containing the two compilation units from
983 \texttt{demo1.dwo} and \texttt{demo2.dwo}. The CU index shows that
984 for the compilation unit from \texttt{demo1.dwo}, with \CUsignature{}
985 \texttt{0x044e413b8a2d1b8f}, its contribution to the \dotdebuginfodwo{}
986 section begins at offset 0, and is 325 bytes long. For the compilation
987 unit from \texttt{demo2.dwo}, with \CUsignature{}
988 \texttt{0xb5f0ecf455e7e97e}, its contribution to the \dotdebuginfodwo{}
989 section begins at offset 325, and is 673 bytes long.
991 Likewise, we can find the contributions to the related sections.
992 In Figure \refersec{fig:splitobjectexampledemotwodwodwarfdebuglocdwoexcerpts},
993 we see that the \DWTAGvariable{} DIE at \texttt{7\$} has a
994 reference to a location list at offset 0x49 (decimal 73). Because
995 this is part of the compilation unit for \texttt{demo2.dwo}, with
996 unit signature \texttt{0xb5f0ecf455e7e97e}, we see that its contribution
997 to \dotdebugloclistsdwo{} begins at offset 84, so the location list from
998 Figure \refersec{fig:splitobjectexampledemotwodwodwarfdebuglocdwoexcerpts}
999 can be found in \texttt{demo.dwp} at offset 157 (84 + 73) in
1000 the combined \dotdebugloclistsdwo{} section.
1004 \begin{tabular}{lrrrrrr}
1006 \multicolumn{7}{c}{Section header} \\
1008 \multicolumn{2}{l}{Version:}& 5 &&&&\\
1009 \multicolumn{2}{l}{Number of columns:}& 5 &&&&\\
1010 \multicolumn{2}{l}{Number of used entries:}& 2 &&&&\\
1011 \multicolumn{2}{l}{Number of slots:}& 16 &&&&\\
1013 \multicolumn{7}{c}{Offset table} \\
1015 slot& signature& info& abbrev& loc& line& str\_off \\
1016 14& \texttt{0xb5f0ecf455e7e97e}& 325& 452& 84& 52& 72 \\
1017 15& \texttt{0x044e413b8a2d1b8f}& 0& 0& 0& 0& 0 \\
1019 \multicolumn{7}{c}{Size table} \\
1021 slot& & info& abbrev& loc& line& str\_off \\
1022 14& & 673& 593& 93& 52& 120 \\
1023 15& & 325& 452& 84& 52& 72 \\
1027 \caption{Example CU index section}
1028 \label{fig:examplecuindexsection}
1032 Figure \referfol{fig:exampletuindexsection}
1033 shows an example TU index section containing the
1034 three type units for classes \texttt{Box}, \texttt{Point}, and
1035 \texttt{Line}. Each type unit
1036 contains contributions from \dotdebuginfodwo{}, \dotdebugabbrevdwo{},
1037 \dotdebuglinedwo{} and \dotdebugstroffsetsdwo{}. In this example, the
1038 type units for classes \texttt{Box} and \texttt{Point} come from
1039 \texttt{demo1.dwo}, and
1040 share the abbreviations table, line number table, and string
1041 offsets table with the compilation unit from \texttt{demo1.dwo}.
1042 Likewise, the type unit for class \texttt{Line} shares tables
1043 from \texttt{demo2.dwo}.
1045 The sharing of these tables between compilation units and type units
1046 is typical for some implementations, but is not required by the
1051 \begin{tabular}{lrrrrr}
1053 \multicolumn{6}{c}{Section header} \\
1055 \multicolumn{2}{l}{Version:}& 5 \\
1056 \multicolumn{2}{l}{Number of columns:}& 4 \\
1057 \multicolumn{2}{l}{Number of used entries:}& 3 \\
1058 \multicolumn{2}{l}{Number of slots:}& 32 \\
1060 \multicolumn{6}{c}{Offset table} \\
1062 slot& signature& info& abbrev& line& str\_off \\
1063 11& \texttt{0x2f33248f03ff18ab}& 1321& 0& 0& 0 \\
1064 17& \texttt{0x79c7ef0eae7375d1}& 1488& 452& 52& 72 \\
1065 27& \texttt{0xe97a3917c5a6529b}& 998& 0& 0& 0 \\
1067 \multicolumn{6}{c}{Size table} \\
1069 slot& & info& abbrev& line& str\_off \\
1070 11& & 167& 452& 52& 72 \\
1071 17& & 217& 593& 52& 120 \\
1072 27& & 323& 452& 52& 72 \\
1077 \caption{Example TU index section}
1078 \label{fig:exampletuindexsection}