|
28 | 28 | #include "llvm/Object/Archive.h"
|
29 | 29 | #include "llvm/Object/ArchiveWriter.h"
|
30 | 30 | #include "llvm/Object/Binary.h"
|
| 31 | +#include "llvm/Object/ELFObjectFile.h" |
31 | 32 | #include "llvm/Object/IRObjectFile.h"
|
32 | 33 | #include "llvm/Object/ObjectFile.h"
|
33 | 34 | #include "llvm/Object/OffloadBinary.h"
|
@@ -339,9 +340,8 @@ Error extractOffloadFiles(MemoryBufferRef Contents,
|
339 | 340 | // Extract offloading binaries from an Object file \p Obj.
|
340 | 341 | Error extractFromBinary(const ObjectFile &Obj,
|
341 | 342 | SmallVectorImpl<OffloadFile> &DeviceFiles) {
|
342 |
| - for (const SectionRef &Sec : Obj.sections()) { |
343 |
| - Expected<StringRef> Name = Sec.getName(); |
344 |
| - if (!Name || !Name->equals(OFFLOAD_SECTION_MAGIC_STR)) |
| 343 | + for (ELFSectionRef Sec : Obj.sections()) { |
| 344 | + if (Sec.getType() != ELF::SHT_LLVM_OFFLOADING) |
345 | 345 | continue;
|
346 | 346 |
|
347 | 347 | Expected<StringRef> Buffer = Sec.getContents();
|
@@ -433,9 +433,7 @@ Error extractFromBuffer(std::unique_ptr<MemoryBuffer> Buffer,
|
433 | 433 | switch (Type) {
|
434 | 434 | case file_magic::bitcode:
|
435 | 435 | return extractFromBitcode(std::move(Buffer), DeviceFiles);
|
436 |
| - case file_magic::elf_relocatable: |
437 |
| - case file_magic::macho_object: |
438 |
| - case file_magic::coff_object: { |
| 436 | + case file_magic::elf_relocatable: { |
439 | 437 | Expected<std::unique_ptr<ObjectFile>> ObjFile =
|
440 | 438 | ObjectFile::createObjectFile(*Buffer, Type);
|
441 | 439 | if (!ObjFile)
|
|
0 commit comments