Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision 37024fd8a316113ef12f469617e9da9c6cecc309)
+++ src/CodeGen/CodeGenerator.cc	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
@@ -10,5 +10,5 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri May 06 14:57:16 2016
+// Last Modified On : Fri May 06 15:40:35 2016
 // Update Count     : 243
 //
@@ -76,10 +76,19 @@
 	void CodeGenerator::visit( FunctionDecl *functionDecl ) {
 		// generalize this
-		switch ( functionDecl->get_attribute() ) {
-			case FunctionDecl::Constructor:
-				output << "__attribute__ ((constructor)) ";
+		FunctionDecl::Attribute attr = functionDecl->get_attribute();
+		switch ( attr.type ) {
+			case FunctionDecl::Attribute::Constructor:
+				output << "__attribute__ ((constructor";
+				if ( attr.priority != FunctionDecl::Attribute::Default ) {
+					output << "(" << attr.priority << ")";
+				}
+				output << ")) ";
 				break;
-			case FunctionDecl::Destructor:
-				output << "__attribute__ ((destructor)) ";
+			case FunctionDecl::Attribute::Destructor:
+				output << "__attribute__ ((destructor";
+				if ( attr.priority != FunctionDecl::Attribute::Default ) {
+					output << "(" << attr.priority << ")";
+				}
+				output << ")) ";
 				break;
 			default:
Index: src/InitTweak/FixGlobalInit.cc
===================================================================
--- src/InitTweak/FixGlobalInit.cc	(revision 37024fd8a316113ef12f469617e9da9c6cecc309)
+++ src/InitTweak/FixGlobalInit.cc	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
@@ -10,5 +10,5 @@
 // Created On       : Mon May 04 15:14:56 2016
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri May 06 14:59:26 2016
+// Last Modified On : Fri May 06 15:40:48 2016
 // Update Count     : 2
 //
@@ -30,5 +30,5 @@
 	class GlobalFixer : public Visitor {
 	  public:
-		GlobalFixer( const std::string & name );
+		GlobalFixer( const std::string & name, bool inLibrary );
 
 		virtual void visit( ObjectDecl *objDecl );
@@ -87,6 +87,6 @@
 	}
 
-	void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name ) {
-		GlobalFixer fixer( name );
+	void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ) {
+		GlobalFixer fixer( name, inLibrary );
 		acceptAll( translationUnit, fixer );
 		translationUnit.push_back( fixer.initFunction );
@@ -102,6 +102,6 @@
   }
 
-	GlobalFixer::GlobalFixer( const std::string & name ) : tempNamer( "_global_init" ) {
-		initFunction = new FunctionDecl( initName( name ), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Constructor );
+	GlobalFixer::GlobalFixer( const std::string & name, bool inLibrary ) : tempNamer( "_global_init" ) {
+		initFunction = new FunctionDecl( initName( name ), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Attribute( FunctionDecl::Attribute::Constructor, inLibrary ? FunctionDecl::Attribute::High : FunctionDecl::Attribute::Default ) );
 	}
 
Index: src/InitTweak/FixGlobalInit.h
===================================================================
--- src/InitTweak/FixGlobalInit.h	(revision 37024fd8a316113ef12f469617e9da9c6cecc309)
+++ src/InitTweak/FixGlobalInit.h	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
@@ -10,5 +10,5 @@
 // Created On       : Mon May 04 15:14:56 2016
 // Last Modified By : Rob Schluntz
-// Last Modified On : Wed May 04 16:35:37 2016
+// Last Modified On : Fri May 06 15:29:13 2016
 // Update Count     : 2
 //
@@ -24,6 +24,8 @@
 
 namespace InitTweak {
-  /// Moves global initialization into an _init function that is unique to the translation unit
-  void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name );
+  /// Moves global initialization into an _init function that is unique to the translation unit.
+  /// Sets the priority of the initialization function depending on whether the initialization
+  /// function is for library code.
+  void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary );
 
   /// Apply transformations to a file name to get a valid C identifier which will be used as
Index: src/SynTree/Declaration.h
===================================================================
--- src/SynTree/Declaration.h	(revision 37024fd8a316113ef12f469617e9da9c6cecc309)
+++ src/SynTree/Declaration.h	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
@@ -10,5 +10,5 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri May 06 11:16:45 2016
+// Last Modified On : Fri May 06 15:39:02 2016
 // Update Count     : 33
 //
@@ -107,9 +107,16 @@
   public:
 	// temporary - merge this into general GCC attributes
-	enum Attribute {
-		NoAttribute, Constructor, Destructor,
+	struct Attribute {
+		enum Type {
+			NoAttribute, Constructor, Destructor,
+		} type;
+		enum Priority {
+			// priorities 0-100 are reserved by gcc, so it's okay to use 100 an exceptional case
+			Default = 100, High,
+		} priority;
+		Attribute(Type t = NoAttribute, Priority p = Default) : type(t), priority(p) {};
 	};
 
-	FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = NoAttribute );
+	FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = Attribute() );
 	FunctionDecl( const FunctionDecl &other );
 	virtual ~FunctionDecl();
Index: src/SynTree/FunctionDecl.cc
===================================================================
--- src/SynTree/FunctionDecl.cc	(revision 37024fd8a316113ef12f469617e9da9c6cecc309)
+++ src/SynTree/FunctionDecl.cc	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
@@ -10,5 +10,5 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri May 06 11:35:09 2016
+// Last Modified On : Fri May 06 15:41:05 2016
 // Update Count     : 19
 //
@@ -65,13 +65,16 @@
 		os << "_Noreturn ";
 	} // if
-	switch ( attribute ) {
-		case Constructor:
+	switch ( attribute.type ) {
+		case Attribute::Constructor:
 			os << "Global Constructor ";
 			break;
-		case Destructor:
+		case Attribute::Destructor:
 			os << "Global Destructor ";
 			break;
 		default:
 			break;
+	}
+	if ( attribute.priority != Attribute::Default ) {
+		os << "with priority " << attribute.priority << " ";
 	}
 	if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
@@ -114,13 +117,16 @@
 		os << "_Noreturn ";
 	} // if
-	switch ( attribute ) {
-		case Constructor:
+	switch ( attribute.type ) {
+		case Attribute::Constructor:
 			os << " Global Constructor ";
 			break;
-		case Destructor:
+		case Attribute::Destructor:
 			os << " Global Destructor ";
 			break;
 		default:
 			break;
+	}
+	if ( attribute.priority != Attribute::Default ) {
+		os << "with priority " << attribute.priority << " ";
 	}
 	if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
Index: src/main.cc
===================================================================
--- src/main.cc	(revision 37024fd8a316113ef12f469617e9da9c6cecc309)
+++ src/main.cc	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
@@ -10,5 +10,5 @@
 // Created On       : Fri May 15 23:12:02 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri May 06 14:56:40 2016
+// Last Modified On : Fri May 06 15:29:42 2016
 // Update Count     : 203
 //
@@ -261,5 +261,5 @@
 		CodeGen::fixNames( translationUnit );
 		OPTPRINT( "fixGlobalInit" );
-		InitTweak::fixGlobalInit( translationUnit, filename );
+		InitTweak::fixGlobalInit( translationUnit, filename, libcfap || treep );
 		OPTPRINT( "tweak" )
 		InitTweak::tweak( translationUnit );
