[llvm-dev] PIC preferred too strongly, even at CodeModel::Large?
Ramkumar Ramachandra via llvm-dev
llvm-dev at lists.llvm.org
Thu Jul 28 18:13:08 PDT 2016
We were just debugging a sporadic crash the other day, when we noticed
that RIP-relative addressing was being used in a JumpTable, even when
code and data were well over 4G apart. This is confusing, because we
picked CodeModel::Large, and expected this to be taken care of. Isn't
that what gcc would do given a Large CodeModel?
The default Relocation Model, Reloc::Default, folds into Reloc::PIC_
in most cases. However, if we explicitly specify Reloc::Static, our
program should work on all platforms except Darwin:
// If we are on Darwin, disallow static relocation model in X86-64 mode, since
// the Mach-O file format doesn't support it.
if (RM == Reloc::Static && TT.isOSDarwin() && is64Bit)
RM = Reloc::PIC_;
First, is the Mach-O limitation still there? Second, is it okay to
silently fold into Reloc::PIC_ in this case and leave the user with
sporadic crashes? Finally, can we bypass this limitation by simply
appending "-elf" to our Target Triple, forcing ELF generation on all
More information about the llvm-dev