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

Cary Coutant ccoutant@google.com
Thu Mar 26 00:26:00 GMT 2009

>> If we ever do hit this case in a
>> non-position-independent link, however, I hope it'll be the compiler's
>> fault, and we shouldn't print a message that implies that -fPIC is
>> actually required. (Maybe we should print something instead about a
>> possible bug in the compiler or assembly code?)
> IMHO don't just hint at a gcc bug: missing -fPIC is much too
> common.  Or if that's not applicable here, maybe the user didn't
> use the correct linker option?

If a missing -fPIC really is the problem, we will still print that. If
you're building a non-position-independent executable, however, you
shouldn't be told to recompile the code with -fPIC, because that's not
supposed to be required for code in an executable. Instead, it points
to a problem either with hand-written assembly code (most likely, I
think), or with the compiler, or with the linker. If the only
possibility were a linker bug, I could just put an assert here and let
the linker die:

+      gold_assert(parameters->options().output_is_position_independent());
+      object->error(_("requires unsupported dynamic reloc; "
+                      "recompile with -fPIC"));
+      this->issued_unsupp_reloc_error_ = true;

I don't think that's the only (or even the most likely) possibility, though.


More information about the Binutils mailing list