[gold][patch] Fix non-PIC warning to print only when building position-independent output

Cary Coutant ccoutant@google.com
Fri Mar 27 17:57:00 GMT 2009


>> I can see the path you took to get to this patch, but now that you are
>> here, why not just put the assert in check_non_pic in all cases?
>
> That would be just as good in my view -- that's what I originally
> thought of in my first response to Hans-Peter, but then I realized
> that we've already established that we're PIC in all but two cases, so
> I thought it might be a bit clearer to establish the assertion more
> locally for those two cases. Keeping the name check_non_pic does kind
> of make that clear, though, so I'm fine either way.

And here's a patch for that...

(I should note that I'm also fine leaving the code as is -- I think
I'm now satisfied that we can't take this path unless we are
generating a position-independent output file. It might be good as
documentation for future targets, though.)

-cary


      * powerpc.cc (Target_powerpc::check_non_pic): Assert that output is
      position independent.
      * sparc.cc (Target_sparc::check_non_pic): Likewise.
      * x86_64.cc (Target_x86_64::check_non_pic): Likewise.


Index: powerpc.cc
===================================================================
RCS file: /cvs/src/src/gold/powerpc.cc,v
retrieving revision 1.11
diff -u -p -r1.11 powerpc.cc
--- powerpc.cc	24 Mar 2009 04:50:32 -0000	1.11
+++ powerpc.cc	27 Mar 2009 17:41:08 -0000
@@ -1094,6 +1094,7 @@ Target_powerpc<size, big_endian>::Scan::
   // error per object file.
   if (this->issued_non_pic_error_)
     return;
+  gold_assert(parameters->options().output_is_position_independent());
   object->error(_("requires unsupported dynamic reloc; "
 		  "recompile with -fPIC"));
   this->issued_non_pic_error_ = true;
Index: sparc.cc
===================================================================
RCS file: /cvs/src/src/gold/sparc.cc,v
retrieving revision 1.15
diff -u -p -r1.15 sparc.cc
--- sparc.cc	24 Mar 2009 04:50:32 -0000	1.15
+++ sparc.cc	27 Mar 2009 17:41:08 -0000
@@ -1589,6 +1589,7 @@ Target_sparc<size, big_endian>::Scan::ch
   // error per object file.
   if (this->issued_non_pic_error_)
     return;
+  gold_assert(parameters->options().output_is_position_independent());
   object->error(_("requires unsupported dynamic reloc; "
 		  "recompile with -fPIC"));
   this->issued_non_pic_error_ = true;
Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.80
diff -u -p -r1.80 x86_64.cc
--- x86_64.cc	24 Mar 2009 00:31:29 -0000	1.80
+++ x86_64.cc	27 Mar 2009 17:41:08 -0000
@@ -974,6 +974,7 @@ Target_x86_64::Scan::check_non_pic(Relob
       // error per object file.
       if (this->issued_non_pic_error_)
         return;
+      gold_assert(parameters->options().output_is_position_independent());
       object->error(_("requires unsupported dynamic reloc; "
                       "recompile with -fPIC"));
       this->issued_non_pic_error_ = true;



More information about the Binutils mailing list