[llvm-commits] [lld] r153964 - in /lld/trunk: include/lld/Core/ lib/Core/ lib/Passes/
Michael J. Spencer
bigcheesegs at gmail.com
Tue Apr 3 11:40:28 PDT 2012
Author: mspencer
Date: Tue Apr 3 13:40:27 2012
New Revision: 153964
URL: http://llvm.org/viewvc/llvm-project?rev=153964&view=rev
Log:
Remove trailing whitespace.
Modified:
lld/trunk/include/lld/Core/Atom.h
lld/trunk/include/lld/Core/DefinedAtom.h
lld/trunk/include/lld/Core/NativeReader.h
lld/trunk/include/lld/Core/NativeWriter.h
lld/trunk/include/lld/Core/Pass.h
lld/trunk/include/lld/Core/Reference.h
lld/trunk/include/lld/Core/Resolver.h
lld/trunk/include/lld/Core/SharedLibraryAtom.h
lld/trunk/include/lld/Core/SymbolTable.h
lld/trunk/include/lld/Core/UndefinedAtom.h
lld/trunk/include/lld/Core/YamlReader.h
lld/trunk/lib/Core/NativeFileFormat.h
lld/trunk/lib/Core/NativeReader.cpp
lld/trunk/lib/Core/NativeWriter.cpp
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/lib/Core/SymbolTable.cpp
lld/trunk/lib/Core/YamlKeyValues.cpp
lld/trunk/lib/Core/YamlKeyValues.h
lld/trunk/lib/Core/YamlReader.cpp
lld/trunk/lib/Core/YamlWriter.cpp
lld/trunk/lib/Passes/StubsPass.cpp
Modified: lld/trunk/include/lld/Core/Atom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Atom.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Atom.h (original)
+++ lld/trunk/include/lld/Core/Atom.h Tue Apr 3 13:40:27 2012
@@ -28,7 +28,7 @@
/// The linker has a Graph Theory model of linking. An object file is seen
/// as a set of Atoms with References to other Atoms. Each Atom is a node
/// and each Reference is an edge. An Atom can be a DefinedAtom which has
-/// content or a UndefinedAtom which is a placeholder and represents an
+/// content or a UndefinedAtom which is a placeholder and represents an
/// undefined symbol (extern declaration).
///
class Atom {
@@ -53,11 +53,11 @@
Definition definition() const { return _definition; };
static inline bool classof(const Atom *a) { return true; }
-
+
protected:
/// Atom is an abstract base class. Only subclasses can access constructor.
Atom(Definition def) : _definition(def) {}
-
+
/// The memory for Atom objects is always managed by the owning File
/// object. Therefore, no one but the owning File object should call
/// delete on an Atom. In fact, some File objects may bulk allocate
Modified: lld/trunk/include/lld/Core/DefinedAtom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/DefinedAtom.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/DefinedAtom.h (original)
+++ lld/trunk/include/lld/Core/DefinedAtom.h Tue Apr 3 13:40:27 2012
@@ -31,7 +31,7 @@
///
/// Here are some example attribute sets for common atoms. If a particular
/// attribute is not listed, the default values are: definition=regular,
-/// sectionChoice=basedOnContent, scope=translationUnit, merge=no,
+/// sectionChoice=basedOnContent, scope=translationUnit, merge=no,
/// deadStrip=normal, interposable=no
///
/// C function: void foo() {} <br>
@@ -44,7 +44,7 @@
/// name=count, type=data, perm=rw_, scope=global
///
/// C tentative definition: int bar; <br>
-/// name=bar, type=zerofill, perm=rw_, scope=global,
+/// name=bar, type=zerofill, perm=rw_, scope=global,
/// merge=asTentative, interposable=yesAndRuntimeWeak
///
/// Uninitialized C static variable: static int stuff; <br>
@@ -60,12 +60,12 @@
/// name=foo, type=code, perm=r_x, scope=global, deadStrip=never
///
/// Non-inlined C++ inline method: inline void Foo::doit() {} <br>
-/// name=_ZN3Foo4doitEv, type=code, perm=r_x, scope=global,
+/// name=_ZN3Foo4doitEv, type=code, perm=r_x, scope=global,
/// mergeDupes=asWeak
///
-/// Non-inlined C++ inline method whose address is taken:
+/// Non-inlined C++ inline method whose address is taken:
/// inline void Foo::doit() {} <br>
-/// name=_ZN3Foo4doitEv, type=code, perm=r_x, scope=global,
+/// name=_ZN3Foo4doitEv, type=code, perm=r_x, scope=global,
/// mergeDupes=asAddressedWeak
///
/// literal c-string: "hello" <br>
@@ -81,9 +81,9 @@
/// name="" type=initializer, perm=rw_l,
/// sectionChoice=customRequired
///
-/// C function place in custom section: __attribute__((section("__foo")))
+/// C function place in custom section: __attribute__((section("__foo")))
/// void foo() {} <br>
-/// name=foo, type=code, perm=r_x, scope=global,
+/// name=foo, type=code, perm=r_x, scope=global,
/// sectionChoice=customRequired, sectionName=__foo
///
class DefinedAtom : public Atom {
@@ -92,7 +92,7 @@
enum Scope {
scopeTranslationUnit, ///< Accessible only to atoms in the same translation
/// unit (e.g. a C static).
- scopeLinkageUnit, ///< Accessible to atoms being linked but not visible
+ scopeLinkageUnit, ///< Accessible to atoms being linked but not visible
/// to runtime loader (e.g. visibility=hidden).
scopeGlobal ///< Accessible to all atoms and visible to runtime
/// loader (e.g. visibility=default).
@@ -101,17 +101,17 @@
enum Interposable {
interposeNo, // linker can directly bind uses of this atom
interposeYes, // linker must indirect (through GOT) uses
- interposeYesAndRuntimeWeak // must indirect and mark symbol weak in final
+ interposeYesAndRuntimeWeak // must indirect and mark symbol weak in final
// linked image
};
enum Merge {
mergeNo, // Another atom with same name is error
mergeAsTentative, // Is ANSI C tentative defintion, can be coalesced
- mergeAsWeak, // is C++ inline definition that was not inlined,
+ mergeAsWeak, // is C++ inline definition that was not inlined,
// but address was not taken, so atom can be hidden
// by linker
- mergeAsWeakAndAddressUsed // is C++ definition inline definition whose
+ mergeAsWeakAndAddressUsed // is C++ definition inline definition whose
// address was taken.
};
@@ -195,72 +195,72 @@
virtual uint64_t size() const = 0;
/// scope - The visibility of this atom to other atoms. C static functions
- /// have scope scopeTranslationUnit. Regular C functions have scope
+ /// have scope scopeTranslationUnit. Regular C functions have scope
/// scopeGlobal. Functions compiled with visibility=hidden have scope
/// scopeLinkageUnit so they can be see by other atoms being linked but not
/// by the OS loader.
virtual Scope scope() const = 0;
-
+
/// interposable - Whether the linker should use direct or indirect
/// access to this atom.
virtual Interposable interposable() const = 0;
-
- /// merge - how the linker should handle if multiple atoms have
+
+ /// merge - how the linker should handle if multiple atoms have
/// the same name.
virtual Merge merge() const = 0;
-
+
/// contentType - The type of this atom, such as code or data.
virtual ContentType contentType() const = 0;
-
- /// alignment - The alignment constraints on how this atom must be laid out
+
+ /// alignment - The alignment constraints on how this atom must be laid out
/// in the final linked image (e.g. 16-byte aligned).
virtual Alignment alignment() const = 0;
-
+
/// sectionChoice - Whether this atom must be in a specially named section
- /// in the final linked image, or if the linker can infer the section
+ /// in the final linked image, or if the linker can infer the section
/// based on the contentType().
virtual SectionChoice sectionChoice() const = 0;
-
+
/// customSectionName - If sectionChoice() != sectionBasedOnContent, then
/// this return the name of the section the atom should be placed into.
- virtual llvm::StringRef customSectionName() const = 0;
-
- /// deadStrip - constraints on whether the linker may dead strip away
+ virtual StringRef customSectionName() const = 0;
+
+ /// deadStrip - constraints on whether the linker may dead strip away
/// this atom.
virtual DeadStripKind deadStrip() const = 0;
-
+
/// permissions - Returns the OS memory protections required for this atom's
/// content at runtime. A function atom is R_X, a global variable is RW_,
/// and a read-only constant is R__.
virtual ContentPermissions permissions() const = 0;
-
+
/// isThumb - only applicable to ARM code. Tells the linker if the code
/// uses thumb or arm instructions. The linker needs to know this to
/// set the low bit of pointers to thumb functions.
virtual bool isThumb() const = 0;
-
+
/// isAlias - means this is a zero size atom that exists to provide an
/// alternate name for another atom. Alias atoms must have a special
/// Reference to the atom they alias which the layout engine recognizes
/// and forces the alias atom to layout right before the target atom.
- virtual bool isAlias() const = 0;
-
- /// rawContent - returns a reference to the raw (unrelocated) bytes of
+ virtual bool isAlias() const = 0;
+
+ /// rawContent - returns a reference to the raw (unrelocated) bytes of
/// this Atom's content.
virtual ArrayRef<uint8_t> rawContent() const = 0;
-
+
/// This class abstracts iterating over the sequence of References
/// in an Atom. Concrete instances of DefinedAtom must implement
/// the derefIterator() and incrementIterator methods.
class reference_iterator {
public:
- reference_iterator(const DefinedAtom& a, const void* it)
+ reference_iterator(const DefinedAtom& a, const void* it)
: _atom(a), _it(it) { }
const Reference* operator*() const {
return _atom.derefIterator(_it);
}
-
+
const Reference* operator->() const {
return _atom.derefIterator(_it);
}
@@ -280,30 +280,30 @@
/// Returns an iterator to the beginning of this Atom's References
virtual reference_iterator referencesBegin() const = 0;
-
+
/// Returns an iterator to the end of this Atom's References
virtual reference_iterator referencesEnd() const = 0;
-
+
static inline bool classof(const Atom *a) {
return a->definition() == definitionRegular;
}
static inline bool classof(const DefinedAtom *) { return true; }
-
+
protected:
- /// DefinedAtom is an abstract base class.
+ /// DefinedAtom is an abstract base class.
/// Only subclasses can access constructor.
DefinedAtom() : Atom(definitionRegular) { }
-
+
/// The memory for DefinedAtom objects is always managed by the owning File
/// object. Therefore, no one but the owning File object should call
/// delete on an Atom. In fact, some File objects may bulk allocate
/// an array of Atoms, so they cannot be individually deleted by anyone.
virtual ~DefinedAtom() {}
-
+
/// Returns a pointer to the Reference object that the abstract
/// iterator "points" to.
virtual const Reference* derefIterator(const void* iter) const = 0;
-
+
/// Adjusts the abstract iterator to "point" to the next Reference object
/// for this Atom.
virtual void incrementIterator(const void*& iter) const = 0;
Modified: lld/trunk/include/lld/Core/NativeReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/NativeReader.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/NativeReader.h (original)
+++ lld/trunk/include/lld/Core/NativeReader.h Tue Apr 3 13:40:27 2012
@@ -17,19 +17,19 @@
#include <memory>
#include <vector>
-namespace llvm {
+namespace llvm {
class MemoryBuffer;
class StringRef;
}
namespace lld {
- /// parseNativeObjectFileOrSTDIN - Open the specified native object file (use
+ /// parseNativeObjectFileOrSTDIN - Open the specified native object file (use
/// stdin if the path is "-") and instantiate into an lld::File object.
error_code parseNativeObjectFileOrSTDIN( StringRef path
, std::unique_ptr<File> &result);
- /// parseNativeObjectFile - Parse the specified native object file
+ /// parseNativeObjectFile - Parse the specified native object file
/// (in a buffer) and instantiate into an lld::File object.
error_code parseNativeObjectFile( std::unique_ptr<llvm::MemoryBuffer> &mb
, StringRef path
Modified: lld/trunk/include/lld/Core/NativeWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/NativeWriter.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/NativeWriter.h (original)
+++ lld/trunk/include/lld/Core/NativeWriter.h Tue Apr 3 13:40:27 2012
@@ -14,7 +14,7 @@
#include "llvm/Support/raw_ostream.h"
-namespace llvm {
+namespace llvm {
class StringRef;
}
Modified: lld/trunk/include/lld/Core/Pass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Pass.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Pass.h (original)
+++ lld/trunk/include/lld/Core/Pass.h Tue Apr 3 13:40:27 2012
@@ -22,11 +22,11 @@
/// Once the core linking is done (which resolves references, coalesces atoms
/// and produces a complete Atom graph), the linker runs a series of passes
/// on the Atom graph. The graph is modeled as a File, which means the pass
-/// has access to all the atoms and to File level attributes. Each pass does
-/// a particular transformation to the Atom graph or to the File attributes.
+/// has access to all the atoms and to File level attributes. Each pass does
+/// a particular transformation to the Atom graph or to the File attributes.
///
/// This is the abstract base class for all passes. A Pass does its
-/// actual work in it perform() method. It can iterator over Atoms in the
+/// actual work in it perform() method. It can iterator over Atoms in the
/// graph using the *begin()/*end() atom iterator of the File. It can add
/// new Atoms to the graph using the File's addAtom() method.
///
@@ -39,8 +39,8 @@
protected:
// Only subclassess can be instantiated.
Pass(File& f, Platform& p) : _file(f), _platform(p) {}
-
-
+
+
File& _file;
Platform& _platform;
};
Modified: lld/trunk/include/lld/Core/Reference.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Reference.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Reference.h (original)
+++ lld/trunk/include/lld/Core/Reference.h Tue Apr 3 13:40:27 2012
@@ -17,51 +17,51 @@
///
/// The linker has a Graph Theory model of linking. An object file is seen
/// as a set of Atoms with References to other Atoms. Each Atom is a node
-/// and each Reference is an edge.
+/// and each Reference is an edge.
///
-/// For example if a function contains a call site to "malloc" 40 bytes into
+/// For example if a function contains a call site to "malloc" 40 bytes into
/// the Atom, then the function Atom will have a Reference of: offsetInAtom=40,
/// kind=callsite, target=malloc, addend=0.
///
/// Besides supporting traditional "relocations", References are also used
-/// grouping atoms (group comdat), forcing layout (one atom must follow
+/// grouping atoms (group comdat), forcing layout (one atom must follow
/// another), marking data-in-code (jump tables or ARM constants), etc.
///
class Reference {
public:
- /// The meaning of positive kind values is architecture specific.
+ /// The meaning of positive kind values is architecture specific.
/// Negative kind values are architecture independent.
typedef int32_t Kind;
// A value to be added to the value of a target
typedef int64_t Addend;
- /// What sort of reference this is.
+ /// What sort of reference this is.
virtual Kind kind() const = 0;
-
+
/// During linking, some optimizations may change the code gen and
/// hence the reference kind.
virtual void setKind(Kind) = 0;
-
- /// If the reference is a fixup in the Atom, then this returns the
+
+ /// If the reference is a fixup in the Atom, then this returns the
/// byte offset into the Atom's content to do the fix up.
virtual uint64_t offsetInAtom() const = 0;
-
+
/// If the reference is an edge to another Atom, then this returns the
/// other Atom. Otherwise, it returns nullptr.
virtual const class Atom * target() const = 0;
-
+
/// During linking, the linker may merge graphs which coalesces some nodes
/// (i.e. Atoms). To switch the target of a reference, this method is called.
virtual void setTarget(const class Atom *) = 0;
-
+
/// Some relocations require a symbol and a value (e.g. foo + 4).
virtual Addend addend() const = 0;
-
+
protected:
/// Atom is an abstract base class. Only subclasses can access constructor.
Reference() {}
-
+
/// The memory for Reference objects is always managed by the owning File
/// object. Therefore, no one but the owning File object should call
/// delete on an Reference. In fact, some File objects may bulk allocate
Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Tue Apr 3 13:40:27 2012
@@ -81,7 +81,7 @@
class MergedFile : public File {
public:
MergedFile() : File("<linker-internal>") { }
-
+
virtual const atom_collection<DefinedAtom>& defined() const {
@@ -96,10 +96,10 @@
virtual const atom_collection<AbsoluteAtom>& absolute() const {
return _absoluteAtoms;
}
-
+
void addAtoms(std::vector<const Atom*>& atoms);
- virtual void addAtom(const Atom& atom);
+ virtual void addAtom(const Atom& atom);
private:
atom_collection_vector<DefinedAtom> _definedAtoms;
@@ -107,9 +107,9 @@
atom_collection_vector<SharedLibraryAtom> _sharedLibraryAtoms;
atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
};
-
-
-
+
+
+
Platform& _platform;
const InputFiles& _inputFiles;
SymbolTable _symbolTable;
Modified: lld/trunk/include/lld/Core/SharedLibraryAtom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/SharedLibraryAtom.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/SharedLibraryAtom.h (original)
+++ lld/trunk/include/lld/Core/SharedLibraryAtom.h Tue Apr 3 13:40:27 2012
@@ -35,7 +35,7 @@
return a->definition() == definitionSharedLibrary;
}
static inline bool classof(const SharedLibraryAtom *) { return true; }
-
+
protected:
SharedLibraryAtom() : Atom(definitionSharedLibrary) {}
virtual ~SharedLibraryAtom() {}
Modified: lld/trunk/include/lld/Core/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/SymbolTable.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/SymbolTable.h (original)
+++ lld/trunk/include/lld/Core/SymbolTable.h Tue Apr 3 13:40:27 2012
@@ -46,10 +46,10 @@
/// @brief add atom to symbol table
void add(const SharedLibraryAtom &);
-
+
/// @brief add atom to symbol table
void add(const AbsoluteAtom &);
-
+
/// @brief checks if name is in symbol table and if so atom is not
/// UndefinedAtom
bool isDefined(StringRef sym);
@@ -79,12 +79,12 @@
};
typedef llvm::DenseMap<StringRef, const Atom *,
StringRefMappingInfo> NameToAtom;
-
+
struct AtomMappingInfo {
static const DefinedAtom * getEmptyKey() { return nullptr; }
static const DefinedAtom * getTombstoneKey() { return (DefinedAtom*)(-1); }
static unsigned getHashValue(const DefinedAtom * const Val);
- static bool isEqual(const DefinedAtom * const LHS,
+ static bool isEqual(const DefinedAtom * const LHS,
const DefinedAtom * const RHS);
};
typedef llvm::DenseSet<const DefinedAtom*, AtomMappingInfo> AtomContentSet;
Modified: lld/trunk/include/lld/Core/UndefinedAtom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/UndefinedAtom.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/UndefinedAtom.h (original)
+++ lld/trunk/include/lld/Core/UndefinedAtom.h Tue Apr 3 13:40:27 2012
@@ -25,37 +25,37 @@
enum CanBeNull {
/// Normal symbols must be resolved at build time
canBeNullNever,
-
+
/// This symbol can be missing at runtime and will evalute to nullptr.
/// That is, the static linker still must find a definition (usually
/// is some shared library), but at runtime, the dynamic loader
/// will allow the symbol to be missing and resolved to nullptr.
///
/// On Darwin this is generated using a function prototype with
- /// __attribute__((weak_import)).
+ /// __attribute__((weak_import)).
/// On linux this is generated using a function prototype with
/// __attribute__((weak)).
canBeNullAtRuntime,
-
-
+
+
/// This symbol can be missing at build time.
/// That is, the static linker will not error if a definition for
- /// this symbol is not found at build time. Instead, the linker
+ /// this symbol is not found at build time. Instead, the linker
/// will build an executable that lets the dynamic loader find the
- /// symbol at runtime.
+ /// symbol at runtime.
/// This feature is not supported on Darwin.
/// On linux this is generated using a function prototype with
/// __attribute__((weak)).
canBeNullAtBuildtime
};
-
+
virtual CanBeNull canBeNull() const = 0;
-
+
static inline bool classof(const Atom *a) {
return a->definition() == definitionUndefined;
}
static inline bool classof(const UndefinedAtom *) { return true; }
-
+
protected:
UndefinedAtom() : Atom(definitionUndefined) {}
virtual ~UndefinedAtom() {}
Modified: lld/trunk/include/lld/Core/YamlReader.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/YamlReader.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/YamlReader.h (original)
+++ lld/trunk/include/lld/Core/YamlReader.h Tue Apr 3 13:40:27 2012
@@ -28,8 +28,8 @@
namespace yaml {
- /// parseObjectTextFileOrSTDIN - Open the specified YAML file (use stdin if
- /// the path is "-") and parse into lld::File object(s) and append each to
+ /// parseObjectTextFileOrSTDIN - Open the specified YAML file (use stdin if
+ /// the path is "-") and parse into lld::File object(s) and append each to
/// the specified vector<File*>.
error_code parseObjectTextFileOrSTDIN( StringRef path
, Platform&
Modified: lld/trunk/lib/Core/NativeFileFormat.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeFileFormat.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/NativeFileFormat.h (original)
+++ lld/trunk/lib/Core/NativeFileFormat.h Tue Apr 3 13:40:27 2012
@@ -19,21 +19,21 @@
// Overview:
//
// The number one design goal of this file format is enable the linker to
-// read object files into in-memory Atom objects extremely quickly.
-// The second design goal is to enable future modifications to the
-// Atom attribute model.
+// read object files into in-memory Atom objects extremely quickly.
+// The second design goal is to enable future modifications to the
+// Atom attribute model.
//
-// The llvm native object file format is not like traditional object file
+// The llvm native object file format is not like traditional object file
// formats (e.g. ELF, COFF, mach-o). There is no symbol table and no
-// sections. Instead the file is essentially an array of archived Atoms.
+// sections. Instead the file is essentially an array of archived Atoms.
// It is *not* serialized Atoms which would require deserialization into
// in memory objects. Instead it is an array of read-only info about each
// Atom. The NativeReader bulk creates in-memory Atoms which just have
// an ivar which points to the read-only info for that Atom. No additional
// processing is done to construct the in-memory Atoms. All Atom attribute
-// getter methods are virtual calls which dig up the info they need from the
+// getter methods are virtual calls which dig up the info they need from the
// ivar data.
-//
+//
// To support the gradual evolution of Atom attributes, the Atom read-only
// data is versioned. The NativeReader chooses which in-memory Atom class
// to use based on the version. What this means is that if new attributes
@@ -41,16 +41,16 @@
// read-only atom info struct needs to be defined. Then, all the existing
// native reader atom classes need to be modified to do their best effort
// to map their old style read-only data to the new Atom model. At some point
-// some classes to support old versions may be dropped.
+// some classes to support old versions may be dropped.
//
//
// Details:
//
-// The native object file format consists of a header that specifies the
+// The native object file format consists of a header that specifies the
// endianness of the file and the architecture along with a list of "chunks"
// in the file. A Chunk is simply a tagged range of the file. There is
-// one chunk for the array of atom infos. There is another chunk for the
-// string pool, and another for the content pool.
+// one chunk for the array of atom infos. There is another chunk for the
+// string pool, and another for the content pool.
//
// It turns out there most atoms have very similar sets of attributes, only
// the name and content attribute vary. To exploit this fact to reduce the file
@@ -98,7 +98,7 @@
NCS_TargetsTable = 9,
NCS_AddendsTable = 10,
NCS_Content = 11,
-};
+};
//
// The 16-bytes at the start of a native object file
@@ -214,10 +214,10 @@
//
// The NCS_TargetsTable chunk contains an array of uint32_t entries.
-// The C++ class Reference has a target() method that returns a
+// The C++ class Reference has a target() method that returns a
// pointer to another Atom. We can't have pointers in object files,
// so instead NativeReferenceIvarsV1 contains an index to the target.
-// The index is into this NCS_TargetsTable of uint32_t entries.
+// The index is into this NCS_TargetsTable of uint32_t entries.
// The values in this table are the index of the (target) atom in this file.
// For DefinedAtoms the value is from 0 to NCS_DefinedAtomsV1.elementCount.
// For UndefinedAtoms the value is from NCS_DefinedAtomsV1.elementCount to
@@ -230,7 +230,7 @@
// If we allocated space for addends directly in NativeReferenceIvarsV1
// it would double the size of that struct. But since addends are rare,
// we instead just keep a pool of addends and have NativeReferenceIvarsV1
-// (if it needs an addend) just store the index (into the pool) of the
+// (if it needs an addend) just store the index (into the pool) of the
// addend it needs.
//
Modified: lld/trunk/lib/Core/NativeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeReader.cpp?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/NativeReader.cpp (original)
+++ lld/trunk/lib/Core/NativeReader.cpp Tue Apr 3 13:40:27 2012
@@ -32,16 +32,16 @@
//
class NativeDefinedAtomV1 : public DefinedAtom {
public:
- NativeDefinedAtomV1(const NativeFile& f,
+ NativeDefinedAtomV1(const NativeFile& f,
const NativeDefinedAtomIvarsV1* ivarData)
- : _file(&f), _ivarData(ivarData) { }
-
+ : _file(&f), _ivarData(ivarData) { }
+
virtual const class File& file() const;
-
- virtual uint64_t ordinal() const;
-
-
+
+ virtual uint64_t ordinal() const;
+
virtual StringRef name() const;
+
virtual uint64_t size() const {
return _ivarData->contentSize;
}
@@ -49,11 +49,11 @@
virtual DefinedAtom::Scope scope() const {
return (DefinedAtom::Scope)(attributes().scope);
}
-
+
virtual DefinedAtom::Interposable interposable() const {
return (DefinedAtom::Interposable)(attributes().interposable);
}
-
+
virtual DefinedAtom::Merge merge() const {
return (DefinedAtom::Merge)(attributes().merge);
}
@@ -62,46 +62,46 @@
const NativeAtomAttributesV1& attr = attributes();
return (DefinedAtom::ContentType)(attr.contentType);
}
-
+
virtual DefinedAtom::Alignment alignment() const {
return DefinedAtom::Alignment(attributes().align2, attributes().alignModulus);
}
-
+
virtual DefinedAtom::SectionChoice sectionChoice() const {
return (DefinedAtom::SectionChoice)(attributes().sectionChoice);
}
virtual StringRef customSectionName() const;
-
+
virtual DefinedAtom::DeadStripKind deadStrip() const {
return (DefinedAtom::DeadStripKind)(attributes().deadStrip);
}
-
+
virtual DefinedAtom::ContentPermissions permissions() const {
return (DefinedAtom::ContentPermissions)(attributes().permissions);
}
-
+
virtual bool isThumb() const {
return false; //(attributes().thumb != 0);
}
-
+
virtual bool isAlias() const {
return (attributes().alias != 0);
}
-
-
+
virtual ArrayRef<uint8_t> rawContent() const;
+
virtual reference_iterator referencesBegin() const;
-
+
virtual reference_iterator referencesEnd() const;
virtual const Reference* derefIterator(const void*) const;
-
+
virtual void incrementIterator(const void*& it) const;
private:
const NativeAtomAttributesV1& attributes() const;
-
+
const NativeFile* _file;
const NativeDefinedAtomIvarsV1* _ivarData;
};
@@ -114,17 +114,17 @@
//
class NativeUndefinedAtomV1 : public UndefinedAtom {
public:
- NativeUndefinedAtomV1(const NativeFile& f,
+ NativeUndefinedAtomV1(const NativeFile& f,
const NativeUndefinedAtomIvarsV1* ivarData)
- : _file(&f), _ivarData(ivarData) { }
+ : _file(&f), _ivarData(ivarData) { }
virtual const File& file() const;
virtual StringRef name() const;
-
+
virtual CanBeNull canBeNull() const {
return (CanBeNull)(_ivarData->flags & 0x3);
}
-
+
private:
const NativeFile* _file;
@@ -138,14 +138,14 @@
//
class NativeSharedLibraryAtomV1 : public SharedLibraryAtom {
public:
- NativeSharedLibraryAtomV1(const NativeFile& f,
+ NativeSharedLibraryAtomV1(const NativeFile& f,
const NativeSharedLibraryAtomIvarsV1* ivarData)
- : _file(&f), _ivarData(ivarData) { }
+ : _file(&f), _ivarData(ivarData) { }
virtual const File& file() const;
virtual StringRef name() const;
virtual StringRef loadName() const;
-
+
virtual bool canBeNullAtRuntime() const {
return (_ivarData->flags & 0x1);
}
@@ -162,13 +162,13 @@
//
class NativeAbsoluteAtomV1 : public AbsoluteAtom {
public:
- NativeAbsoluteAtomV1(const NativeFile& f,
+ NativeAbsoluteAtomV1(const NativeFile& f,
const NativeAbsoluteAtomIvarsV1* ivarData)
- : _file(&f), _ivarData(ivarData) { }
+ : _file(&f), _ivarData(ivarData) { }
virtual const File& file() const;
virtual StringRef name() const;
-
+
virtual uint64_t value() const {
return _ivarData->value;
}
@@ -186,30 +186,30 @@
//
class NativeReferenceV1 : public Reference {
public:
- NativeReferenceV1(const NativeFile& f,
+ NativeReferenceV1(const NativeFile& f,
const NativeReferenceIvarsV1* ivarData)
- : _file(&f), _ivarData(ivarData) { }
+ : _file(&f), _ivarData(ivarData) { }
virtual uint64_t offsetInAtom() const {
return _ivarData->offsetInAtom;
}
-
+
virtual Kind kind() const {
return _ivarData->kind;
}
-
+
virtual void setKind(Kind);
virtual const Atom* target() const;
virtual Addend addend() const;
virtual void setTarget(const Atom* newAtom);
private:
- // Used in rare cases when Reference is modified,
+ // Used in rare cases when Reference is modified,
// since ivar data is mapped read-only.
void cloneIvarData() {
// TODO: do nothing on second call
NativeReferenceIvarsV1* niv = reinterpret_cast<NativeReferenceIvarsV1*>
- (operator new(sizeof(NativeReferenceIvarsV1),
+ (operator new(sizeof(NativeReferenceIvarsV1),
std::nothrow));
memcpy(niv, _ivarData, sizeof(NativeReferenceIvarsV1));
}
@@ -224,16 +224,16 @@
// lld::File object for native llvm object file
//
class NativeFile : public File {
-public:
+public:
/// Instantiates a File object from a native object file. Ownership
/// of the MemoryBuffer is transfered to the resulting File object.
static error_code make(std::unique_ptr<llvm::MemoryBuffer> mb,
StringRef path,
std::unique_ptr<File> &result) {
- const uint8_t* const base =
+ const uint8_t* const base =
reinterpret_cast<const uint8_t*>(mb->getBufferStart());
- const NativeFileHeader* const header =
+ const NativeFileHeader* const header =
reinterpret_cast<const NativeFileHeader*>(base);
const NativeChunk *const chunks =
reinterpret_cast<const NativeChunk*>(base + sizeof(NativeFileHeader));
@@ -248,7 +248,7 @@
// instantiate NativeFile object and add values to it as found
std::unique_ptr<NativeFile> file(new NativeFile(std::move(mb), path));
-
+
// process each chunk
for(uint32_t i=0; i < header->chunkCount; ++i) {
error_code ec;
@@ -302,10 +302,10 @@
result.reset(file.release());
return make_error_code(native_reader_error::success);
}
-
+
virtual ~NativeFile() {
// _buffer is automatically deleted because of OwningPtr<>
-
+
// All other ivar pointers are pointers into the MemoryBuffer, except
// the _definedAtoms array which was allocated to contain an array
// of Atom objects. The atoms have empty destructors, so it is ok
@@ -317,7 +317,7 @@
delete _references.arrayStart;
delete _targetsTable;
}
-
+
virtual const atom_collection<DefinedAtom>& defined() const {
return _definedAtoms;
}
@@ -334,14 +334,14 @@
virtual void addAtom(const Atom&) {
assert(0 && "cannot add atoms to native .o files");
}
-
+
private:
friend class NativeDefinedAtomV1;
friend class NativeUndefinedAtomV1;
friend class NativeSharedLibraryAtomV1;
friend class NativeAbsoluteAtomV1;
friend class NativeReferenceV1;
-
+
// instantiate array of DefinedAtoms from v1 ivar data in file
error_code processDefinedAtomsV1(const uint8_t *base,
const NativeChunk *chunk) {
@@ -356,11 +356,11 @@
if ( ivarElementSize != sizeof(NativeDefinedAtomIvarsV1) )
return make_error_code(native_reader_error::file_malformed);
uint8_t* atomsEnd = atomsStart + atomsArraySize;
- const NativeDefinedAtomIvarsV1* ivarData =
+ const NativeDefinedAtomIvarsV1* ivarData =
reinterpret_cast<const NativeDefinedAtomIvarsV1*>
(base + chunk->fileOffset);
for(uint8_t* s = atomsStart; s != atomsEnd; s += atomSize) {
- NativeDefinedAtomV1* atomAllocSpace =
+ NativeDefinedAtomV1* atomAllocSpace =
reinterpret_cast<NativeDefinedAtomV1*>(s);
new (atomAllocSpace) NativeDefinedAtomV1(*this, ivarData);
++ivarData;
@@ -371,7 +371,7 @@
this->_definedAtoms._elementCount = chunk->elementCount;
return make_error_code(native_reader_error::success);
}
-
+
// set up pointers to attributes array
error_code processAttributesV1(const uint8_t *base,
const NativeChunk *chunk) {
@@ -379,7 +379,7 @@
this->_attributesMaxOffset = chunk->fileSize;
return make_error_code(native_reader_error::success);
}
-
+
// instantiate array of UndefinedAtoms from v1 ivar data in file
error_code processUndefinedAtomsV1(const uint8_t *base,
const NativeChunk *chunk) {
@@ -389,16 +389,16 @@
(operator new(atomsArraySize, std::nothrow));
if (atomsStart == nullptr)
return make_error_code(native_reader_error::memory_error);
- const size_t ivarElementSize = chunk->fileSize
+ const size_t ivarElementSize = chunk->fileSize
/ chunk->elementCount;
if ( ivarElementSize != sizeof(NativeUndefinedAtomIvarsV1) )
return make_error_code(native_reader_error::file_malformed);
uint8_t* atomsEnd = atomsStart + atomsArraySize;
- const NativeUndefinedAtomIvarsV1* ivarData =
+ const NativeUndefinedAtomIvarsV1* ivarData =
reinterpret_cast<const NativeUndefinedAtomIvarsV1*>
(base + chunk->fileOffset);
for(uint8_t* s = atomsStart; s != atomsEnd; s += atomSize) {
- NativeUndefinedAtomV1* atomAllocSpace =
+ NativeUndefinedAtomV1* atomAllocSpace =
reinterpret_cast<NativeUndefinedAtomV1*>(s);
new (atomAllocSpace) NativeUndefinedAtomV1(*this, ivarData);
++ivarData;
@@ -409,8 +409,8 @@
this->_undefinedAtoms._elementCount = chunk->elementCount;
return make_error_code(native_reader_error::success);
}
-
-
+
+
// instantiate array of ShareLibraryAtoms from v1 ivar data in file
error_code processSharedLibraryAtomsV1(const uint8_t *base,
const NativeChunk *chunk) {
@@ -420,16 +420,16 @@
(operator new(atomsArraySize, std::nothrow));
if (atomsStart == nullptr)
return make_error_code(native_reader_error::memory_error);
- const size_t ivarElementSize = chunk->fileSize
+ const size_t ivarElementSize = chunk->fileSize
/ chunk->elementCount;
if ( ivarElementSize != sizeof(NativeSharedLibraryAtomIvarsV1) )
return make_error_code(native_reader_error::file_malformed);
uint8_t* atomsEnd = atomsStart + atomsArraySize;
- const NativeSharedLibraryAtomIvarsV1* ivarData =
+ const NativeSharedLibraryAtomIvarsV1* ivarData =
reinterpret_cast<const NativeSharedLibraryAtomIvarsV1*>
(base + chunk->fileOffset);
for(uint8_t* s = atomsStart; s != atomsEnd; s += atomSize) {
- NativeSharedLibraryAtomV1* atomAllocSpace =
+ NativeSharedLibraryAtomV1* atomAllocSpace =
reinterpret_cast<NativeSharedLibraryAtomV1*>(s);
new (atomAllocSpace) NativeSharedLibraryAtomV1(*this, ivarData);
++ivarData;
@@ -440,8 +440,8 @@
this->_sharedLibraryAtoms._elementCount = chunk->elementCount;
return make_error_code(native_reader_error::success);
}
-
-
+
+
// instantiate array of AbsoluteAtoms from v1 ivar data in file
error_code processAbsoluteAtomsV1(const uint8_t *base,
const NativeChunk *chunk) {
@@ -451,16 +451,16 @@
(operator new(atomsArraySize, std::nothrow));
if (atomsStart == nullptr)
return make_error_code(native_reader_error::memory_error);
- const size_t ivarElementSize = chunk->fileSize
+ const size_t ivarElementSize = chunk->fileSize
/ chunk->elementCount;
if ( ivarElementSize != sizeof(NativeAbsoluteAtomIvarsV1) )
return make_error_code(native_reader_error::file_malformed);
uint8_t* atomsEnd = atomsStart + atomsArraySize;
- const NativeAbsoluteAtomIvarsV1* ivarData =
+ const NativeAbsoluteAtomIvarsV1* ivarData =
reinterpret_cast<const NativeAbsoluteAtomIvarsV1*>
(base + chunk->fileOffset);
for(uint8_t* s = atomsStart; s != atomsEnd; s += atomSize) {
- NativeAbsoluteAtomV1* atomAllocSpace =
+ NativeAbsoluteAtomV1* atomAllocSpace =
reinterpret_cast<NativeAbsoluteAtomV1*>(s);
new (atomAllocSpace) NativeAbsoluteAtomV1(*this, ivarData);
++ivarData;
@@ -471,10 +471,10 @@
this->_absoluteAtoms._elementCount = chunk->elementCount;
return make_error_code(native_reader_error::success);
}
-
-
-
-
+
+
+
+
// instantiate array of Referemces from v1 ivar data in file
error_code processReferencesV1(const uint8_t *base,
const NativeChunk *chunk) {
@@ -491,11 +491,11 @@
if ( ivarElementSize != sizeof(NativeReferenceIvarsV1) )
return make_error_code(native_reader_error::file_malformed);
uint8_t* refsEnd = refsStart + refsArraySize;
- const NativeReferenceIvarsV1* ivarData =
+ const NativeReferenceIvarsV1* ivarData =
reinterpret_cast<const NativeReferenceIvarsV1*>
(base + chunk->fileOffset);
for(uint8_t* s = refsStart; s != refsEnd; s += refSize) {
- NativeReferenceV1* atomAllocSpace =
+ NativeReferenceV1* atomAllocSpace =
reinterpret_cast<NativeReferenceV1*>(s);
new (atomAllocSpace) NativeReferenceV1(*this, ivarData);
++ivarData;
@@ -506,7 +506,7 @@
this->_references.elementCount = chunk->elementCount;
return make_error_code(native_reader_error::success);
}
-
+
// set up pointers to target table
error_code processTargetsTable(const uint8_t *base,
const NativeChunk *chunk) {
@@ -517,31 +517,31 @@
for (uint32_t i=0; i < chunk->elementCount; ++i) {
const uint32_t index = targetIndexes[i];
if ( index < _definedAtoms._elementCount ) {
- const uint8_t* p = _definedAtoms._arrayStart
+ const uint8_t* p = _definedAtoms._arrayStart
+ index * _definedAtoms._elementSize;
this->_targetsTable[i] = reinterpret_cast<const DefinedAtom*>(p);
continue;
}
const uint32_t undefIndex = index - _definedAtoms._elementCount;
if ( undefIndex < _undefinedAtoms._elementCount ) {
- const uint8_t* p = _undefinedAtoms._arrayStart
+ const uint8_t* p = _undefinedAtoms._arrayStart
+ undefIndex * _undefinedAtoms._elementSize;
this->_targetsTable[i] = reinterpret_cast<const UndefinedAtom*>(p);
continue;
}
- const uint32_t slIndex = index - _definedAtoms._elementCount
+ const uint32_t slIndex = index - _definedAtoms._elementCount
- _undefinedAtoms._elementCount;
if ( slIndex < _sharedLibraryAtoms._elementCount ) {
- const uint8_t* p = _sharedLibraryAtoms._arrayStart
+ const uint8_t* p = _sharedLibraryAtoms._arrayStart
+ slIndex * _sharedLibraryAtoms._elementSize;
this->_targetsTable[i] = reinterpret_cast<const SharedLibraryAtom*>(p);
continue;
}
- const uint32_t abIndex = index - _definedAtoms._elementCount
+ const uint32_t abIndex = index - _definedAtoms._elementCount
- _undefinedAtoms._elementCount
- _sharedLibraryAtoms._elementCount;
if ( abIndex < _absoluteAtoms._elementCount ) {
- const uint8_t* p = _absoluteAtoms._arrayStart
+ const uint8_t* p = _absoluteAtoms._arrayStart
+ slIndex * _absoluteAtoms._elementSize;
this->_targetsTable[i] = reinterpret_cast<const AbsoluteAtom*>(p);
continue;
@@ -550,8 +550,8 @@
}
return make_error_code(native_reader_error::success);
}
-
-
+
+
// set up pointers to addend pool in file
error_code processAddendsTable(const uint8_t *base,
const NativeChunk *chunk) {
@@ -560,7 +560,7 @@
this->_addendsMaxIndex = chunk->elementCount;
return make_error_code(native_reader_error::success);
}
-
+
// set up pointers to string pool in file
error_code processStrings(const uint8_t *base,
const NativeChunk *chunk) {
@@ -568,7 +568,7 @@
this->_stringsMaxOffset = chunk->fileSize;
return make_error_code(native_reader_error::success);
}
-
+
// set up pointers to content area in file
error_code processContent(const uint8_t *base,
const NativeChunk *chunk) {
@@ -576,12 +576,12 @@
this->_contentEnd = base + chunk->fileOffset + chunk->fileSize;
return make_error_code(native_reader_error::success);
}
-
+
StringRef string(uint32_t offset) const {
assert(offset < _stringsMaxOffset);
return StringRef(&_strings[offset]);
}
-
+
Reference::Addend addend(uint32_t index) const {
if ( index == 0 )
return 0; // addend index zero is used to mean "no addend"
@@ -599,7 +599,7 @@
assert((result+size) <= _contentEnd);
return result;
}
-
+
const Reference* referenceByIndex(uintptr_t index) const {
assert(index < _references.elementCount);
const uint8_t* p = _references.arrayStart + index * _references.elementSize;
@@ -610,13 +610,13 @@
assert(index < _targetsTableCount);
return _targetsTable[index];
}
-
+
void setTarget(uint32_t index, const Atom* newAtom) const {
assert(index > _targetsTableCount);
_targetsTable[index] = newAtom;
}
-
-
+
+
// private constructor, only called by make()
NativeFile(std::unique_ptr<llvm::MemoryBuffer> mb, StringRef path) :
File(path),
@@ -640,11 +640,11 @@
public:
AtomArray() : _arrayStart(nullptr), _arrayEnd(nullptr),
_elementSize(0), _elementCount(0) { }
-
- virtual atom_iterator<T> begin() const {
+
+ virtual atom_iterator<T> begin() const {
return atom_iterator<T>(*this, reinterpret_cast<const void*>(_arrayStart));
}
- virtual atom_iterator<T> end() const{
+ virtual atom_iterator<T> end() const{
return atom_iterator<T>(*this, reinterpret_cast<const void*>(_arrayEnd));
}
virtual const T* deref(const void* it) const {
@@ -662,12 +662,12 @@
};
struct IvarArray {
- IvarArray() :
+ IvarArray() :
arrayStart(nullptr),
arrayEnd(nullptr),
- elementSize(0),
- elementCount(0) { }
-
+ elementSize(0),
+ elementCount(0) { }
+
const uint8_t* arrayStart;
const uint8_t* arrayEnd;
uint32_t elementSize;
@@ -730,7 +730,7 @@
const void* it = reinterpret_cast<const void*>(index);
return reference_iterator(*this, it);
}
-
+
DefinedAtom::reference_iterator NativeDefinedAtomV1::referencesEnd() const {
uintptr_t index = _ivarData->referencesStartIndex+_ivarData->referencesCount;
const void* it = reinterpret_cast<const void*>(index);
@@ -741,7 +741,7 @@
uintptr_t index = reinterpret_cast<uintptr_t>(it);
return _file->referenceByIndex(index);
}
-
+
void NativeDefinedAtomV1::incrementIterator(const void*& it) const {
uintptr_t index = reinterpret_cast<uintptr_t>(it);
++index;
@@ -826,6 +826,4 @@
, result);
}
-
-
} // namespace lld
Modified: lld/trunk/lib/Core/NativeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeWriter.cpp?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/NativeWriter.cpp (original)
+++ lld/trunk/lib/Core/NativeWriter.cpp Tue Apr 3 13:40:27 2012
@@ -26,33 +26,33 @@
class NativeWriter {
public:
/// construct writer for an lld::File object
- NativeWriter(const lld::File& file) : _file(file) {
+ NativeWriter(const lld::File& file) : _file(file) {
// reserve first byte for unnamed atoms
_stringPool.push_back('\0');
// visit all atoms
- for(File::defined_iterator it=file.definedAtomsBegin(),
- end=file.definedAtomsEnd();
+ for(File::defined_iterator it=file.definedAtomsBegin(),
+ end=file.definedAtomsEnd();
it != end; ++it) {
this->addIVarsForDefinedAtom(**it);
}
- for(File::undefined_iterator it=file.undefinedAtomsBegin(),
- end=file.undefinedAtomsEnd();
+ for(File::undefined_iterator it=file.undefinedAtomsBegin(),
+ end=file.undefinedAtomsEnd();
it != end; ++it) {
this->addIVarsForUndefinedAtom(**it);
}
- for(File::shared_library_iterator it=file.sharedLibraryAtomsBegin(),
- end=file.sharedLibraryAtomsEnd();
+ for(File::shared_library_iterator it=file.sharedLibraryAtomsBegin(),
+ end=file.sharedLibraryAtomsEnd();
it != end; ++it) {
this->addIVarsForSharedLibraryAtom(**it);
}
- for(File::absolute_iterator it=file.absoluteAtomsBegin(),
- end=file.absoluteAtomsEnd();
+ for(File::absolute_iterator it=file.absoluteAtomsBegin(),
+ end=file.absoluteAtomsEnd();
it != end; ++it) {
this->addIVarsForAbsoluteAtom(**it);
}
-
-
+
+
// construct file header based on atom information accumulated
makeHeader();
}
@@ -61,60 +61,60 @@
void write(raw_ostream &out) {
assert( out.tell() == 0 );
out.write((char*)_headerBuffer, _headerBufferSize);
-
+
if (!_definedAtomIvars.empty()) {
assert( out.tell() == findChunk(NCS_DefinedAtomsV1).fileOffset );
out.write((char*)&_definedAtomIvars[0],
_definedAtomIvars.size()*sizeof(NativeDefinedAtomIvarsV1));
}
-
+
if (!_attributes.empty()) {
assert( out.tell() == findChunk(NCS_AttributesArrayV1).fileOffset );
out.write((char*)&_attributes[0],
_attributes.size()*sizeof(NativeAtomAttributesV1));
}
-
+
if ( !_undefinedAtomIvars.empty() ) {
assert( out.tell() == findChunk(NCS_UndefinedAtomsV1).fileOffset );
- out.write((char*)&_undefinedAtomIvars[0],
+ out.write((char*)&_undefinedAtomIvars[0],
_undefinedAtomIvars.size()*sizeof(NativeUndefinedAtomIvarsV1));
}
-
+
if ( !_sharedLibraryAtomIvars.empty() ) {
assert( out.tell() == findChunk(NCS_SharedLibraryAtomsV1).fileOffset );
- out.write((char*)&_sharedLibraryAtomIvars[0],
- _sharedLibraryAtomIvars.size()
+ out.write((char*)&_sharedLibraryAtomIvars[0],
+ _sharedLibraryAtomIvars.size()
* sizeof(NativeSharedLibraryAtomIvarsV1));
}
-
+
if ( !_absoluteAtomIvars.empty() ) {
assert( out.tell() == findChunk(NCS_AbsoluteAtomsV1).fileOffset );
- out.write((char*)&_absoluteAtomIvars[0],
- _absoluteAtomIvars.size()
+ out.write((char*)&_absoluteAtomIvars[0],
+ _absoluteAtomIvars.size()
* sizeof(NativeAbsoluteAtomIvarsV1));
}
-
+
if (!_stringPool.empty()) {
assert( out.tell() == findChunk(NCS_Strings).fileOffset );
out.write(&_stringPool[0], _stringPool.size());
}
-
+
if ( !_references.empty() ) {
assert( out.tell() == findChunk(NCS_ReferencesArrayV1).fileOffset );
- out.write((char*)&_references[0],
+ out.write((char*)&_references[0],
_references.size()*sizeof(NativeReferenceIvarsV1));
}
-
+
if ( !_targetsTableIndex.empty() ) {
assert( out.tell() == findChunk(NCS_TargetsTable).fileOffset );
writeTargetTable(out);
}
-
+
if ( !_addendsTableIndex.empty() ) {
assert( out.tell() == findChunk(NCS_AddendsTable).fileOffset );
writeAddendTable(out);
}
-
+
if (!_contentPool.empty()) {
assert( out.tell() == findChunk(NCS_Content).fileOffset );
out.write((char*)&_contentPool[0], _contentPool.size());
@@ -135,7 +135,7 @@
ivar.contentSize = atom.size();
_definedAtomIvars.push_back(ivar);
}
-
+
void addIVarsForUndefinedAtom(const UndefinedAtom& atom) {
_undefinedAtomIndex[&atom] = _undefinedAtomIvars.size();
NativeUndefinedAtomIvarsV1 ivar;
@@ -143,7 +143,7 @@
ivar.flags = (atom.canBeNull() & 0x03);
_undefinedAtomIvars.push_back(ivar);
}
-
+
void addIVarsForSharedLibraryAtom(const SharedLibraryAtom& atom) {
_sharedLibraryAtomIndex[&atom] = _sharedLibraryAtomIvars.size();
NativeSharedLibraryAtomIvarsV1 ivar;
@@ -152,7 +152,7 @@
ivar.flags = atom.canBeNullAtRuntime();
_sharedLibraryAtomIvars.push_back(ivar);
}
-
+
void addIVarsForAbsoluteAtom(const AbsoluteAtom& atom) {
_absoluteAtomIndex[&atom] = _absoluteAtomIvars.size();
NativeAbsoluteAtomIvarsV1 ivar;
@@ -183,7 +183,7 @@
if ( hasAddendTable ) ++chunkCount;
if ( hasContent ) ++chunkCount;
- _headerBufferSize = sizeof(NativeFileHeader)
+ _headerBufferSize = sizeof(NativeFileHeader)
+ chunkCount*sizeof(NativeChunk);
_headerBuffer = reinterpret_cast<NativeFileHeader*>
(operator new(_headerBufferSize, std::nothrow));
@@ -195,7 +195,7 @@
_headerBuffer->architecture = 0;
_headerBuffer->fileSize = 0;
_headerBuffer->chunkCount = chunkCount;
-
+
// create chunk for defined atom ivar array
int nextIndex = 0;
uint32_t nextFileOffset = _headerBufferSize;
@@ -207,7 +207,7 @@
chd.elementCount = _definedAtomIvars.size();
nextFileOffset = chd.fileOffset + chd.fileSize;
- // create chunk for attributes
+ // create chunk for attributes
NativeChunk& cha = chunks[nextIndex++];
cha.signature = NCS_AttributesArrayV1;
cha.fileOffset = nextFileOffset;
@@ -215,42 +215,42 @@
cha.elementCount = _attributes.size();
nextFileOffset = cha.fileOffset + cha.fileSize;
}
-
+
// create chunk for undefined atom array
if ( hasUndefines ) {
NativeChunk& chu = chunks[nextIndex++];
chu.signature = NCS_UndefinedAtomsV1;
chu.fileOffset = nextFileOffset;
- chu.fileSize = _undefinedAtomIvars.size() *
+ chu.fileSize = _undefinedAtomIvars.size() *
sizeof(NativeUndefinedAtomIvarsV1);
chu.elementCount = _undefinedAtomIvars.size();
nextFileOffset = chu.fileOffset + chu.fileSize;
}
-
+
// create chunk for shared library atom array
if ( hasSharedLibraries ) {
NativeChunk& chsl = chunks[nextIndex++];
chsl.signature = NCS_SharedLibraryAtomsV1;
chsl.fileOffset = nextFileOffset;
- chsl.fileSize = _sharedLibraryAtomIvars.size() *
+ chsl.fileSize = _sharedLibraryAtomIvars.size() *
sizeof(NativeSharedLibraryAtomIvarsV1);
chsl.elementCount = _sharedLibraryAtomIvars.size();
nextFileOffset = chsl.fileOffset + chsl.fileSize;
}
-
+
// create chunk for shared library atom array
if ( hasAbsolutes ) {
NativeChunk& chsl = chunks[nextIndex++];
chsl.signature = NCS_AbsoluteAtomsV1;
chsl.fileOffset = nextFileOffset;
- chsl.fileSize = _absoluteAtomIvars.size() *
+ chsl.fileSize = _absoluteAtomIvars.size() *
sizeof(NativeAbsoluteAtomIvarsV1);
chsl.elementCount = _absoluteAtomIvars.size();
nextFileOffset = chsl.fileOffset + chsl.fileSize;
}
-
+
// create chunk for symbol strings
- // pad end of string pool to 4-bytes
+ // pad end of string pool to 4-bytes
while ( (_stringPool.size() % 4) != 0 )
_stringPool.push_back('\0');
NativeChunk& chs = chunks[nextIndex++];
@@ -259,8 +259,8 @@
chs.fileSize = _stringPool.size();
chs.elementCount = _stringPool.size();
nextFileOffset = chs.fileOffset + chs.fileSize;
-
- // create chunk for references
+
+ // create chunk for references
if ( hasReferences ) {
NativeChunk& chr = chunks[nextIndex++];
chr.signature = NCS_ReferencesArrayV1;
@@ -269,8 +269,8 @@
chr.elementCount = _references.size();
nextFileOffset = chr.fileOffset + chr.fileSize;
}
-
- // create chunk for target table
+
+ // create chunk for target table
if ( hasTargetsTable ) {
NativeChunk& cht = chunks[nextIndex++];
cht.signature = NCS_TargetsTable;
@@ -280,7 +280,7 @@
nextFileOffset = cht.fileOffset + cht.fileSize;
}
- // create chunk for addend table
+ // create chunk for addend table
if ( hasAddendTable ) {
NativeChunk& chad = chunks[nextIndex++];
chad.signature = NCS_AddendsTable;
@@ -289,8 +289,8 @@
chad.elementCount = _addendsTableIndex.size();
nextFileOffset = chad.fileOffset + chad.fileSize;
}
-
- // create chunk for content
+
+ // create chunk for content
if ( hasContent ) {
NativeChunk& chc = chunks[nextIndex++];
chc.signature = NCS_Content;
@@ -299,7 +299,7 @@
chc.elementCount = _contentPool.size();
nextFileOffset = chc.fileOffset + chc.fileSize;
}
-
+
_headerBuffer->fileSize = nextFileOffset;
}
@@ -321,12 +321,12 @@
uint32_t getNameOffset(const Atom& atom) {
return this->getNameOffset(atom.name());
}
-
+
// check if name is already in pool or append and return offset
uint32_t getSharedLibraryNameOffset(StringRef name) {
assert( ! name.empty() );
// look to see if this library name was used by another atom
- for(NameToOffsetVector::iterator it = _sharedLibraryNames.begin();
+ for(NameToOffsetVector::iterator it = _sharedLibraryNames.begin();
it != _sharedLibraryNames.end(); ++it) {
if ( name.equals(it->first) )
return it->second;
@@ -336,7 +336,7 @@
_sharedLibraryNames.push_back(std::make_pair(name, result));
return result;
}
-
+
// append atom name to string pool and return offset
uint32_t getNameOffset(StringRef name) {
if ( name.empty() )
@@ -349,7 +349,7 @@
// append atom cotent to content pool and return offset
uint32_t getContentOffset(const class DefinedAtom& atom) {
- if ( atom.contentType() == DefinedAtom::typeZeroFill )
+ if ( atom.contentType() == DefinedAtom::typeZeroFill )
return 0;
uint32_t result = _contentPool.size();
ArrayRef<uint8_t> cont = atom.rawContent();
@@ -372,7 +372,7 @@
_attributes.push_back(attrs);
return result;
}
-
+
uint32_t sectionNameOffset(const class DefinedAtom& atom) {
// if section based on content, then no custom section name available
if ( atom.sectionChoice() == DefinedAtom::sectionBasedOnContent )
@@ -380,7 +380,7 @@
StringRef name = atom.customSectionName();
assert( ! name.empty() );
// look to see if this section name was used by another atom
- for(NameToOffsetVector::iterator it=_sectionNames.begin();
+ for(NameToOffsetVector::iterator it=_sectionNames.begin();
it != _sectionNames.end(); ++it) {
if ( name.equals(it->first) )
return it->second;
@@ -390,21 +390,21 @@
_sectionNames.push_back(std::make_pair(name, result));
return result;
}
-
- void computeAttributesV1(const class DefinedAtom& atom,
+
+ void computeAttributesV1(const class DefinedAtom& atom,
NativeAtomAttributesV1& attrs) {
attrs.sectionNameOffset = sectionNameOffset(atom);
attrs.align2 = atom.alignment().powerOf2;
attrs.alignModulus = atom.alignment().modulus;
- attrs.scope = atom.scope();
- attrs.interposable = atom.interposable();
- attrs.merge = atom.merge();
- attrs.contentType = atom.contentType();
- attrs.sectionChoice = atom.sectionChoice();
- attrs.deadStrip = atom.deadStrip();
- attrs.permissions = atom.permissions();
- //attrs.thumb = atom.isThumb();
- attrs.alias = atom.isAlias();
+ attrs.scope = atom.scope();
+ attrs.interposable = atom.interposable();
+ attrs.merge = atom.merge();
+ attrs.contentType = atom.contentType();
+ attrs.sectionChoice = atom.sectionChoice();
+ attrs.deadStrip = atom.deadStrip();
+ attrs.permissions = atom.permissions();
+ //attrs.thumb = atom.isThumb();
+ attrs.alias = atom.isAlias();
}
// add references for this atom in a contiguous block in NCS_ReferencesArrayV1
@@ -428,7 +428,7 @@
else
return result;
}
-
+
uint32_t getTargetIndex(const Atom* target) {
TargetToIndex::const_iterator pos = _targetsTableIndex.find(target);
if ( pos != _targetsTableIndex.end() ) {
@@ -438,13 +438,13 @@
_targetsTableIndex[target] = result;
return result;
}
-
- void writeTargetTable(llvm::raw_ostream& out) {
- // Build table of target indexes
+
+ void writeTargetTable(raw_ostream &out) {
+ // Build table of target indexes
uint32_t maxTargetIndex = _targetsTableIndex.size();
assert(maxTargetIndex > 0);
std::vector<uint32_t> targetIndexes(maxTargetIndex);
- for (TargetToIndex::iterator it = _targetsTableIndex.begin();
+ for (TargetToIndex::iterator it = _targetsTableIndex.begin();
it != _targetsTableIndex.end(); ++it) {
const Atom* atom = it->first;
uint32_t targetIndex = it->second;
@@ -463,15 +463,15 @@
pos = _sharedLibraryAtomIndex.find(atom);
if ( pos != _sharedLibraryAtomIndex.end() ) {
assert(pos != _sharedLibraryAtomIndex.end());
- atomIndex = pos->second
- + _definedAtomIvars.size()
+ atomIndex = pos->second
+ + _definedAtomIvars.size()
+ _undefinedAtomIndex.size();
}
else {
pos = _absoluteAtomIndex.find(atom);
assert(pos != _absoluteAtomIndex.end());
- atomIndex = pos->second
- + _definedAtomIvars.size()
+ atomIndex = pos->second
+ + _definedAtomIvars.size()
+ _undefinedAtomIndex.size()
+ _sharedLibraryAtomIndex.size();
}
@@ -482,8 +482,8 @@
// write table
out.write((char*)&targetIndexes[0], maxTargetIndex*sizeof(uint32_t));
}
-
- uint32_t getAddendIndex(Reference::Addend addend) {
+
+ uint32_t getAddendIndex(Reference::Addend addend) {
if ( addend == 0 )
return 0; // addend index zero is used to mean "no addend"
AddendToIndex::const_iterator pos = _addendsTableIndex.find(addend);
@@ -494,12 +494,12 @@
_addendsTableIndex[addend] = result;
return result;
}
-
- // Build table of addends
+
void writeAddendTable(raw_ostream &out) {
+ // Build table of addends
uint32_t maxAddendIndex = _addendsTableIndex.size();
std::vector<Reference::Addend> addends(maxAddendIndex);
- for (AddendToIndex::iterator it = _addendsTableIndex.begin();
+ for (AddendToIndex::iterator it = _addendsTableIndex.begin();
it != _addendsTableIndex.end(); ++it) {
Reference::Addend addend = it->first;
uint32_t index = it->second;
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Tue Apr 3 13:40:27 2012
@@ -24,11 +24,11 @@
namespace lld {
-/// This is used as a filter function to std::remove_if to dead strip atoms.
+/// This is used as a filter function to std::remove_if to dead strip atoms.
class NotLive {
public:
NotLive(const llvm::DenseSet<const Atom*>& la) : _liveAtoms(la) { }
-
+
bool operator()(const Atom *atom) const {
// don't remove if live
if ( _liveAtoms.count(atom) )
@@ -41,13 +41,13 @@
// do remove this atom
return true;
}
-
+
private:
const llvm::DenseSet<const Atom*> _liveAtoms;
};
-/// This is used as a filter function to std::remove_if to coalesced atoms.
+/// This is used as a filter function to std::remove_if to coalesced atoms.
class AtomCoalescedAway {
public:
AtomCoalescedAway(SymbolTable &sym) : _symbolTable(sym) {}
@@ -93,7 +93,7 @@
void Resolver::doUndefinedAtom(const class UndefinedAtom& atom) {
// add to list of known atoms
_atoms.push_back(&atom);
-
+
// tell symbol table
_symbolTable.add(atom);
}
@@ -106,7 +106,7 @@
// add to list of known atoms
_atoms.push_back(&atom);
-
+
// adjust scope (e.g. force some globals to be hidden)
_platform.adjustScope(atom);
@@ -137,21 +137,21 @@
void Resolver::doSharedLibraryAtom(const SharedLibraryAtom& atom) {
// add to list of known atoms
_atoms.push_back(&atom);
-
+
// tell symbol table
_symbolTable.add(atom);
}
-
+
void Resolver::doAbsoluteAtom(const AbsoluteAtom& atom) {
// add to list of known atoms
_atoms.push_back(&atom);
-
+
// tell symbol table
_symbolTable.add(atom);
}
-
+
// utility to add a vector of atoms
void Resolver::addAtoms(const std::vector<const DefinedAtom*>& newAtoms) {
for (std::vector<const DefinedAtom *>::const_iterator it = newAtoms.begin();
@@ -209,7 +209,7 @@
assert(curAtom != nullptr);
if (const DefinedAtom* curDefAtom = dyn_cast<DefinedAtom>(curAtom)) {
if (curDefAtom->merge() == DefinedAtom::mergeAsTentative )
- _inputFiles.searchLibraries(tentName, searchDylibs,
+ _inputFiles.searchLibraries(tentName, searchDylibs,
true, true, *this);
}
}
@@ -346,7 +346,7 @@
const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(*it);
if (defAtom == nullptr)
continue;
- if ( defAtom->merge() != DefinedAtom::mergeAsTentative )
+ if ( defAtom->merge() != DefinedAtom::mergeAsTentative )
continue;
assert(defAtom->scope() != DefinedAtom::scopeTranslationUnit);
// See if any shared library also has symbol which
Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Tue Apr 3 13:40:27 2012
@@ -41,7 +41,7 @@
void SymbolTable::add(const SharedLibraryAtom &atom) {
this->addByName(atom);
}
-
+
void SymbolTable::add(const AbsoluteAtom &atom) {
this->addByName(atom);
}
@@ -118,7 +118,7 @@
}
};
-static MergeResolution mergeSelect(DefinedAtom::Merge first,
+static MergeResolution mergeSelect(DefinedAtom::Merge first,
DefinedAtom::Merge second) {
return mergeCases[first][second];
}
@@ -130,7 +130,7 @@
if (existing == nullptr) {
// Name is not in symbol table yet, add it associate with this atom.
_nameTable[name] = &newAtom;
- }
+ }
else {
// Name is already in symbol table and associated with another atom.
bool useNew = true;
@@ -144,7 +144,7 @@
case NCR_DupDef:
assert(existing->definition() == Atom::definitionRegular);
assert(newAtom.definition() == Atom::definitionRegular);
- switch ( mergeSelect(((DefinedAtom*)existing)->merge(),
+ switch ( mergeSelect(((DefinedAtom*)existing)->merge(),
((DefinedAtom*)(&newAtom))->merge()) ) {
case MCR_First:
useNew = false;
@@ -173,7 +173,7 @@
else {
useNew = (newUndef->canBeNull() < existingUndef->canBeNull());
// give platform a change to override which to use
- _platform.undefineCanBeNullMismatch(*existingUndef,
+ _platform.undefineCanBeNullMismatch(*existingUndef,
*newUndef, useNew);
}
}
@@ -185,7 +185,7 @@
dyn_cast<SharedLibraryAtom>(&newAtom);
assert(existingShLib != nullptr);
assert(newShLib != nullptr);
- if ( (existingShLib->canBeNullAtRuntime()
+ if ( (existingShLib->canBeNullAtRuntime()
== newShLib->canBeNullAtRuntime()) &&
existingShLib->loadName().equals(newShLib->loadName()) ) {
useNew = false;
@@ -229,7 +229,7 @@
}
-bool SymbolTable::AtomMappingInfo::isEqual(const DefinedAtom * const l,
+bool SymbolTable::AtomMappingInfo::isEqual(const DefinedAtom * const l,
const DefinedAtom * const r) {
if ( l == r )
return true;
Modified: lld/trunk/lib/Core/YamlKeyValues.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlKeyValues.cpp?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/YamlKeyValues.cpp (original)
+++ lld/trunk/lib/Core/YamlKeyValues.cpp Tue Apr 3 13:40:27 2012
@@ -104,7 +104,7 @@
{ "static", DefinedAtom::scopeTranslationUnit },
{ nullptr, DefinedAtom::scopeGlobal }
};
-
+
DefinedAtom::Scope KeyValues::scope(const char* s)
{
for (const ScopeMapping* p = scopeMappings; p->string != nullptr; ++p) {
Modified: lld/trunk/lib/Core/YamlKeyValues.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlKeyValues.h?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/YamlKeyValues.h (original)
+++ lld/trunk/lib/Core/YamlKeyValues.h Tue Apr 3 13:40:27 2012
@@ -28,7 +28,7 @@
static const char* const loadNameKeyword;
static const char* const valueKeyword;
static const char* const fixupsKeyword;
-
+
static const char* const definitionKeyword;
static const Atom::Definition definitionDefault;
static Atom::Definition definition(const char*);
@@ -38,7 +38,7 @@
static const DefinedAtom::Scope scopeDefault;
static DefinedAtom::Scope scope(const char*);
static const char* scope(DefinedAtom::Scope);
-
+
static const char* const contentTypeKeyword;
static const DefinedAtom::ContentType contentTypeDefault;
static DefinedAtom::ContentType contentType(const char*);
Modified: lld/trunk/lib/Core/YamlReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlReader.cpp?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/YamlReader.cpp (original)
+++ lld/trunk/lib/Core/YamlReader.cpp Tue Apr 3 13:40:27 2012
@@ -41,7 +41,7 @@
class YAML {
public:
struct Entry {
- Entry(const char *k, const char *v, std::vector<uint8_t>* vs,
+ Entry(const char *k, const char *v, std::vector<uint8_t>* vs,
int d, bool bd, bool bs)
: key(strdup(k))
, value(v ? strdup(v) : nullptr)
@@ -216,7 +216,7 @@
}
else {
*p++ = c;
- }
+ }
break;
case inValueSequence:
if (c == ']') {
@@ -231,7 +231,7 @@
}
else if ( isdigit(c) ) {
contentByte = (contentByte << 4) | (c-'0');
- }
+ }
else if ( ('a' <= tolower(c)) && (tolower(c) <= 'f') ) {
contentByte = (contentByte << 4) | (tolower(c)-'a'+10);
}
@@ -257,18 +257,18 @@
class YAMLReference : public Reference {
-public:
+public:
YAMLReference() : _target(nullptr), _targetName(nullptr),
_offsetInAtom(0), _addend(0), _kind(0) { }
virtual uint64_t offsetInAtom() const {
return _offsetInAtom;
}
-
+
virtual Kind kind() const {
return _kind;
}
-
+
virtual void setKind(Kind k) {
_kind = k;
}
@@ -276,7 +276,7 @@
virtual const Atom* target() const {
return _target;
}
-
+
virtual Addend addend() const {
return _addend;
}
@@ -318,14 +318,14 @@
virtual void addAtom(const Atom&) {
assert(0 && "cannot add atoms to YAML files");
}
-
+
void bindTargetReferences();
void addDefinedAtom(YAMLDefinedAtom* atom, const char* refName);
void addUndefinedAtom(UndefinedAtom* atom);
void addSharedLibraryAtom(SharedLibraryAtom* atom);
void addAbsoluteAtom(AbsoluteAtom* atom);
Atom* findAtom(const char* name);
-
+
struct NameAtomPair {
NameAtomPair(const char* n, Atom* a) : name(n), atom(a) {}
const char* name;
@@ -400,11 +400,11 @@
virtual DefinedAtom::Scope scope() const {
return _scope;
}
-
+
virtual DefinedAtom::Interposable interposable() const {
return _interpose;
}
-
+
virtual DefinedAtom::Merge merge() const {
return _merge;
}
@@ -412,11 +412,11 @@
virtual DefinedAtom::ContentType contentType() const {
return _type;
}
-
+
virtual DefinedAtom::Alignment alignment() const {
return _alignment;
}
-
+
virtual DefinedAtom::SectionChoice sectionChoice() const {
return _sectionChoice;
}
@@ -424,30 +424,30 @@
virtual StringRef customSectionName() const {
return _sectionName;
}
-
+
virtual DefinedAtom::DeadStripKind deadStrip() const {
return _deadStrip;
}
-
+
virtual DefinedAtom::ContentPermissions permissions() const {
return _permissions;
}
-
+
virtual bool isThumb() const {
return _isThumb;
}
-
+
virtual bool isAlias() const {
return _isAlias;
}
-
+
ArrayRef<uint8_t> rawContent() const {
if (_content != nullptr)
return ArrayRef<uint8_t>(*_content);
else
return ArrayRef<uint8_t>();
}
-
+
virtual uint64_t ordinal() const {
return _ord;
}
@@ -457,7 +457,7 @@
const void* it = reinterpret_cast<const void*>(index);
return reference_iterator(*this, it);
}
-
+
DefinedAtom::reference_iterator referencesEnd() const {
uintptr_t index = _refEndIndex;
const void* it = reinterpret_cast<const void*>(index);
@@ -471,15 +471,15 @@
assert(index < _file._references.size());
return &_file._references[index];
}
-
+
void incrementIterator(const void*& it) const {
uintptr_t index = reinterpret_cast<uintptr_t>(it);
++index;
it = reinterpret_cast<const void*>(index);
}
-
-
+
+
void bindTargetReferences() const {
for (unsigned int i=_refStartIndex; i < _refEndIndex; ++i) {
const char* targetName = _file._references[i]._targetName;
@@ -487,7 +487,7 @@
_file._references[i]._target = targetAtom;
}
}
-
+
private:
YAMLFile& _file;
const char * _name;
@@ -512,7 +512,7 @@
class YAMLUndefinedAtom : public UndefinedAtom {
public:
- YAMLUndefinedAtom(YAMLFile& f, int32_t ord, const char* nm,
+ YAMLUndefinedAtom(YAMLFile& f, int32_t ord, const char* nm,
UndefinedAtom::CanBeNull cbn)
: _file(f), _name(nm), _ordinal(ord), _canBeNull(cbn) { }
@@ -527,8 +527,8 @@
virtual CanBeNull canBeNull() const {
return _canBeNull;
}
-
-
+
+
private:
YAMLFile& _file;
const char * _name;
@@ -540,9 +540,9 @@
class YAMLSharedLibraryAtom : public SharedLibraryAtom {
public:
- YAMLSharedLibraryAtom(YAMLFile& f, int32_t ord, const char* nm,
+ YAMLSharedLibraryAtom(YAMLFile& f, int32_t ord, const char* nm,
const char* ldnm, bool cbn)
- : _file(f), _name(nm), _ordinal(ord),
+ : _file(f), _name(nm), _ordinal(ord),
_loadName(ldnm), _canBeNull(cbn) { }
virtual const class File& file() const {
@@ -560,8 +560,8 @@
virtual bool canBeNullAtRuntime() const {
return _canBeNull;
}
-
-
+
+
private:
YAMLFile& _file;
const char * _name;
@@ -600,7 +600,7 @@
void YAMLFile::bindTargetReferences() {
for (defined_iterator it = definedAtomsBegin(); it != definedAtomsEnd(); ++it) {
- const YAMLDefinedAtom* atom = reinterpret_cast<const YAMLDefinedAtom*>(*it);
+ const YAMLDefinedAtom* atom = reinterpret_cast<const YAMLDefinedAtom*>(*it);
atom->bindTargetReferences();
}
}
@@ -639,7 +639,7 @@
class YAMLAtomState {
public:
YAMLAtomState(Platform& platform);
-
+
void setName(const char *n);
void setRefName(const char *n);
void setAlign2(const char *n);
@@ -695,7 +695,7 @@
, _deadStrip(KeyValues::deadStripKindDefault)
, _permissions(KeyValues::permissionsDefault)
, _isThumb(KeyValues::isThumbDefault)
- , _isAlias(KeyValues::isAliasDefault)
+ , _isAlias(KeyValues::isAliasDefault)
, _canBeNull(KeyValues::canBeNullDefault)
{
}
@@ -705,7 +705,7 @@
if ( _definition == Atom::definitionRegular ) {
YAMLDefinedAtom *a = new YAMLDefinedAtom(_ordinal, f, _scope, _type,
_sectionChoice, _interpose, _merge, _deadStrip,
- _permissions, _isThumb, _isAlias,
+ _permissions, _isThumb, _isAlias,
_alignment, _name, _sectionName, _size, _content);
f.addDefinedAtom(a, _refName ? _refName : _name);
++_ordinal;
@@ -717,7 +717,7 @@
}
else if ( _definition == Atom::definitionSharedLibrary ) {
bool nullable = (_canBeNull == UndefinedAtom::canBeNullAtRuntime);
- SharedLibraryAtom *a = new YAMLSharedLibraryAtom(f, _ordinal, _name,
+ SharedLibraryAtom *a = new YAMLSharedLibraryAtom(f, _ordinal, _name,
_loadName, nullable);
f.addSharedLibraryAtom(a);
++_ordinal;
@@ -727,7 +727,7 @@
f.addAbsoluteAtom(a);
++_ordinal;
}
-
+
// reset state for next atom
_name = nullptr;
_refName = nullptr;
@@ -859,15 +859,15 @@
if (strcmp(entry->key, KeyValues::nameKeyword) == 0) {
atomState.setName(entry->value);
haveAtom = true;
- }
+ }
else if (strcmp(entry->key, KeyValues::refNameKeyword) == 0) {
atomState.setRefName(entry->value);
haveAtom = true;
- }
+ }
else if (strcmp(entry->key, KeyValues::definitionKeyword) == 0) {
atomState._definition = KeyValues::definition(entry->value);
haveAtom = true;
- }
+ }
else if (strcmp(entry->key, KeyValues::scopeKeyword) == 0) {
atomState._scope = KeyValues::scope(entry->value);
haveAtom = true;
@@ -911,21 +911,21 @@
else if (strcmp(entry->key, KeyValues::sectionNameKeyword) == 0) {
atomState._sectionName = entry->value;
haveAtom = true;
- }
+ }
else if (strcmp(entry->key, KeyValues::sizeKeyword) == 0) {
StringRef val = entry->value;
if (val.getAsInteger(0, atomState._size))
return make_error_code(yaml_reader_error::illegal_value);
haveAtom = true;
- }
+ }
else if (strcmp(entry->key, KeyValues::contentKeyword) == 0) {
atomState._content = entry->valueSequenceBytes;
haveAtom = true;
- }
+ }
else if (strcmp(entry->key, "align2") == 0) {
atomState.setAlign2(entry->value);
haveAtom = true;
- }
+ }
else if (strcmp(entry->key, KeyValues::fixupsKeyword) == 0) {
inFixups = true;
}
@@ -942,7 +942,7 @@
else {
return make_error_code(yaml_reader_error::unknown_keyword);
}
- }
+ }
else if (depthForFixups == entry->depth) {
if (entry->beginSequence) {
if (haveFixup) {
@@ -953,13 +953,13 @@
if (strcmp(entry->key, KeyValues::fixupsKindKeyword) == 0) {
atomState.setFixupKind(entry->value);
haveFixup = true;
- }
+ }
else if (strcmp(entry->key, KeyValues::fixupsOffsetKeyword) == 0) {
if (StringRef(entry->value).getAsInteger(0,
atomState._ref._offsetInAtom))
return make_error_code(yaml_reader_error::illegal_value);
haveFixup = true;
- }
+ }
else if (strcmp(entry->key, KeyValues::fixupsTargetKeyword) == 0) {
atomState.setFixupTarget(entry->value);
haveFixup = true;
Modified: lld/trunk/lib/Core/YamlWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlWriter.cpp?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Core/YamlWriter.cpp (original)
+++ lld/trunk/lib/Core/YamlWriter.cpp Tue Apr 3 13:40:27 2012
@@ -33,7 +33,7 @@
namespace {
///
/// In most cases, atoms names are unambiguous, so references can just
-/// use the atom name as the target (e.g. target: foo). But in a few
+/// use the atom name as the target (e.g. target: foo). But in a few
/// cases that does not work, so ref-names are added. These are labels
/// used only in yaml. The labels do not exist in the Atom model.
///
@@ -45,17 +45,17 @@
///
class RefNameBuilder {
public:
- RefNameBuilder(const File& file)
- : _collisionCount(0), _unnamedCounter(0) {
+ RefNameBuilder(const File& file)
+ : _collisionCount(0), _unnamedCounter(0) {
// visit all atoms
- for(File::defined_iterator it=file.definedAtomsBegin(),
- end=file.definedAtomsEnd();
+ for(File::defined_iterator it=file.definedAtomsBegin(),
+ end=file.definedAtomsEnd();
it != end; ++it) {
- const DefinedAtom* atom = *it;
+ const DefinedAtom* atom = *it;
// Build map of atoms names to detect duplicates
if ( ! atom->name().empty() )
buildDuplicateNameMap(*atom);
-
+
// Find references to unnamed atoms and create ref-names for them.
for (auto rit=atom->referencesBegin(), rend=atom->referencesEnd();
rit != rend; ++rit) {
@@ -69,25 +69,25 @@
}
}
}
- for(File::undefined_iterator it=file.undefinedAtomsBegin(),
- end=file.undefinedAtomsEnd();
+ for(File::undefined_iterator it=file.undefinedAtomsBegin(),
+ end=file.undefinedAtomsEnd();
it != end; ++it) {
buildDuplicateNameMap(**it);
}
- for(File::shared_library_iterator it=file.sharedLibraryAtomsBegin(),
- end=file.sharedLibraryAtomsEnd();
+ for(File::shared_library_iterator it=file.sharedLibraryAtomsBegin(),
+ end=file.sharedLibraryAtomsEnd();
it != end; ++it) {
buildDuplicateNameMap(**it);
}
- for(File::absolute_iterator it=file.absoluteAtomsBegin(),
- end=file.absoluteAtomsEnd();
+ for(File::absolute_iterator it=file.absoluteAtomsBegin(),
+ end=file.absoluteAtomsEnd();
it != end; ++it) {
buildDuplicateNameMap(**it);
}
-
+
}
-
+
void buildDuplicateNameMap(const Atom& atom) {
assert(!atom.name().empty());
NameToAtom::iterator pos = _nameMap.find(atom.name());
@@ -110,19 +110,19 @@
_nameMap[atom.name()] = &atom;
}
}
-
+
bool hasRefName(const Atom* atom) {
return _refNames.count(atom);
}
-
+
StringRef refName(const Atom *atom) {
return _refNames.find(atom)->second;
}
-
+
private:
typedef llvm::StringMap<const Atom*> NameToAtom;
typedef llvm::DenseMap<const Atom*, std::string> AtomToRefName;
-
+
unsigned int _collisionCount;
unsigned int _unnamedCounter;
NameToAtom _nameMap;
@@ -135,40 +135,40 @@
///
class AtomWriter {
public:
- AtomWriter(const File& file, Platform& platform, RefNameBuilder& rnb)
+ AtomWriter(const File& file, Platform& platform, RefNameBuilder& rnb)
: _file(file), _platform(platform), _rnb(rnb), _firstAtom(true) { }
void write(raw_ostream &out) {
- // write header
+ // write header
out << "---\n";
-
+
// visit all atoms
- for(File::defined_iterator it=_file.definedAtomsBegin(),
- end=_file.definedAtomsEnd();
+ for(File::defined_iterator it=_file.definedAtomsBegin(),
+ end=_file.definedAtomsEnd();
it != end; ++it) {
writeDefinedAtom(**it, out);
}
- for(File::undefined_iterator it=_file.undefinedAtomsBegin(),
- end=_file.undefinedAtomsEnd();
+ for(File::undefined_iterator it=_file.undefinedAtomsBegin(),
+ end=_file.undefinedAtomsEnd();
it != end; ++it) {
writeUndefinedAtom(**it, out);
}
- for(File::shared_library_iterator it=_file.sharedLibraryAtomsBegin(),
- end=_file.sharedLibraryAtomsEnd();
+ for(File::shared_library_iterator it=_file.sharedLibraryAtomsBegin(),
+ end=_file.sharedLibraryAtomsEnd();
it != end; ++it) {
writeSharedLibraryAtom(**it, out);
}
- for(File::absolute_iterator it=_file.absoluteAtomsBegin(),
- end=_file.absoluteAtomsEnd();
+ for(File::absolute_iterator it=_file.absoluteAtomsBegin(),
+ end=_file.absoluteAtomsEnd();
it != end; ++it) {
writeAbsoluteAtom(**it, out);
}
-
+
out << "...\n";
}
-
+
void writeDefinedAtom(const DefinedAtom &atom, raw_ostream &out) {
if ( _firstAtom ) {
out << "atoms:\n";
@@ -178,94 +178,94 @@
// add blank line between atoms for readability
out << "\n";
}
-
+
bool hasDash = false;
if ( !atom.name().empty() ) {
out << " - "
<< KeyValues::nameKeyword
<< ":"
<< spacePadding(KeyValues::nameKeyword)
- << atom.name()
+ << atom.name()
<< "\n";
hasDash = true;
}
-
+
if ( _rnb.hasRefName(&atom) ) {
out << (hasDash ? " " : " - ")
<< KeyValues::refNameKeyword
<< ":"
<< spacePadding(KeyValues::refNameKeyword)
- << _rnb.refName(&atom)
+ << _rnb.refName(&atom)
<< "\n";
hasDash = true;
}
-
+
if ( atom.definition() != KeyValues::definitionDefault ) {
out << (hasDash ? " " : " - ")
- << KeyValues::definitionKeyword
+ << KeyValues::definitionKeyword
<< ":"
<< spacePadding(KeyValues::definitionKeyword)
- << KeyValues::definition(atom.definition())
+ << KeyValues::definition(atom.definition())
<< "\n";
hasDash = true;
}
-
+
if ( atom.scope() != KeyValues::scopeDefault ) {
out << (hasDash ? " " : " - ")
- << KeyValues::scopeKeyword
+ << KeyValues::scopeKeyword
<< ":"
<< spacePadding(KeyValues::scopeKeyword)
- << KeyValues::scope(atom.scope())
+ << KeyValues::scope(atom.scope())
<< "\n";
hasDash = true;
}
-
+
if ( atom.interposable() != KeyValues::interposableDefault ) {
- out << " "
- << KeyValues::interposableKeyword
+ out << " "
+ << KeyValues::interposableKeyword
<< ":"
<< spacePadding(KeyValues::interposableKeyword)
- << KeyValues::interposable(atom.interposable())
+ << KeyValues::interposable(atom.interposable())
<< "\n";
}
-
+
if ( atom.merge() != KeyValues::mergeDefault ) {
- out << " "
- << KeyValues::mergeKeyword
+ out << " "
+ << KeyValues::mergeKeyword
<< ":"
<< spacePadding(KeyValues::mergeKeyword)
- << KeyValues::merge(atom.merge())
+ << KeyValues::merge(atom.merge())
<< "\n";
}
-
+
if ( atom.contentType() != KeyValues::contentTypeDefault ) {
- out << " "
- << KeyValues::contentTypeKeyword
+ out << " "
+ << KeyValues::contentTypeKeyword
<< ":"
<< spacePadding(KeyValues::contentTypeKeyword)
- << KeyValues::contentType(atom.contentType())
+ << KeyValues::contentType(atom.contentType())
<< "\n";
}
if ( atom.deadStrip() != KeyValues::deadStripKindDefault ) {
- out << " "
- << KeyValues::deadStripKindKeyword
+ out << " "
+ << KeyValues::deadStripKindKeyword
<< ":"
<< spacePadding(KeyValues::deadStripKindKeyword)
- << KeyValues::deadStripKind(atom.deadStrip())
+ << KeyValues::deadStripKind(atom.deadStrip())
<< "\n";
}
if ( atom.sectionChoice() != KeyValues::sectionChoiceDefault ) {
- out << " "
- << KeyValues::sectionChoiceKeyword
+ out << " "
+ << KeyValues::sectionChoiceKeyword
<< ":"
<< spacePadding(KeyValues::sectionChoiceKeyword)
- << KeyValues::sectionChoice(atom.sectionChoice())
+ << KeyValues::sectionChoice(atom.sectionChoice())
<< "\n";
assert( ! atom.customSectionName().empty() );
- out << " "
- << KeyValues::sectionNameKeyword
+ out << " "
+ << KeyValues::sectionNameKeyword
<< ":"
<< spacePadding(KeyValues::sectionNameKeyword)
<< atom.customSectionName()
@@ -273,27 +273,27 @@
}
if ( atom.isThumb() != KeyValues::isThumbDefault ) {
- out << " "
- << KeyValues::isThumbKeyword
+ out << " "
+ << KeyValues::isThumbKeyword
<< ":"
<< spacePadding(KeyValues::isThumbKeyword)
- << KeyValues::isThumb(atom.isThumb())
+ << KeyValues::isThumb(atom.isThumb())
<< "\n";
}
if ( atom.isAlias() != KeyValues::isAliasDefault ) {
- out << " "
- << KeyValues::isAliasKeyword
+ out << " "
+ << KeyValues::isAliasKeyword
<< ":"
<< spacePadding(KeyValues::isAliasKeyword)
- << KeyValues::isAlias(atom.isAlias())
+ << KeyValues::isAlias(atom.isAlias())
<< "\n";
}
- if ( (atom.contentType() != DefinedAtom::typeZeroFill)
+ if ( (atom.contentType() != DefinedAtom::typeZeroFill)
&& (atom.size() != 0) ) {
- out << " "
- << KeyValues::contentKeyword
+ out << " "
+ << KeyValues::contentKeyword
<< ":"
<< spacePadding(KeyValues::contentKeyword)
<< "[ ";
@@ -342,7 +342,7 @@
<< KeyValues::fixupsTargetKeyword
<< ":"
<< spacePadding(KeyValues::fixupsTargetKeyword)
- << refName
+ << refName
<< "\n";
}
if ( ref->addend() != 0 ) {
@@ -355,7 +355,7 @@
}
}
}
-
+
void writeUndefinedAtom(const UndefinedAtom &atom, raw_ostream &out) {
if ( _firstAtom ) {
@@ -366,27 +366,27 @@
// add blank line between atoms for readability
out << "\n";
}
-
+
out << " - "
<< KeyValues::nameKeyword
<< ":"
<< spacePadding(KeyValues::nameKeyword)
- << atom.name()
+ << atom.name()
<< "\n";
- out << " "
- << KeyValues::definitionKeyword
+ out << " "
+ << KeyValues::definitionKeyword
<< ":"
<< spacePadding(KeyValues::definitionKeyword)
- << KeyValues::definition(atom.definition())
+ << KeyValues::definition(atom.definition())
<< "\n";
if ( atom.canBeNull() != KeyValues::canBeNullDefault ) {
- out << " "
- << KeyValues::canBeNullKeyword
+ out << " "
+ << KeyValues::canBeNullKeyword
<< ":"
<< spacePadding(KeyValues::canBeNullKeyword)
- << KeyValues::canBeNull(atom.canBeNull())
+ << KeyValues::canBeNull(atom.canBeNull())
<< "\n";
}
}
@@ -400,24 +400,24 @@
// add blank line between atoms for readability
out << "\n";
}
-
+
out << " - "
<< KeyValues::nameKeyword
<< ":"
<< spacePadding(KeyValues::nameKeyword)
- << atom.name()
+ << atom.name()
<< "\n";
- out << " "
- << KeyValues::definitionKeyword
+ out << " "
+ << KeyValues::definitionKeyword
<< ":"
<< spacePadding(KeyValues::definitionKeyword)
- << KeyValues::definition(atom.definition())
+ << KeyValues::definition(atom.definition())
<< "\n";
if ( !atom.loadName().empty() ) {
- out << " "
- << KeyValues::loadNameKeyword
+ out << " "
+ << KeyValues::loadNameKeyword
<< ":"
<< spacePadding(KeyValues::loadNameKeyword)
<< atom.loadName()
@@ -425,15 +425,15 @@
}
if ( atom.canBeNullAtRuntime() ) {
- out << " "
- << KeyValues::canBeNullKeyword
+ out << " "
+ << KeyValues::canBeNullKeyword
<< ":"
<< spacePadding(KeyValues::canBeNullKeyword)
- << KeyValues::canBeNull(UndefinedAtom::canBeNullAtRuntime)
+ << KeyValues::canBeNull(UndefinedAtom::canBeNullAtRuntime)
<< "\n";
}
}
-
+
void writeAbsoluteAtom(const AbsoluteAtom &atom, raw_ostream &out) {
if ( _firstAtom ) {
out << "atoms:\n";
@@ -443,30 +443,30 @@
// add blank line between atoms for readability
out << "\n";
}
-
+
out << " - "
<< KeyValues::nameKeyword
<< ":"
<< spacePadding(KeyValues::nameKeyword)
- << atom.name()
+ << atom.name()
<< "\n";
- out << " "
- << KeyValues::definitionKeyword
+ out << " "
+ << KeyValues::definitionKeyword
<< ":"
<< spacePadding(KeyValues::definitionKeyword)
- << KeyValues::definition(atom.definition())
+ << KeyValues::definition(atom.definition())
<< "\n";
-
- out << " "
- << KeyValues::valueKeyword
+
+ out << " "
+ << KeyValues::valueKeyword
<< ":"
<< spacePadding(KeyValues::valueKeyword)
<< "0x";
out.write_hex(atom.value());
out << "\n";
}
-
+
private:
// return a string of the correct number of spaces to align value
@@ -500,7 +500,7 @@
void writeObjectText(const File &file, Platform &platform, raw_ostream &out) {
// Figure what ref-name labels are needed
RefNameBuilder rnb(file);
-
+
// Write out all atoms
AtomWriter writer(file, platform, rnb);
writer.write(out);
Modified: lld/trunk/lib/Passes/StubsPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/StubsPass.cpp?rev=153964&r1=153963&r2=153964&view=diff
==============================================================================
--- lld/trunk/lib/Passes/StubsPass.cpp (original)
+++ lld/trunk/lib/Passes/StubsPass.cpp Tue Apr 3 13:40:27 2012
@@ -29,15 +29,15 @@
// Skip this pass if output format uses text relocations instead of stubs.
if ( !_platform.noTextRelocs() )
return;
-
+
// Use map so all call sites to same shlib symbol use same stub.
llvm::DenseMap<const Atom*, const DefinedAtom*> targetToStub;
-
+
// Scan all references in all atoms.
- for(auto ait=_file.definedAtomsBegin(), aend=_file.definedAtomsEnd();
+ for(auto ait=_file.definedAtomsBegin(), aend=_file.definedAtomsEnd();
ait != aend; ++ait) {
const DefinedAtom* atom = *ait;
- for (auto rit=atom->referencesBegin(), rend=atom->referencesEnd();
+ for (auto rit=atom->referencesBegin(), rend=atom->referencesEnd();
rit != rend; ++rit) {
const Reference* ref = *rit;
// Look at call-sites.
@@ -51,7 +51,7 @@
} else if (const DefinedAtom* defTarget =
dyn_cast<DefinedAtom>(target)) {
if ( defTarget->interposable() != DefinedAtom::interposeNo ) {
- // Calls to interposable functions in same linkage unit
+ // Calls to interposable functions in same linkage unit
// must also go through a stub.
assert(defTarget->scope() != DefinedAtom::scopeTranslationUnit);
replaceCalleeWithStub = true;
@@ -79,12 +79,12 @@
}
}
}
-
+
// add all created stubs to file
for (auto it=targetToStub.begin(), end=targetToStub.end(); it != end; ++it) {
_file.addAtom(*it->second);
}
-
+
}
More information about the llvm-commits
mailing list