Index: osprey/be/cg/calls.cxx
===================================================================
--- osprey/be/cg/calls.cxx	(revision 3542)
+++ osprey/be/cg/calls.cxx	(working copy)
@@ -374,7 +374,7 @@
 #ifdef TARG_X8664
   if( CG_opt_level > 0  &&
       Is_Target_32bit() &&
-      (Gen_PIC_Shared || Gen_PIC_Call_Shared)    &&
+      (Gen_PIC_Shared || Gen_PIE)    &&
       !PU_References_GOT ){
     TN* ebx_tn = Ebx_TN();
     REGISTER_Set_Allocatable( TN_register_class(ebx_tn),
@@ -924,7 +924,7 @@
   }
 
 #ifdef TARG_X8664
-  if( Is_Target_32bit() && (Gen_PIC_Shared || Gen_PIC_Call_Shared) ){
+  if( Is_Target_32bit() && (Gen_PIC_Shared || Gen_PIE) ){
     EETARG_Generate_PIC_Entry_Code( bb, &ops );
   }
 #endif
@@ -1749,7 +1749,7 @@
     EETARG_Restore_Extra_Callee_Tns (&ops);
 
 #ifdef TARG_X8664
-  if( Is_Target_32bit() && (Gen_PIC_Call_Shared || Gen_PIC_Shared) ){
+  if( Is_Target_32bit() && (Gen_PIE || Gen_PIC_Shared) ){
     EETARG_Generate_PIC_Exit_Code( bb_epi, &ops );
   }
 #endif
Index: osprey/be/cg/register.cxx
===================================================================
--- osprey/be/cg/register.cxx	(revision 3542)
+++ osprey/be/cg/register.cxx	(working copy)
@@ -776,7 +776,7 @@
        be used to hold the address pointing to the global offset table.
     */
     if( Is_Target_32bit() &&
-	(Gen_PIC_Shared || Gen_PIC_Call_Shared)   &&
+	(Gen_PIC_Shared || Gen_PIE )   &&
 	rclass == TN_register_class(ebx_tn) ){
       reg_alloc_status[rclass][TN_register(ebx_tn)] = AS_not_allocatable;
       re_init = TRUE;
Index: osprey/be/cg/x8664/expand.cxx
===================================================================
--- osprey/be/cg/x8664/expand.cxx	(revision 3542)
+++ osprey/be/cg/x8664/expand.cxx	(working copy)
@@ -9890,7 +9890,7 @@
 	         Gen_Literal_TN(4*(num_xmms-8), 4), ops);
       }
       Build_OP(TOP_neg64, r11_tn, r11_tn, ops);
-      if ( Gen_PIC_Shared || Gen_PIC_Call_Shared ) {
+      if ( Gen_PIC_Shared || Gen_PIE ) {
 	Build_OP ( TOP_lea64, rax_tn, Rip_TN(), OP_opnd( op, 4 ), ops );
 	ops->last->bb = bb; // to pass Verify_Operand
 	Build_OP ( TOP_leax64, r11_tn, r11_tn, rax_tn, 
Index: osprey/be/cg/x8664/cgemit_targ.cxx
===================================================================
--- osprey/be/cg/x8664/cgemit_targ.cxx	(revision 3542)
+++ osprey/be/cg/x8664/cgemit_targ.cxx	(working copy)
@@ -3906,7 +3906,7 @@
     // Mach-O linker evidently handles this automatically
 #else /* defined(BUILD_OS_DARWIN) */
     // Add a reference to the PLT under -fPIC compilation.
-    if ( (Gen_PIC_Shared || Gen_PIC_Call_Shared) &&  
+    if ( (Gen_PIC_Shared || Gen_PIE) &&  
 	 !TN_is_label( OP_opnd(op,opnd) ) &&
          TOP_is_jump(topcode) &&
          opnd == OP_find_opnd_use(op,OU_target) ) {
Index: osprey/be/cg/x8664/exp_loadstore.cxx
===================================================================
--- osprey/be/cg/x8664/exp_loadstore.cxx	(revision 3542)
+++ osprey/be/cg/x8664/exp_loadstore.cxx	(working copy)
@@ -1176,8 +1176,9 @@
       else if( Is_Target_64bit() ){
         FmtAssert(!ST_is_thread_local(base_sym),
                   ("Exp_Ldst: thread-local storage should not be handled here"));
-	if (Gen_PIC_Shared || Gen_PIC_Call_Shared) {
-	  if ( ST_is_preemptible(base_sym) ) {
+	if (Gen_PIC_Shared || Gen_PIE) {
+	  if ( (Gen_PIC_Shared && !ST_is_export_local(base_sym)) ||
+	       (Gen_PIE && ST_is_preemptible(base_sym)) ) {
 	    TN *tmp = base_ofst == 0 ? tn : Build_TN_Like(tn);
 	    Build_OP( TOP_ld64, tmp, Rip_TN(), 
 		      Gen_Symbol_TN( base_sym, 0, TN_RELOC_X8664_GOTPCREL ),
@@ -1225,7 +1226,7 @@
 	  ErrMsg(EC_Misc_User_Abort,
 	    ("Detected 64-bit address offset under -m32.  Try -m64 -mcmodel=medium."));
 
-	if( (Gen_PIC_Shared || Gen_PIC_Call_Shared) && 
+	if( (Gen_PIC_Shared || Gen_PIE) && 
 	    (!ST_is_export_local (base_sym) ||
 	                       // function, even if export_local?
 	                       ST_class(base_sym) == CLASS_FUNC ||
@@ -1338,7 +1339,7 @@
 	}
       }
 
-      if( (Gen_PIC_Shared || Gen_PIC_Call_Shared) && 
+      if( (Gen_PIC_Shared || Gen_PIE) && 
 	  (!ST_is_export_local (base_sym) ||
 	                      // section?
 	                      (ST_class(base_sym) == CLASS_BLOCK &&
Index: osprey/be/cg/whirl2ops.cxx
===================================================================
--- osprey/be/cg/whirl2ops.cxx	(revision 3542)
+++ osprey/be/cg/whirl2ops.cxx	(working copy)
@@ -1678,7 +1678,7 @@
 
 #ifdef TARG_X8664
   if( Is_Target_32bit() &&
-      (Gen_PIC_Shared || Gen_PIC_Call_Shared)    &&
+      (Gen_PIC_Shared || Gen_PIE)    &&
       call_st != NULL   &&
       !ST_is_export_local(call_st) ){
     PU_References_GOT = TRUE;
@@ -7784,7 +7784,7 @@
 
 #ifdef TARG_X8664
   if( Is_Target_32bit() &&
-      (Gen_PIC_Shared || Gen_PIC_Call_Shared)   &&
+      (Gen_PIC_Shared || Gen_PIE)   &&
       call_st != NULL   &&
       !ST_is_export_local(call_st) ){
     PU_References_GOT = TRUE;
Index: osprey/driver/OPTIONS
===================================================================
--- osprey/driver/OPTIONS	(revision 3542)
+++ osprey/driver/OPTIONS	(working copy)
@@ -2034,11 +2034,11 @@
  	"Do not generate position independent code"
 -fno-pic	toggle(&pic,TRUE);	A	anyfe	self
  	"Do not generate position independent code"
--fpie	;		A	anyfe	self "-TENV:PIC"
+-fpie	;		A	anyfe	self "-TENV:PIE"
 	"Generate position independent code, if possible"
--pie	;		A	ld	self "-TENV:PIC"
+-pie	;		A	ld	self "-TENV:PIE"
 	"Generate position independent code, if possible"
--fPIE	;		A	anyfe	self "-TENV:PIC"
+-fPIE	;		A	anyfe	self "-TENV:PIE"
  	"Generate position independent code, if possible"
 -fno-pie	;	A	anyfe	self
 	"Do not generate position independent code"
Index: osprey/common/com/config.cxx
===================================================================
--- osprey/common/com/config.cxx	(revision 3542)
+++ osprey/common/com/config.cxx	(working copy)
@@ -525,6 +525,9 @@
   { OVK_BOOL,	OV_SHY,		FALSE, "pic1",			NULL,
     0, 0, 0, &Gen_PIC_Call_Shared, NULL,
     "Generate code for executable programs which may call DSOs" },
+  { OVK_BOOL,	OV_SHY,		FALSE, "pie",			NULL,
+    0, 0, 0, &Gen_PIE, NULL,
+    "Generate code for position independent executables" },
   { OVK_BOOL,   OV_SHY,		FALSE, "profile_call",		"prof",
     0, 0, 0,    &Gen_Profile, NULL },
   { OVK_NAME,	OV_SHY,		FALSE, "profile_name",		"",
@@ -950,6 +953,7 @@
 BOOL Gen_PIC_Call_Shared = FALSE; /* CPIC */
 BOOL Gen_PIC_Shared = FALSE;	/* PIC */
 BOOL Gen_PIC_Calls = FALSE;	/* PIC calls */
+BOOL Gen_PIE = FALSE;	        /* PIE */
 BOOL Guaranteed_Small_GOT = TRUE; /* GOT < 64kB? */
 BOOL Non_Volatile_GOT = FALSE;	/* GOT entries volatile? */
 BOOL PIC_Local_Names = FALSE;	/* Names local by default? */
Index: osprey/common/com/config.h
===================================================================
--- osprey/common/com/config.h	(revision 3542)
+++ osprey/common/com/config.h	(working copy)
@@ -637,6 +637,7 @@
 extern BOOL Gen_PIC_Call_Shared; /* CPIC */
 extern BOOL Gen_PIC_Shared;	/* PIC */
 extern BOOL Gen_PIC_Calls;	/* do calls as PIC code */
+extern BOOL Gen_PIE;	        /* PIE */
 extern BOOL Guaranteed_Small_GOT; /* GOT < 64kB? */
 extern BOOL Non_Volatile_GOT;	/* GOT entries volatile? */
 extern BOOL PIC_Local_Names;	/* Names local by default? */
Index: osprey/common/com/x8664/config_targ.cxx
===================================================================
--- osprey/common/com/x8664/config_targ.cxx	(revision 3542)
+++ osprey/common/com/x8664/config_targ.cxx	(working copy)
@@ -819,8 +819,8 @@
     FP_Exception_Enable_Min |= FPX_V;
 
 // TMP: ignore cpic until we figure out what to do with it
-//   if (Gen_PIC_Call_Shared)
-// 	Gen_PIC_Call_Shared = FALSE;
+  if (Gen_PIC_Call_Shared)
+	Gen_PIC_Call_Shared = FALSE;
 
   return;
 }
Index: osprey/ipa/common/ipc_compile.cxx
===================================================================
--- osprey/ipa/common/ipc_compile.cxx	(revision 3542)
+++ osprey/ipa/common/ipc_compile.cxx	(working copy)
@@ -81,6 +81,9 @@
 
 #include "lib_phase_dir.h"              // for BINDIR etc
 
+#include "bfd.h"                        // for bfd_link_info
+#include "bfdlink.h"                    // for bfd_link_info
+
 #ifdef KEY
 #include "ipc_defs.h"                   // for IPA_Target_Type
 #endif
@@ -159,6 +162,8 @@
 static const char* symtab_command_line = 0;
 static const char* symtab_extra_args = 0;
 
+// to use link_info.pie
+extern struct bfd_link_info link_info;
 
 // Map from short forms of command names (e.g. "cc") to full 
 // forms (e.g. "/usr/bin/cc").
@@ -1391,6 +1396,8 @@
 #ifndef TARG_MIPS
 #if !defined(TARG_SL)
     args.push_back("-pic1");
+    if (link_info.pie)
+      args.push_back("-pie");
 #endif
 #endif
     break;
