xref: /freebsd/contrib/llvm-project/llvm/lib/Target/M68k/M68kTargetObjectFile.cpp (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 //===-- M68kELFTargetObjectFile.cpp - M68k Object Files ---------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file contains definitions for M68k ELF object file lowering.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #include "M68kTargetObjectFile.h"
15 
16 #include "M68kSubtarget.h"
17 #include "M68kTargetMachine.h"
18 
19 #include "llvm/BinaryFormat/ELF.h"
20 #include "llvm/IR/DataLayout.h"
21 #include "llvm/IR/DerivedTypes.h"
22 #include "llvm/IR/GlobalVariable.h"
23 #include "llvm/MC/MCContext.h"
24 #include "llvm/MC/MCSectionELF.h"
25 #include "llvm/Support/CommandLine.h"
26 #include "llvm/Target/TargetMachine.h"
27 
28 using namespace llvm;
29 
30 static cl::opt<unsigned> SSThreshold(
31     "m68k-ssection-threshold", cl::Hidden,
32     cl::desc("Small data and bss section threshold size (default=8)"),
33     cl::init(8));
34 
35 void M68kELFTargetObjectFile::Initialize(MCContext &Ctx,
36                                          const TargetMachine &TM) {
37   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
38   InitializeELF(TM.Options.UseInitArray);
39 
40   this->TM = &static_cast<const M68kTargetMachine &>(TM);
41 
42   // FIXME do we need `.sdata` and `.sbss` explicitly?
43   SmallDataSection = getContext().getELFSection(
44       ".sdata", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
45 
46   SmallBSSSection = getContext().getELFSection(".sbss", ELF::SHT_NOBITS,
47                                                ELF::SHF_WRITE | ELF::SHF_ALLOC);
48 }
49