[PATCH] add support for LayoutAfter/LayoutBefore references
kledzik at apple.com
kledzik at apple.com
Wed Feb 6 16:25:31 PST 2013
================
Comment at: include/lld/Core/Pass.h:117-146
@@ -113,11 +116,32 @@
-/// Pass for sorting atoms.
-class OrderPass : public Pass {
+/// Pass for atoms layout.
+class LayoutPass : public Pass {
public:
- OrderPass() : Pass() {}
-
+ class CompareAtoms {
+ public:
+ CompareAtoms(const LayoutPass &pass) : _layout(pass) {}
+ bool operator()(const DefinedAtom *left, const DefinedAtom *right);
+ private:
+ const LayoutPass &_layout;
+ };
+
+ LayoutPass() : Pass(), _compareAtoms(*this) {}
+
/// Sorts atoms in mergedFile by content type then by command line order.
virtual void perform(MutableFile &mergedFile);
-};
+ virtual ~LayoutPass() {}
+
+private:
+ void buildFollowOnTable(MutableFile::DefinedAtomRange &range);
+ void buildPrecededByTable(MutableFile::DefinedAtomRange &range);
+ void buildOrdinalOverrideMap(MutableFile::DefinedAtomRange &range);
+
+ typedef std::map<const Atom *, const Atom *> AtomToAtomT;
+ typedef std::map<const Atom *, uint64_t> AtomToOrdinalT;
+ AtomToAtomT _followOnNexts;
+ AtomToAtomT _followOnRoots;
+ AtomToOrdinalT _ordinalOverrideMap;
+ CompareAtoms _compareAtoms;
+};
----------------
Michael Spencer wrote:
> This should really be in the Passes library.
I think what Michael means here is that Pass.h should just contain the Interface to the pass. The implementation details should be in the pass implementation.
================
Comment at: include/lld/Core/Reference.h:38-39
@@ +37,4 @@
+ enum {
+ LayoutBefore = -1,
+ LayoutAfter = -2
+ };
----------------
The type should be encoded in these names. These values are "kinds", so better names would be kindLayoutBefore and kindLayoutAfter.
================
Comment at: include/lld/Core/Reference.h:55-59
@@ +54,7 @@
+ case -1:
+ return "layoutbefore";
+ break;
+ case -2:
+ return "layoutafter";
+ break;
+ default:
----------------
The usual YAML style is a dash between words (e.g. layout-before). Where else are these string used?
================
Comment at: lib/ReaderWriter/ELF/Atoms.h:78-82
@@ -80,7 +77,7 @@
private:
- const Atom *_target;
- uint64_t _targetSymbolIndex;
- uint64_t _offsetInAtom;
- Addend _addend;
- Kind _kind;
+ const Atom *_target;
+ uint64_t _targetSymbolIndex;
+ uint64_t _offsetInAtom;
+ Addend _addend;
+ Kind _kind;
};
----------------
:-(. I find having the ivar names vertically aligned to be much more readable. Why did you go out of your way to remove that?
================
Comment at: test/followon-test.objtxt:30
@@ +29,2 @@
+# CHKORDER: - name: fn2
+# CHKORDER: - name: fn3
----------------
Since the kind name is "layout after" seems like the test file name should match (layout-after.objtxt).
http://llvm-reviews.chandlerc.com/D373
More information about the llvm-commits
mailing list