summaryrefslogtreecommitdiff
path: root/include/lld/ReaderWriter/AtomLayout.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-03-24 21:31:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-03-24 21:31:36 +0000
commitfb911942f1434f3d1750f83f25f5e42c80e60638 (patch)
tree1678c4a4f0182e4029a86d135aa4a1b7d09e3c41 /include/lld/ReaderWriter/AtomLayout.h
Notes
Diffstat (limited to 'include/lld/ReaderWriter/AtomLayout.h')
-rw-r--r--include/lld/ReaderWriter/AtomLayout.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/lld/ReaderWriter/AtomLayout.h b/include/lld/ReaderWriter/AtomLayout.h
new file mode 100644
index 000000000000..ad4cd0607b88
--- /dev/null
+++ b/include/lld/ReaderWriter/AtomLayout.h
@@ -0,0 +1,39 @@
+//===- include/lld/ReaderWriter/AtomLayout.h ------------------------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_READER_WRITER_ATOM_LAYOUT_H
+#define LLD_READER_WRITER_ATOM_LAYOUT_H
+
+namespace lld {
+class Atom;
+
+/// AtomLayouts are used by a writer to manage physical positions of atoms.
+/// AtomLayout has two positions; one is file offset, and the other is the
+/// address when loaded into memory.
+///
+/// Construction of AtomLayouts is usually a multi-pass process. When an atom
+/// is appended to a section, we don't know the starting address of the
+/// section. Thus, we have no choice but to store the offset from the
+/// beginning of the section as AtomLayout values. After all sections starting
+/// address are fixed, AtomLayout is revisited to get the offsets updated by
+/// adding the starting addresses of the section.
+struct AtomLayout {
+ AtomLayout(const Atom *a, uint64_t fileOff, uint64_t virAddr)
+ : _atom(a), _fileOffset(fileOff), _virtualAddr(virAddr) {}
+
+ AtomLayout() : _atom(nullptr), _fileOffset(0), _virtualAddr(0) {}
+
+ const Atom *_atom;
+ uint64_t _fileOffset;
+ uint64_t _virtualAddr;
+};
+
+}
+
+#endif