* PIC codegen for X86/Linux has been implemented

* PIC-aware internal structures in X86 Codegen have been refactored
* Visibility (default/weak) has been added
* Docs fixes (external weak linkage, visibility, formatting)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33136 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov
2007-01-12 19:20:47 +00:00
parent ab7752c149
commit 7f70559bc4
31 changed files with 607 additions and 178 deletions

View File

@@ -127,6 +127,25 @@ X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS, bool
if (getCodeModel() == CodeModel::Default)
setCodeModel(CodeModel::Small);
}
if (getRelocationModel() == Reloc::PIC_) {
if (Subtarget.isTargetDarwin()) {
if (Subtarget.is64Bit())
Subtarget.setPICStyle(PICStyle::RIPRel);
else
Subtarget.setPICStyle(PICStyle::Stub);
} else if (Subtarget.isTargetELF())
Subtarget.setPICStyle(PICStyle::GOT);
else
assert(0 && "Don't know how to generate PIC code for this target!");
} else if (getRelocationModel() == Reloc::DynamicNoPIC) {
if (Subtarget.isTargetDarwin())
Subtarget.setPICStyle(PICStyle::Stub);
else if (Subtarget.isTargetCygMing())
Subtarget.setPICStyle(PICStyle::WinPIC);
else
assert(0 && "Don't know how to generate PIC code for this target!");
}
}
//===----------------------------------------------------------------------===//
@@ -163,6 +182,8 @@ bool X86TargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
MachineCodeEmitter &MCE) {
// FIXME: Move this to TargetJITInfo!
setRelocationModel(Reloc::Static);
Subtarget.setPICStyle(PICStyle::None);
// JIT cannot ensure globals are placed in the lower 4G of address.
if (Subtarget.is64Bit())
setCodeModel(CodeModel::Large);