mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
7521964d28
This starts merging MCSection and MCSectionData. There are a few issues with the current split between MCSection and MCSectionData. * It optimizes the the not as important case. We want the production of .o files to be really fast, but the split puts the information used for .o emission in a separate data structure. * The ELF/COFF/MachO hierarchy is not represented in MCSectionData, leading to some ad-hoc ways to represent the various flags. * It makes it harder to remember where each item is. The attached patch starts merging the two by moving the alignment from MCSectionData to MCSection. Most of the patch is actually just dropping 'const', since MCSectionData is mutable, but MCSection was not. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237936 91177308-0d34-0410-b5e6-96231b3b80d8
64 lines
2.6 KiB
C++
64 lines
2.6 KiB
C++
//===-- PPCTargetObjectFile.cpp - PPC Object Info -------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "PPCTargetObjectFile.h"
|
|
#include "llvm/IR/Mangler.h"
|
|
#include "llvm/MC/MCContext.h"
|
|
#include "llvm/MC/MCExpr.h"
|
|
#include "llvm/MC/MCSectionELF.h"
|
|
|
|
using namespace llvm;
|
|
|
|
void
|
|
PPC64LinuxTargetObjectFile::
|
|
Initialize(MCContext &Ctx, const TargetMachine &TM) {
|
|
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
|
|
InitializeELF(TM.Options.UseInitArray);
|
|
}
|
|
|
|
MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal(
|
|
const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
|
|
const TargetMachine &TM) const {
|
|
// Here override ReadOnlySection to DataRelROSection for PPC64 SVR4 ABI
|
|
// when we have a constant that contains global relocations. This is
|
|
// necessary because of this ABI's handling of pointers to functions in
|
|
// a shared library. The address of a function is actually the address
|
|
// of a function descriptor, which resides in the .opd section. Generated
|
|
// code uses the descriptor directly rather than going via the GOT as some
|
|
// other ABIs do, which means that initialized function pointers must
|
|
// reference the descriptor. The linker must convert copy relocs of
|
|
// pointers to functions in shared libraries into dynamic relocations,
|
|
// because of an ordering problem with initialization of copy relocs and
|
|
// PLT entries. The dynamic relocation will be initialized by the dynamic
|
|
// linker, so we must use DataRelROSection instead of ReadOnlySection.
|
|
// For more information, see the description of ELIMINATE_COPY_RELOCS in
|
|
// GNU ld.
|
|
if (Kind.isReadOnly()) {
|
|
const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
|
|
|
|
if (GVar && GVar->isConstant() &&
|
|
(GVar->getInitializer()->getRelocationInfo() ==
|
|
Constant::GlobalRelocations))
|
|
Kind = SectionKind::getReadOnlyWithRel();
|
|
}
|
|
|
|
return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind,
|
|
Mang, TM);
|
|
}
|
|
|
|
const MCExpr *PPC64LinuxTargetObjectFile::
|
|
getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
|
|
const MCExpr *Expr =
|
|
MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_PPC_DTPREL, getContext());
|
|
return MCBinaryExpr::CreateAdd(Expr,
|
|
MCConstantExpr::Create(0x8000, getContext()),
|
|
getContext());
|
|
}
|
|
|