<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">ping? This wasn’t just an idle question. I really don’t like this change unless there’s a real need for it.<div><br></div><div><br><div><div><div>On Apr 8, 2013, at 2:58 PM, Jim Grosbach <<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Why do this? The resultant code is less readable to me, replacing an explicit “64” in the type name with a “true” that I have to go look at the template definition to find the meaning of.<div><br></div><div>-Jim</div><div><br><div><div>On Apr 8, 2013, at 1:45 PM, Rafael Espindola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Author: rafael<br>Date: Mon Apr 8 15:45:01 2013<br>New Revision: 179051<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=179051&view=rev">http://llvm.org/viewvc/llvm-project?rev=179051&view=rev</a><br>Log:<br>Template the MachO types over the word size.<br><br>Modified:<br> llvm/trunk/include/llvm/Object/MachO.h<br> llvm/trunk/lib/Object/MachOObjectFile.cpp<br> llvm/trunk/tools/llvm-readobj/MachODumper.cpp<br><br>Modified: llvm/trunk/include/llvm/Object/MachO.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=179051&r1=179050&r2=179051&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=179051&r1=179050&r2=179051&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/Object/MachO.h (original)<br>+++ llvm/trunk/include/llvm/Object/MachO.h Mon Apr 8 15:45:01 2013<br>@@ -27,7 +27,11 @@ namespace llvm {<br>namespace object {<br><br>namespace MachOFormat {<br>- struct Section {<br>+ template<bool is64Bits><br>+ struct Section;<br>+<br>+ template<><br>+ struct Section<false> {<br> char Name[16];<br> char SegmentName[16];<br> support::ulittle32_t Address;<br>@@ -41,7 +45,8 @@ namespace MachOFormat {<br> support::ulittle32_t Reserved2;<br> };<br><br>- struct Section64 {<br>+ template<><br>+ struct Section<true> {<br> char Name[16];<br> char SegmentName[16];<br> support::ulittle64_t Address;<br>@@ -61,7 +66,11 @@ namespace MachOFormat {<br> support::ulittle32_t Word1;<br> };<br><br>- struct SymbolTableEntry {<br>+ template<bool is64Bits><br>+ struct SymbolTableEntry;<br>+<br>+ template<><br>+ struct SymbolTableEntry<false> {<br> support::ulittle32_t StringIndex;<br> uint8_t Type;<br> uint8_t SectionIndex;<br>@@ -69,7 +78,8 @@ namespace MachOFormat {<br> support::ulittle32_t Value;<br> };<br><br>- struct Symbol64TableEntry {<br>+ template<><br>+ struct SymbolTableEntry<true> {<br> support::ulittle32_t StringIndex;<br> uint8_t Type;<br> uint8_t SectionIndex;<br>@@ -91,7 +101,11 @@ namespace MachOFormat {<br> support::ulittle32_t StringTableSize;<br> };<br><br>- struct SegmentLoadCommand {<br>+ template<bool is64Bits><br>+ struct SegmentLoadCommand;<br>+<br>+ template<><br>+ struct SegmentLoadCommand<false> {<br> support::ulittle32_t Type;<br> support::ulittle32_t Size;<br> char Name[16];<br>@@ -105,7 +119,8 @@ namespace MachOFormat {<br> support::ulittle32_t Flags;<br> };<br><br>- struct Segment64LoadCommand {<br>+ template<><br>+ struct SegmentLoadCommand<true> {<br> support::ulittle32_t Type;<br> support::ulittle32_t Size;<br> char Name[16];<br>@@ -165,11 +180,11 @@ public:<br> ArrayRef<char> getSectionRawName(DataRefImpl Sec) const;<br> ArrayRef<char>getSectionRawFinalSegmentName(DataRefImpl Sec) const;<br><br>- const MachOFormat::Section64 *getSection64(DataRefImpl DRI) const;<br>- const MachOFormat::Section *getSection(DataRefImpl DRI) const;<br>- const MachOFormat::Symbol64TableEntry *<br>+ const MachOFormat::Section<true> *getSection64(DataRefImpl DRI) const;<br>+ const MachOFormat::Section<false> *getSection(DataRefImpl DRI) const;<br>+ const MachOFormat::SymbolTableEntry<true> *<br> getSymbol64TableEntry(DataRefImpl DRI) const;<br>- const MachOFormat::SymbolTableEntry *<br>+ const MachOFormat::SymbolTableEntry<false> *<br> getSymbolTableEntry(DataRefImpl DRI) const;<br> bool is64Bit() const;<br> const MachOFormat::LoadCommand *getLoadCommandInfo(unsigned Index) const;<br>@@ -242,11 +257,11 @@ private:<br><br> void moveToNextSection(DataRefImpl &DRI) const;<br><br>- const MachOFormat::SymbolTableEntry *<br>+ const MachOFormat::SymbolTableEntry<false> *<br> getSymbolTableEntry(DataRefImpl DRI,<br> const MachOFormat::SymtabLoadCommand *SymtabLoadCmd) const;<br><br>- const MachOFormat::Symbol64TableEntry *<br>+ const MachOFormat::SymbolTableEntry<true> *<br> getSymbol64TableEntry(DataRefImpl DRI,<br> const MachOFormat::SymtabLoadCommand *SymtabLoadCmd) const;<br><br><br>Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=179051&r1=179050&r2=179051&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=179051&r1=179050&r2=179051&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)<br>+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Mon Apr 8 15:45:01 2013<br>@@ -116,7 +116,7 @@ void MachOObjectFile::moveToNextSymbol(D<br> }<br>}<br><br>-const MachOFormat::SymbolTableEntry *<br>+const MachOFormat::SymbolTableEntry<false> *<br>MachOObjectFile::getSymbolTableEntry(DataRefImpl DRI) const {<br> const MachOFormat::LoadCommand *Command = getLoadCommandInfo(DRI.d.a);<br> const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =<br>@@ -125,18 +125,20 @@ MachOObjectFile::getSymbolTableEntry(Dat<br> return getSymbolTableEntry(DRI, SymtabLoadCmd);<br>}<br><br>-const MachOFormat::SymbolTableEntry *<br>+const MachOFormat::SymbolTableEntry<false> *<br>MachOObjectFile::getSymbolTableEntry(DataRefImpl DRI,<br> const MachOFormat::SymtabLoadCommand *SymtabLoadCmd) const {<br> uint64_t SymbolTableOffset = SymtabLoadCmd->SymbolTableOffset;<br> unsigned Index = DRI.d.b;<br> uint64_t Offset = (SymbolTableOffset +<br>- Index * sizeof(macho::SymbolTableEntry));<br>- StringRef Data = getData(Offset, sizeof(MachOFormat::SymbolTableEntry));<br>- return reinterpret_cast<const MachOFormat::SymbolTableEntry*>(Data.data());<br>+ Index * sizeof(MachOFormat::SymbolTableEntry<false>));<br>+ StringRef Data =<br>+ getData(Offset, sizeof(MachOFormat::SymbolTableEntry<false>));<br>+ return<br>+ reinterpret_cast<const MachOFormat::SymbolTableEntry<false>*>(Data.data());<br>}<br><br>-const MachOFormat::Symbol64TableEntry*<br>+const MachOFormat::SymbolTableEntry<true>*<br>MachOObjectFile::getSymbol64TableEntry(DataRefImpl DRI) const {<br> const MachOFormat::LoadCommand *Command = getLoadCommandInfo(DRI.d.a);<br> const MachOFormat::SymtabLoadCommand *SymtabLoadCmd =<br>@@ -145,15 +147,16 @@ MachOObjectFile::getSymbol64TableEntry(D<br> return getSymbol64TableEntry(DRI, SymtabLoadCmd);<br>}<br><br>-const MachOFormat::Symbol64TableEntry*<br>+const MachOFormat::SymbolTableEntry<true>*<br>MachOObjectFile::getSymbol64TableEntry(DataRefImpl DRI,<br> const MachOFormat::SymtabLoadCommand *SymtabLoadCmd) const {<br> uint64_t SymbolTableOffset = SymtabLoadCmd->SymbolTableOffset;<br> unsigned Index = DRI.d.b;<br> uint64_t Offset = (SymbolTableOffset +<br>- Index * sizeof(macho::Symbol64TableEntry));<br>- StringRef Data = getData(Offset, sizeof(MachOFormat::Symbol64TableEntry));<br>- return reinterpret_cast<const MachOFormat::Symbol64TableEntry*>(Data.data());<br>+ Index * sizeof(MachOFormat::SymbolTableEntry<true>));<br>+ StringRef Data = getData(Offset, sizeof(MachOFormat::SymbolTableEntry<true>));<br>+ return<br>+ reinterpret_cast<const MachOFormat::SymbolTableEntry<true>*>(Data.data());<br>}<br><br>error_code MachOObjectFile::getSymbolNext(DataRefImpl DRI,<br>@@ -175,11 +178,11 @@ error_code MachOObjectFile::getSymbolNam<br><br> uint32_t StringIndex;<br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry =<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br> getSymbol64TableEntry(DRI, SymtabLoadCmd);<br> StringIndex = Entry->StringIndex;<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry =<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br> getSymbolTableEntry(DRI, SymtabLoadCmd);<br> StringIndex = Entry->StringIndex;<br> }<br>@@ -193,18 +196,20 @@ error_code MachOObjectFile::getSymbolNam<br>error_code MachOObjectFile::getSymbolFileOffset(DataRefImpl DRI,<br> uint64_t &Result) const {<br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry = getSymbol64TableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ getSymbol64TableEntry(DRI);<br> Result = Entry->Value;<br> if (Entry->SectionIndex) {<br>- const MachOFormat::Section64 *Section =<br>+ const MachOFormat::Section<true> *Section =<br> getSection64(Sections[Entry->SectionIndex-1]);<br> Result += Section->Offset - Section->Address;<br> }<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = getSymbolTableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ getSymbolTableEntry(DRI);<br> Result = Entry->Value;<br> if (Entry->SectionIndex) {<br>- const MachOFormat::Section *Section =<br>+ const MachOFormat::Section<false> *Section =<br> getSection(Sections[Entry->SectionIndex-1]);<br> Result += Section->Offset - Section->Address;<br> }<br>@@ -216,10 +221,12 @@ error_code MachOObjectFile::getSymbolFil<br>error_code MachOObjectFile::getSymbolAddress(DataRefImpl DRI,<br> uint64_t &Result) const {<br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry = getSymbol64TableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ getSymbol64TableEntry(DRI);<br> Result = Entry->Value;<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = getSymbolTableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ getSymbolTableEntry(DRI);<br> Result = Entry->Value;<br> }<br> return object_error::success;<br>@@ -232,7 +239,8 @@ error_code MachOObjectFile::getSymbolSiz<br> uint64_t EndOffset = 0;<br> uint8_t SectionIndex;<br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry = getSymbol64TableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ getSymbol64TableEntry(DRI);<br> BeginOffset = Entry->Value;<br> SectionIndex = Entry->SectionIndex;<br> if (!SectionIndex) {<br>@@ -259,7 +267,8 @@ error_code MachOObjectFile::getSymbolSiz<br> DRI.d.b++;<br> }<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = getSymbolTableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ getSymbolTableEntry(DRI);<br> BeginOffset = Entry->Value;<br> SectionIndex = Entry->SectionIndex;<br> if (!SectionIndex) {<br>@@ -300,11 +309,13 @@ error_code MachOObjectFile::getSymbolNMT<br> char &Result) const {<br> uint8_t Type, Flags;<br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry = getSymbol64TableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ getSymbol64TableEntry(DRI);<br> Type = Entry->Type;<br> Flags = Entry->Flags;<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = getSymbolTableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ getSymbolTableEntry(DRI);<br> Type = Entry->Type;<br> Flags = Entry->Flags;<br> }<br>@@ -334,11 +345,13 @@ error_code MachOObjectFile::getSymbolFla<br> uint16_t MachOFlags;<br> uint8_t MachOType;<br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry = getSymbol64TableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ getSymbol64TableEntry(DRI);<br> MachOFlags = Entry->Flags;<br> MachOType = Entry->Type;<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = getSymbolTableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ getSymbolTableEntry(DRI);<br> MachOFlags = Entry->Flags;<br> MachOType = Entry->Type;<br> }<br>@@ -371,10 +384,12 @@ error_code MachOObjectFile::getSymbolSec<br> section_iterator &Res) const {<br> uint8_t index;<br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry = getSymbol64TableEntry(Symb);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ getSymbol64TableEntry(Symb);<br> index = Entry->SectionIndex;<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = getSymbolTableEntry(Symb);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ getSymbolTableEntry(Symb);<br> index = Entry->SectionIndex;<br> }<br><br>@@ -390,10 +405,12 @@ error_code MachOObjectFile::getSymbolTyp<br> SymbolRef::Type &Res) const {<br> uint8_t n_type;<br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry = getSymbol64TableEntry(Symb);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ getSymbol64TableEntry(Symb);<br> n_type = Entry->Type;<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = getSymbolTableEntry(Symb);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ getSymbolTableEntry(Symb);<br> n_type = Entry->Type;<br> }<br> Res = SymbolRef::ST_Other;<br>@@ -465,14 +482,14 @@ void MachOObjectFile::moveToNextSection(<br> while (DRI.d.a < LoadCommandCount) {<br> const MachOFormat::LoadCommand *Command = getLoadCommandInfo(DRI.d.a);<br> if (Command->Type == macho::LCT_Segment) {<br>- const MachOFormat::SegmentLoadCommand *SegmentLoadCmd =<br>- reinterpret_cast<const MachOFormat::SegmentLoadCommand*>(Command);<br>+ const MachOFormat::SegmentLoadCommand<false> *SegmentLoadCmd =<br>+ reinterpret_cast<const MachOFormat::SegmentLoadCommand<false>*>(Command);<br> if (DRI.d.b < SegmentLoadCmd->NumSections)<br> return;<br> } else if (Command->Type == macho::LCT_Segment64) {<br>- const MachOFormat::Segment64LoadCommand *Segment64LoadCmd =<br>- reinterpret_cast<const MachOFormat::Segment64LoadCommand*>(Command);<br>- if (DRI.d.b < Segment64LoadCmd->NumSections)<br>+ const MachOFormat::SegmentLoadCommand<true> *SegmentLoadCmd =<br>+ reinterpret_cast<const MachOFormat::SegmentLoadCommand<true>*>(Command);<br>+ if (DRI.d.b < SegmentLoadCmd->NumSections)<br> return;<br> }<br><br>@@ -489,13 +506,14 @@ error_code MachOObjectFile::getSectionNe<br> return object_error::success;<br>}<br><br>-const MachOFormat::Section *MachOObjectFile::getSection(DataRefImpl DRI) const {<br>+const MachOFormat::Section<false> *<br>+MachOObjectFile::getSection(DataRefImpl DRI) const {<br> assert(!is64Bit());<br> const MachOFormat::LoadCommand *Command = getLoadCommandInfo(DRI.d.a);<br> uintptr_t CommandAddr = reinterpret_cast<uintptr_t>(Command);<br> uintptr_t SectionAddr = CommandAddr + sizeof(macho::SegmentLoadCommand) +<br>- DRI.d.b * sizeof(MachOFormat::Section);<br>- return reinterpret_cast<const MachOFormat::Section*>(SectionAddr);<br>+ DRI.d.b * sizeof(MachOFormat::Section<false>);<br>+ return reinterpret_cast<const MachOFormat::Section<false>*>(SectionAddr);<br>}<br><br>std::size_t MachOObjectFile::getSectionIndex(DataRefImpl Sec) const {<br>@@ -505,14 +523,14 @@ std::size_t MachOObjectFile::getSectionI<br> return std::distance(Sections.begin(), loc);<br>}<br><br>-const MachOFormat::Section64 *<br>+const MachOFormat::Section<true> *<br>MachOObjectFile::getSection64(DataRefImpl DRI) const {<br> assert(is64Bit());<br> const MachOFormat::LoadCommand *Command = getLoadCommandInfo(DRI.d.a);<br> uintptr_t CommandAddr = reinterpret_cast<uintptr_t>(Command);<br> uintptr_t SectionAddr = CommandAddr + sizeof(macho::Segment64LoadCommand) +<br>- DRI.d.b * sizeof(MachOFormat::Section64);<br>- return reinterpret_cast<const MachOFormat::Section64*>(SectionAddr);<br>+ DRI.d.b * sizeof(MachOFormat::Section<true>);<br>+ return reinterpret_cast<const MachOFormat::Section<true>*>(SectionAddr);<br>}<br><br>static StringRef parseSegmentOrSectionName(const char *P) {<br>@@ -525,10 +543,10 @@ static StringRef parseSegmentOrSectionNa<br><br>ArrayRef<char> MachOObjectFile::getSectionRawName(DataRefImpl DRI) const {<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *sec = getSection64(DRI);<br>+ const MachOFormat::Section<true> *sec = getSection64(DRI);<br> return ArrayRef<char>(sec->Name);<br> } else {<br>- const MachOFormat::Section *sec = getSection(DRI);<br>+ const MachOFormat::Section<false> *sec = getSection(DRI);<br> return ArrayRef<char>(sec->Name);<br> }<br>}<br>@@ -543,10 +561,10 @@ error_code MachOObjectFile::getSectionNa<br>ArrayRef<char><br>MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const {<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *sec = getSection64(Sec);<br>+ const MachOFormat::Section<true> *sec = getSection64(Sec);<br> return ArrayRef<char>(sec->SegmentName, 16);<br> } else {<br>- const MachOFormat::Section *sec = getSection(Sec);<br>+ const MachOFormat::Section<false> *sec = getSection(Sec);<br> return ArrayRef<char>(sec->SegmentName);<br> }<br>}<br>@@ -559,10 +577,10 @@ StringRef MachOObjectFile::getSectionFin<br>error_code MachOObjectFile::getSectionAddress(DataRefImpl DRI,<br> uint64_t &Result) const {<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(DRI);<br>+ const MachOFormat::Section<true> *Sect = getSection64(DRI);<br> Result = Sect->Address;<br> } else {<br>- const MachOFormat::Section *Sect = getSection(DRI);<br>+ const MachOFormat::Section<false> *Sect = getSection(DRI);<br> Result = Sect->Address;<br> }<br> return object_error::success;<br>@@ -571,10 +589,10 @@ error_code MachOObjectFile::getSectionAd<br>error_code MachOObjectFile::getSectionSize(DataRefImpl DRI,<br> uint64_t &Result) const {<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(DRI);<br>+ const MachOFormat::Section<true> *Sect = getSection64(DRI);<br> Result = Sect->Size;<br> } else {<br>- const MachOFormat::Section *Sect = getSection(DRI);<br>+ const MachOFormat::Section<false> *Sect = getSection(DRI);<br> Result = Sect->Size;<br> }<br> return object_error::success;<br>@@ -583,10 +601,10 @@ error_code MachOObjectFile::getSectionSi<br>error_code MachOObjectFile::getSectionContents(DataRefImpl DRI,<br> StringRef &Result) const {<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(DRI);<br>+ const MachOFormat::Section<true> *Sect = getSection64(DRI);<br> Result = getData(Sect->Offset, Sect->Size);<br> } else {<br>- const MachOFormat::Section *Sect = getSection(DRI);<br>+ const MachOFormat::Section<false> *Sect = getSection(DRI);<br> Result = getData(Sect->Offset, Sect->Size);<br> }<br> return object_error::success;<br>@@ -595,10 +613,10 @@ error_code MachOObjectFile::getSectionCo<br>error_code MachOObjectFile::getSectionAlignment(DataRefImpl DRI,<br> uint64_t &Result) const {<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(DRI);<br>+ const MachOFormat::Section<true> *Sect = getSection64(DRI);<br> Result = uint64_t(1) << Sect->Align;<br> } else {<br>- const MachOFormat::Section *Sect = getSection(DRI);<br>+ const MachOFormat::Section<false> *Sect = getSection(DRI);<br> Result = uint64_t(1) << Sect->Align;<br> }<br> return object_error::success;<br>@@ -607,10 +625,10 @@ error_code MachOObjectFile::getSectionAl<br>error_code MachOObjectFile::isSectionText(DataRefImpl DRI,<br> bool &Result) const {<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(DRI);<br>+ const MachOFormat::Section<true> *Sect = getSection64(DRI);<br> Result = Sect->Flags & macho::SF_PureInstructions;<br> } else {<br>- const MachOFormat::Section *Sect = getSection(DRI);<br>+ const MachOFormat::Section<false> *Sect = getSection(DRI);<br> Result = Sect->Flags & macho::SF_PureInstructions;<br> }<br> return object_error::success;<br>@@ -647,12 +665,12 @@ error_code MachOObjectFile::isSectionVir<br>error_code MachOObjectFile::isSectionZeroInit(DataRefImpl DRI,<br> bool &Result) const {<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(DRI);<br>+ const MachOFormat::Section<true> *Sect = getSection64(DRI);<br> unsigned SectionType = Sect->Flags & MachO::SectionFlagMaskSectionType;<br> Result = (SectionType == MachO::SectionTypeZeroFill ||<br> SectionType == MachO::SectionTypeZeroFillLarge);<br> } else {<br>- const MachOFormat::Section *Sect = getSection(DRI);<br>+ const MachOFormat::Section<false> *Sect = getSection(DRI);<br> unsigned SectionType = Sect->Flags & MachO::SectionFlagMaskSectionType;<br> Result = (SectionType == MachO::SectionTypeZeroFill ||<br> SectionType == MachO::SectionTypeZeroFillLarge);<br>@@ -688,11 +706,13 @@ error_code MachOObjectFile::sectionConta<br> SectEnd += SectBegin;<br><br> if (is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry = getSymbol64TableEntry(Symb);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ getSymbol64TableEntry(Symb);<br> uint64_t SymAddr= Entry->Value;<br> Result = (SymAddr >= SectBegin) && (SymAddr < SectEnd);<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = getSymbolTableEntry(Symb);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ getSymbolTableEntry(Symb);<br> uint64_t SymAddr= Entry->Value;<br> Result = (SymAddr >= SectBegin) && (SymAddr < SectEnd);<br> }<br>@@ -705,13 +725,14 @@ relocation_iterator MachOObjectFile::get<br> ret.d.b = getSectionIndex(Sec);<br> return relocation_iterator(RelocationRef(ret, this));<br>}<br>+<br>relocation_iterator MachOObjectFile::getSectionRelEnd(DataRefImpl Sec) const {<br> uint32_t last_reloc;<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(Sec);<br>+ const MachOFormat::Section<true> *Sect = getSection64(Sec);<br> last_reloc = Sect->NumRelocationTableEntries;<br> } else {<br>- const MachOFormat::Section *Sect = getSection(Sec);<br>+ const MachOFormat::Section<false> *Sect = getSection(Sec);<br> last_reloc = Sect->NumRelocationTableEntries;<br> }<br> DataRefImpl ret;<br>@@ -738,10 +759,10 @@ const MachOFormat::RelocationEntry *<br>MachOObjectFile::getRelocation(DataRefImpl Rel) const {<br> uint32_t relOffset;<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(Sections[Rel.d.b]);<br>+ const MachOFormat::Section<true> *Sect = getSection64(Sections[Rel.d.b]);<br> relOffset = Sect->RelocationTableOffset;<br> } else {<br>- const MachOFormat::Section *Sect = getSection(Sections[Rel.d.b]);<br>+ const MachOFormat::Section<false> *Sect = getSection(Sections[Rel.d.b]);<br> relOffset = Sect->RelocationTableOffset;<br> }<br> uint64_t Offset = relOffset + Rel.d.a * sizeof(MachOFormat::RelocationEntry);<br>@@ -759,10 +780,10 @@ error_code MachOObjectFile::getRelocatio<br> uint64_t &Res) const {<br> const uint8_t* sectAddress = 0;<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(Sections[Rel.d.b]);<br>+ const MachOFormat::Section<true> *Sect = getSection64(Sections[Rel.d.b]);<br> sectAddress += Sect->Address;<br> } else {<br>- const MachOFormat::Section *Sect = getSection(Sections[Rel.d.b]);<br>+ const MachOFormat::Section<false> *Sect = getSection(Sections[Rel.d.b]);<br> sectAddress += Sect->Address;<br> }<br> const MachOFormat::RelocationEntry *RE = getRelocation(Rel);<br>@@ -926,10 +947,10 @@ error_code MachOObjectFile::getRelocatio<br> if (!isExtern) {<br> const uint8_t* sectAddress = base();<br> if (is64Bit()) {<br>- const MachOFormat::Section64 *Sect = getSection64(Sections[Rel.d.b]);<br>+ const MachOFormat::Section<true> *Sect = getSection64(Sections[Rel.d.b]);<br> sectAddress += Sect->Offset;<br> } else {<br>- const MachOFormat::Section *Sect = getSection(Sections[Rel.d.b]);<br>+ const MachOFormat::Section<false> *Sect = getSection(Sections[Rel.d.b]);<br> sectAddress += Sect->Offset;<br> }<br> Res = reinterpret_cast<uintptr_t>(sectAddress);<br><br>Modified: llvm/trunk/tools/llvm-readobj/MachODumper.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/MachODumper.cpp?rev=179051&r1=179050&r2=179051&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/MachODumper.cpp?rev=179051&r1=179050&r2=179051&view=diff</a><br>==============================================================================<br>--- llvm/trunk/tools/llvm-readobj/MachODumper.cpp (original)<br>+++ llvm/trunk/tools/llvm-readobj/MachODumper.cpp Mon Apr 8 15:45:01 2013<br>@@ -161,7 +161,7 @@ static void getSection(const MachOObject<br> DataRefImpl DRI,<br> MachOSection &Section) {<br> if (Obj->is64Bit()) {<br>- const MachOFormat::Section64 *Sect = Obj->getSection64(DRI);<br>+ const MachOFormat::Section<true> *Sect = Obj->getSection64(DRI);<br><br> Section.Address = Sect->Address;<br> Section.Size = Sect->Size;<br>@@ -173,7 +173,7 @@ static void getSection(const MachOObject<br> Section.Reserved1 = Sect->Reserved1;<br> Section.Reserved2 = Sect->Reserved2;<br> } else {<br>- const MachOFormat::Section *Sect = Obj->getSection(DRI);<br>+ const MachOFormat::Section<false> *Sect = Obj->getSection(DRI);<br><br> Section.Address = Sect->Address;<br> Section.Size = Sect->Size;<br>@@ -191,15 +191,16 @@ static void getSymbol(const MachOObjectF<br> DataRefImpl DRI,<br> MachOSymbol &Symbol) {<br> if (Obj->is64Bit()) {<br>- const MachOFormat::Symbol64TableEntry *Entry =<br>- Obj->getSymbol64TableEntry( DRI);<br>+ const MachOFormat::SymbolTableEntry<true> *Entry =<br>+ Obj->getSymbol64TableEntry(DRI);<br> Symbol.StringIndex = Entry->StringIndex;<br> Symbol.Type = Entry->Type;<br> Symbol.SectionIndex = Entry->SectionIndex;<br> Symbol.Flags = Entry->Flags;<br> Symbol.Value = Entry->Value;<br> } else {<br>- const MachOFormat::SymbolTableEntry *Entry = Obj->getSymbolTableEntry(DRI);<br>+ const MachOFormat::SymbolTableEntry<false> *Entry =<br>+ Obj->getSymbolTableEntry(DRI);<br> Symbol.StringIndex = Entry->StringIndex;<br> Symbol.Type = Entry->Type;<br> Symbol.SectionIndex = Entry->SectionIndex;<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></div></body></html>