Skip to content

Commit

Permalink
Track the compact unwind encoding for when we are unable to generate …
Browse files Browse the repository at this point in the history
…compact unwind information.

Compact unwind has an encoding for when we're not able to generate compact
unwind and must generate an EH frame instead. Track that, but still emit that CU
encoding.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179220 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
isanbard committed Apr 10, 2013
1 parent 49bbb35 commit 62c75ad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
11 changes: 10 additions & 1 deletion include/llvm/MC/MCObjectFileInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ class MCObjectFileInfo {
unsigned FDEEncoding;
unsigned FDECFIEncoding;
unsigned TTypeEncoding;
// Section flags for eh_frame

/// Section flags for eh_frame
unsigned EHSectionType;
unsigned EHSectionFlags;

/// CompactUnwindDwarfEHFrameOnly - Compact unwind encoding indicating that we
/// should emit only an EH frame.
unsigned CompactUnwindDwarfEHFrameOnly;

/// TextSection - Section directive for standard text.
///
const MCSection *TextSection;
Expand Down Expand Up @@ -201,6 +206,10 @@ class MCObjectFileInfo {
}
unsigned getTTypeEncoding() const { return TTypeEncoding; }

unsigned getCompactUnwindDwarfEHFrameOnly() const {
return CompactUnwindDwarfEHFrameOnly;
}

const MCSection *getTextSection() const { return TextSection; }
const MCSection *getDataSection() const { return DataSection; }
const MCSection *getBSSSection() const { return BSSSection; }
Expand Down
9 changes: 4 additions & 5 deletions lib/MC/MCDwarf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,10 +1168,10 @@ bool FrameEmitterImpl::EmitCompactUnwind(MCStreamer &Streamer,
// .quad except_tab1

uint32_t Encoding = Frame.CompactUnwindEncoding;
if (!Encoding) return false;
bool DwarfEHFrameOnly = (Encoding == MOFI->getCompactUnwindDwarfEHFrameOnly());

// The encoding needs to know we have an LSDA.
if (Frame.Lsda)
if (!DwarfEHFrameOnly && Frame.Lsda)
Encoding |= 0x40000000;

Streamer.SwitchSection(MOFI->getCompactUnwindSection());
Expand All @@ -1194,19 +1194,18 @@ bool FrameEmitterImpl::EmitCompactUnwind(MCStreamer &Streamer,
Twine::utohexstr(Encoding));
Streamer.EmitIntValue(Encoding, Size);


// Personality Function
Size = getSizeForEncoding(Streamer, dwarf::DW_EH_PE_absptr);
if (VerboseAsm) Streamer.AddComment("Personality Function");
if (Frame.Personality)
if (!DwarfEHFrameOnly && Frame.Personality)
Streamer.EmitSymbolValue(Frame.Personality, Size);
else
Streamer.EmitIntValue(0, Size); // No personality fn

// LSDA
Size = getSizeForEncoding(Streamer, Frame.LsdaEncoding);
if (VerboseAsm) Streamer.AddComment("LSDA");
if (Frame.Lsda)
if (!DwarfEHFrameOnly && Frame.Lsda)
Streamer.EmitSymbolValue(Frame.Lsda, Size);
else
Streamer.EmitIntValue(0, Size); // No LSDA
Expand Down
8 changes: 7 additions & 1 deletion lib/MC/MCObjectFileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,16 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
SectionKind::getReadOnlyWithRel());

if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6))
if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6)) {
CompactUnwindSection =
Ctx->getMachOSection("__LD", "__compact_unwind",
MCSectionMachO::S_ATTR_DEBUG,
SectionKind::getReadOnly());

if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
CompactUnwindDwarfEHFrameOnly = 0x04000000;
}

// Debug Information.
DwarfAccelNamesSection =
Ctx->getMachOSection("__DWARF", "__apple_names",
Expand Down Expand Up @@ -629,6 +633,8 @@ void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding =
TTypeEncoding = dwarf::DW_EH_PE_absptr;

CompactUnwindDwarfEHFrameOnly = 0;

EHFrameSection = 0; // Created on demand.
CompactUnwindSection = 0; // Used only by selected targets.
DwarfAccelNamesSection = 0; // Used only by selected targets.
Expand Down

0 comments on commit 62c75ad

Please sign in to comment.