[PATCH] [mips] Set default relocation model to static for NaCl

Petar Jovanovic petarj at mips.com
Tue Sep 23 09:59:01 PDT 2014


================
Comment at: lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp:98
@@ +97,3 @@
+    else
+      RM = Reloc::PIC_;
+  }
----------------
mseaborn wrote:
> Could possibly you add a comment to explain why the default is PIC, and why you don't make Reloc::Static the default for non-NaCl targets as well as for NaCl?
> 
> This has come up several times, but I'm still not clear on why LLVM defaults to PIC for MIPS.
> 
> e.g. Sasa Sankovic wrote: "MIPS traditionally used PIC relocation model, to be able to use shared libraries. PLT support (which enables non-PIC code to use shared libraries) was added to MIPS only recently, in 2008. I suppose at that time GCC switched to using non-PIC as default. I don't know why LLVM still uses PIC." (see http://reviews.llvm.org/D3928)
> 
> Even if the comment is speculative, it would be useful.  The comment could just state that the reasons are unknown, and that Reloc::Static is being left as the default in case changing it breaks anything.
I would rather avoid putting comments and being explicit about MIPS default relocation model, primarily because I am not sure I can have a complete answer to your question. PIC has been generally used for Linux shared libraries and majority of applications. PIC code can be easily relocated, and in some instances, such as N64, is actually more efficient that static. You will find out that we are generating PIC code for N64 even if you pass relocation-model=static to llc.

http://reviews.llvm.org/D5442






More information about the llvm-commits mailing list