This patch is my proposed fix for bug 577,  The problem is that when
linking a program using the -pie (-fPIE, -fpie) option to create a
position independent executable we link in libopen64rt.a which contains
non-PIC code and this causes us to get a link-time error.

My fix is to link in libopen64rt_shared.a instead of libopen64rt.a when
linking PIE code since the code in libopen64rt_shared.a is built with
the -fPIC option.  We already link in libopen64rt_shared.a instead of
libopen64rt.a when building shared libraries.

I tested the patch on a small test case that calls bzero (one of the
functions defined in libopen64rt) and verified that it fixes the bug on
x86 and since the libopen64rt libraries are only used for x86 targets
this won't affect any other targets.

Can a gatekeeper approve this patch?

Steve Ellcey
s...@cup.hp.com


Defect report:

http://bugs.open64.net/show_bug.cgi?id=577


Patch:

Index: osprey/driver/phases.c
===================================================================
--- osprey/driver/phases.c      (revision 3298)
+++ osprey/driver/phases.c      (working copy)
@@ -2124,7 +2124,8 @@ add_final_ld_args (string_list_t *args, 
        // Bug 3995.
        if (!option_was_seen(O_fno_fast_stdlib) &&
            !option_was_seen(O_nolibopen64rt)) {        // bug 9611
-            if (option_was_seen(O_shared)) {
+            if (option_was_seen(O_shared) || option_was_seen(O_pie) ||
+                option_was_seen(O_fpie) || option_was_seen(O_fPIE)) {
                 add_library(args, "open64rt_shared");
             } else {
                 add_library(args, "open64rt");

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to