This is the mail archive of the
mailing list for the binutils project.
Re: Question about ld_plugin_output_file_type and "-fpic" option
- From: Alexander Ivchenko <aivchenk at gmail dot com>
- To: binutils <binutils at sourceware dot org>
- Date: Thu, 20 Mar 2014 18:03:21 +0400
- Subject: Re: Question about ld_plugin_output_file_type and "-fpic" option
- Authentication-results: sourceware.org; auth=none
- References: <CACysShhtHBVrnj+-7==fC_WDY4V9mBBjwvifY9t5DsB45DZxYg at mail dot gmail dot com>
Hi guys, could you please share some expertise on the question? I see
this LLVM's fail to produce position independent code executable with
"-fpic -flto", because it relies on ld_plugin_output_file_type and gcc
2014-03-04 18:16 GMT+04:00 Alexander Ivchenko <email@example.com>:
> Have a little question about ld_plugin_output_file_type in plugin-api.h.
> "-fpic" option is turned on by default for Android compiler (both gcc
> and llvm), so if we run the compiler on a .c file and get an
> executable - it will be compiled and linked as position independent
> code (e.g. no COPY relocs).
> However, if we add an lto mechanism into account, the thing will be
> different. As far as I understand, for gcc case "-fpic" option will be
> given through temporary file, but llvm will rely on
> ld_plugin_output_file_type of the linker, which in the case described
> above would be just LDPO_EXEC which is not position independent. And
> so for "-fpic" and lto we will get copy relocations and stuff.
> Since we allow to compile and link an executable with "-fpic" (I know
> that it is recommended to make an executable "-fpie" but I'm
> describing how the default compiling is done) what are the assumptions
> on a resulting executable? Should there be another entry in
> ld_plugin_output_file_type for that? "-fpic" is not given to a linker
> in any way, can we say that the resulting executable will be a
> position independent?