Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions llvm/include/llvm/Object/DXContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,16 +605,12 @@ class DXContainerObjectFile : public ObjectFile {
public:
static bool classof(const Binary *v) { return v->isDXContainer(); }

Expected<StringRef> getSymbolName(DataRefImpl) const override { return ""; }
Expected<StringRef> getSymbolName(DataRefImpl) const override;
Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override { return 0; }
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override {
return 0;
}
Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override {
return SymbolRef::Type::ST_Unknown;
}
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;

Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
void moveSectionNext(DataRefImpl &Sec) const override;
Expected<StringRef> getSectionName(DataRefImpl Sec) const override;
Expand Down Expand Up @@ -651,16 +647,14 @@ class DXContainerObjectFile : public ObjectFile {

void moveSymbolNext(DataRefImpl &Symb) const override {}
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;
Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override {
return 0;
}
Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
basic_symbol_iterator symbol_begin() const override {
return basic_symbol_iterator(SymbolRef());
}
basic_symbol_iterator symbol_end() const override {
return basic_symbol_iterator(SymbolRef());
}
bool is64Bit() const override { return 0; }
bool is64Bit() const override { return false; }

bool isRelocatableObject() const override { return false; }
};
Expand Down
34 changes: 30 additions & 4 deletions llvm/lib/Object/DXContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,28 @@ DXContainerObjectFile::getSymbolSection(DataRefImpl Symb) const {
return make_error<DXNotSupportedError>("Symbol sections");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should all be lower-case 's' for "Symbol".

}

Expected<StringRef> DXContainerObjectFile::getSymbolName(DataRefImpl) const {
return make_error<DXNotSupportedError>("Symbol names");
}

Expected<uint64_t>
DXContainerObjectFile::getSymbolAddress(DataRefImpl Symb) const {
return make_error<DXNotSupportedError>("Symbol addresses");
}

uint64_t DXContainerObjectFile::getSymbolValueImpl(DataRefImpl Symb) const {
llvm_unreachable("DXContainer does not support symbols");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogner @llvm-beanz I think the DXContainerObjectFile should present as if it had empty symbol and relocation tables, rather than making these operations unreachable.

From a design perspective you should be able to iterate over the set of symbols and relocations in an object file, and empty sets are perfectly legal.

As a practical matter presenting empty sets will allow llvm-objdump -r and llvm-objdump -t to behave sensibly, whereas unreachable will cause them to crash.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think what you're saying here is in conflict to having llvm_unreachable here. With this patch llvm-objdump -r produces the output:

>bin/llvm-objdump -r part-headers.yaml.tmp

:       file format directx container

and llvm-objdump -t produces:

> bin/llvm-objdump -t part-headers.yaml.tmp

:       file format directx container

SYMBOL TABLE:

The iterators are implemented and all effectively return end iterators so that the result is an empty set. The only way you'd really hit these unreachable is if you tried to access or increment one of the iterators, and since they would be invalid, that would always be a logic error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're totally right. My bad!

LGTM. :)

}
uint64_t
DXContainerObjectFile::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
llvm_unreachable("DXContainer does not support symbols");
}

Expected<SymbolRef::Type>
DXContainerObjectFile::getSymbolType(DataRefImpl Symb) const {
return make_error<DXNotSupportedError>("Symbol types");
}

void DXContainerObjectFile::moveSectionNext(DataRefImpl &Sec) const {
PartIterator It = reinterpret_cast<PartIterator>(Sec.p);
if (It == Parts.end())
Expand Down Expand Up @@ -616,10 +633,12 @@ DXContainerObjectFile::section_rel_end(DataRefImpl Sec) const {
return relocation_iterator(RelocationRef());
}

void DXContainerObjectFile::moveRelocationNext(DataRefImpl &Rel) const {}
void DXContainerObjectFile::moveRelocationNext(DataRefImpl &Rel) const {
llvm_unreachable("DXContainer does not support relocations");
}

uint64_t DXContainerObjectFile::getRelocationOffset(DataRefImpl Rel) const {
return 0;
llvm_unreachable("DXContainer does not support relocations");
}

symbol_iterator
Expand All @@ -628,11 +647,13 @@ DXContainerObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
}

uint64_t DXContainerObjectFile::getRelocationType(DataRefImpl Rel) const {
return 0;
llvm_unreachable("DXContainer does not support relocations");
}

void DXContainerObjectFile::getRelocationTypeName(
DataRefImpl Rel, SmallVectorImpl<char> &Result) const {}
DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
llvm_unreachable("DXContainer does not support relocations");
}

section_iterator DXContainerObjectFile::section_begin() const {
DataRefImpl Sec;
Expand Down Expand Up @@ -662,6 +683,11 @@ Error DXContainerObjectFile::printSymbolName(raw_ostream &OS,
return make_error<DXNotSupportedError>("Symbol names");
}

Expected<uint32_t>
DXContainerObjectFile::getSymbolFlags(DataRefImpl Symb) const {
return make_error<DXNotSupportedError>("Symbol flags");
}

Expected<std::unique_ptr<DXContainerObjectFile>>
ObjectFile::createDXContainerObjectFile(MemoryBufferRef Object) {
auto ExC = DXContainer::create(Object);
Expand Down