[WebAssembly] MC: Fix crash when -g specified.

At this point we don't output any debug sections or thier
relocations.

Differential Revision: https://reviews.llvm.org/D39076

llvm-svn: 316240
This commit is contained in:
Sam Clegg
2017-10-20 21:28:38 +00:00
parent c420b61b26
commit 12fd3da9d1
9 changed files with 99 additions and 59 deletions

View File

@@ -168,8 +168,7 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
MMI, Streamer);
}
static SectionKind
getELFKindForNamedSection(StringRef Name, SectionKind K) {
static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
// N.B.: The defaults used in here are no the same ones used in MC.
// We follow gcc, MC follows gas. For example, given ".section .eh_frame",
// both gas and MC will produce a section with no flags. Given
@@ -1249,7 +1248,7 @@ static const Comdat *getWasmComdat(const GlobalValue *GV) {
MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
StringRef Name = GO->getSection();
return getContext().getWasmSection(Name, wasm::WASM_SEC_DATA);
return getContext().getWasmSection(Name, SectionKind::getData());
}
static MCSectionWasm *selectWasmSectionForGlobal(
@@ -1262,12 +1261,10 @@ static MCSectionWasm *selectWasmSectionForGlobal(
bool UniqueSectionNames = TM.getUniqueSectionNames();
SmallString<128> Name = getSectionPrefixForGlobal(Kind);
uint32_t Type = wasm::WASM_SEC_DATA;
if (const auto *F = dyn_cast<Function>(GO)) {
const auto &OptionalPrefix = F->getSectionPrefix();
if (OptionalPrefix)
Name += *OptionalPrefix;
Type = wasm::WASM_SEC_CODE;
}
if (EmitUniqueSection && UniqueSectionNames) {
@@ -1279,7 +1276,7 @@ static MCSectionWasm *selectWasmSectionForGlobal(
UniqueID = *NextUniqueID;
(*NextUniqueID)++;
}
return Ctx.getWasmSection(Name, Type, Group, UniqueID);
return Ctx.getWasmSection(Name, Kind, Group, UniqueID);
}
MCSection *TargetLoweringObjectFileWasm::SelectSectionForGlobal(
@@ -1330,7 +1327,7 @@ const MCExpr *TargetLoweringObjectFileWasm::lowerRelativeReference(
void TargetLoweringObjectFileWasm::InitializeWasm() {
StaticCtorSection =
getContext().getWasmSection(".init_array", wasm::WASM_SEC_DATA);
getContext().getWasmSection(".init_array", SectionKind::getData());
StaticDtorSection =
getContext().getWasmSection(".fini_array", wasm::WASM_SEC_DATA);
getContext().getWasmSection(".fini_array", SectionKind::getData());
}