1 //===- ELFDynObjFileFormat.cpp --------------------------------------------===//
2 //
3 // The MCLinker Project
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include <mcld/LD/ELFDynObjFileFormat.h>
10 #include <mcld/LD/LDSection.h>
11 #include <mcld/Object/ObjectBuilder.h>
12
13 #include <llvm/Support/ELF.h>
14
15 using namespace mcld;
16
initObjectFormat(ObjectBuilder & pBuilder,unsigned int pBitClass)17 void ELFDynObjFileFormat::initObjectFormat(ObjectBuilder& pBuilder,
18 unsigned int pBitClass)
19 {
20 f_pDynSymTab = pBuilder.CreateSection(".dynsym",
21 LDFileFormat::NamePool,
22 llvm::ELF::SHT_DYNSYM,
23 llvm::ELF::SHF_ALLOC,
24 pBitClass / 8);
25 f_pDynStrTab = pBuilder.CreateSection(".dynstr",
26 LDFileFormat::NamePool,
27 llvm::ELF::SHT_STRTAB,
28 llvm::ELF::SHF_ALLOC,
29 0x1);
30 f_pInterp = pBuilder.CreateSection(".interp",
31 LDFileFormat::Note,
32 llvm::ELF::SHT_PROGBITS,
33 llvm::ELF::SHF_ALLOC,
34 0x1);
35 f_pHashTab = pBuilder.CreateSection(".hash",
36 LDFileFormat::NamePool,
37 llvm::ELF::SHT_HASH,
38 llvm::ELF::SHF_ALLOC,
39 pBitClass / 8);
40 f_pDynamic = pBuilder.CreateSection(".dynamic",
41 LDFileFormat::NamePool,
42 llvm::ELF::SHT_DYNAMIC,
43 llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE,
44 pBitClass / 8);
45 f_pRelaDyn = pBuilder.CreateSection(".rela.dyn",
46 LDFileFormat::Relocation,
47 llvm::ELF::SHT_RELA,
48 llvm::ELF::SHF_ALLOC,
49 pBitClass / 8);
50 f_pRelaPlt = pBuilder.CreateSection(".rela.plt",
51 LDFileFormat::Relocation,
52 llvm::ELF::SHT_RELA,
53 llvm::ELF::SHF_ALLOC,
54 pBitClass / 8);
55 f_pRelDyn = pBuilder.CreateSection(".rel.dyn",
56 LDFileFormat::Relocation,
57 llvm::ELF::SHT_REL,
58 llvm::ELF::SHF_ALLOC,
59 pBitClass / 8);
60 f_pRelPlt = pBuilder.CreateSection(".rel.plt",
61 LDFileFormat::Relocation,
62 llvm::ELF::SHT_REL,
63 llvm::ELF::SHF_ALLOC,
64 pBitClass / 8);
65 f_pGOT = pBuilder.CreateSection(".got",
66 LDFileFormat::Target,
67 llvm::ELF::SHT_PROGBITS,
68 llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE,
69 pBitClass / 8);
70 f_pPLT = pBuilder.CreateSection(".plt",
71 LDFileFormat::Target,
72 llvm::ELF::SHT_PROGBITS,
73 llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,
74 pBitClass / 8);
75 f_pGOTPLT = pBuilder.CreateSection(".got.plt",
76 LDFileFormat::Target,
77 llvm::ELF::SHT_PROGBITS,
78 llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE,
79 pBitClass / 8);
80 f_pEhFrameHdr = pBuilder.CreateSection(".eh_frame_hdr",
81 LDFileFormat::EhFrameHdr,
82 llvm::ELF::SHT_PROGBITS,
83 llvm::ELF::SHF_ALLOC,
84 0x4);
85 f_pGNUHashTab = pBuilder.CreateSection(".gnu.hash",
86 LDFileFormat::NamePool,
87 llvm::ELF::SHT_GNU_HASH,
88 llvm::ELF::SHF_ALLOC,
89 pBitClass / 8);
90 }
91
92