blob: 8faf70737bff843677eb863310aba05d53a7de00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
//===- lib/MC/MCWinEH.cpp - Windows EH implementation ---------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCWinEH.h"
#include "llvm/Support/COFF.h"
namespace llvm {
namespace WinEH {
const MCSection *UnwindEmitter::GetPDataSection(StringRef Suffix,
MCContext &Context) {
if (Suffix.empty())
return Context.getObjectFileInfo()->getPDataSection();
return Context.getCOFFSection((".pdata" + Suffix).str(),
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ,
SectionKind::getDataRel());
}
const MCSection *UnwindEmitter::GetXDataSection(StringRef Suffix,
MCContext &Context) {
if (Suffix.empty())
return Context.getObjectFileInfo()->getXDataSection();
return Context.getCOFFSection((".xdata" + Suffix).str(),
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ,
SectionKind::getDataRel());
}
StringRef UnwindEmitter::GetSectionSuffix(const MCSymbol *Function) {
if (!Function || !Function->isInSection())
return "";
const MCSection *FunctionSection = &Function->getSection();
if (const auto Section = dyn_cast<MCSectionCOFF>(FunctionSection)) {
StringRef Name = Section->getSectionName();
size_t Dollar = Name.find('$');
size_t Dot = Name.find('.', 1);
if (Dollar == StringRef::npos && Dot == StringRef::npos)
return "";
if (Dot == StringRef::npos)
return Name.substr(Dollar);
if (Dollar == StringRef::npos || Dot < Dollar)
return Name.substr(Dot);
return Name.substr(Dollar);
}
return "";
}
}
}
|