diff options
| author | Daniel Sanders <daniel.sanders@imgtec.com> | 2014-07-14 14:02:14 +0000 |
|---|---|---|
| committer | Daniel Sanders <daniel.sanders@imgtec.com> | 2014-07-14 14:02:14 +0000 |
| commit | 8e254166e1d23bc5a8430f83a23153782961b007 (patch) | |
| tree | eb612406f2e8250cb5803b9ef7e7c762d85f8012 /llvm/lib/Target | |
| parent | 7ddb0ab85f04f56371ae948052188d968725b8b7 (diff) | |
| download | bcm5719-llvm-8e254166e1d23bc5a8430f83a23153782961b007.tar.gz bcm5719-llvm-8e254166e1d23bc5a8430f83a23153782961b007.zip | |
[mips] Correct section alignments and EntrySizes for .bss, .text, .data, .reginfo, .MIPS.options, and .MIPS.abiflags
Summary:
.bss, .text, and .data are at least 16-byte aligned.
.reginfo is 4-byte aligned and has a 24-byte EntrySize.
.MIPS.abiflags has an 24-byte EntrySize.
.MIPS.options is 8-byte aligned and has 1-byte EntrySize.
Using a 1-byte EntrySize for .MIPS.options seems strange because the
records are neither 1-byte long nor fixed-length but this matches the value
that GAS emits.
Differential Revision: http://reviews.llvm.org/D4487
llvm-svn: 212939
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index fbe375b8964..45683e883ff 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -323,13 +323,30 @@ void MipsTargetELFStreamer::finish() { MCAssembler &MCA = getStreamer().getAssembler(); MCContext &Context = MCA.getContext(); MCStreamer &OS = getStreamer(); + const MCObjectFileInfo &OFI = *Context.getObjectFileInfo(); Triple T(STI.getTargetTriple()); uint64_t Features = STI.getFeatureBits(); + // .bss, .text and .data are always at least 16-byte aligned. + MCSectionData &TextSectionData = + MCA.getOrCreateSectionData(*OFI.getTextSection()); + MCSectionData &DataSectionData = + MCA.getOrCreateSectionData(*OFI.getDataSection()); + MCSectionData &BSSSectionData = + MCA.getOrCreateSectionData(*OFI.getBSSSection()); + + TextSectionData.setAlignment(std::max(16u, TextSectionData.getAlignment())); + DataSectionData.setAlignment(std::max(16u, DataSectionData.getAlignment())); + BSSSectionData.setAlignment(std::max(16u, BSSSectionData.getAlignment())); + if (T.isArch64Bit() && (Features & Mips::FeatureN64)) { - const MCSectionELF *Sec = Context.getELFSection( - ".MIPS.options", ELF::SHT_MIPS_OPTIONS, - ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, SectionKind::getMetadata()); + // The EntrySize value of 1 seems strange since the records are neither + // 1-byte long nor fixed length but it matches the value GAS emits. + const MCSectionELF *Sec = + Context.getELFSection(".MIPS.options", ELF::SHT_MIPS_OPTIONS, + ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, + SectionKind::getMetadata(), 1, ""); + MCA.getOrCreateSectionData(*Sec).setAlignment(8); OS.SwitchSection(Sec); OS.EmitIntValue(1, 1); // kind @@ -346,7 +363,8 @@ void MipsTargetELFStreamer::finish() { } else { const MCSectionELF *Sec = Context.getELFSection(".reginfo", ELF::SHT_MIPS_REGINFO, ELF::SHF_ALLOC, - SectionKind::getMetadata()); + SectionKind::getMetadata(), 24, ""); + MCA.getOrCreateSectionData(*Sec).setAlignment(4); OS.SwitchSection(Sec); OS.EmitIntValue(0, 4); // ri_gprmask @@ -638,7 +656,7 @@ void MipsTargetELFStreamer::emitMipsAbiFlags() { MCStreamer &OS = getStreamer(); const MCSectionELF *Sec = Context.getELFSection(".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, - ELF::SHF_ALLOC, SectionKind::getMetadata()); + ELF::SHF_ALLOC, SectionKind::getMetadata(), 24, ""); MCSectionData &ABIShndxSD = MCA.getOrCreateSectionData(*Sec); ABIShndxSD.setAlignment(8); OS.SwitchSection(Sec); |

