mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Pass the computed magic to createBinary and createObjectFile if available.
identify_magic is not free, so we should avoid calling it twice. The argument also makes it cheap for createBinary to just forward to createObjectFile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199813 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -37,9 +37,11 @@ section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const {
|
||||
return section_iterator(SectionRef(Sec, this));
|
||||
}
|
||||
|
||||
ErrorOr<ObjectFile *> ObjectFile::createObjectFile(MemoryBuffer *Object) {
|
||||
ErrorOr<ObjectFile *> ObjectFile::createObjectFile(MemoryBuffer *Object,
|
||||
sys::fs::file_magic Type) {
|
||||
OwningPtr<MemoryBuffer> ScopedObj(Object);
|
||||
sys::fs::file_magic Type = sys::fs::identify_magic(Object->getBuffer());
|
||||
if (Type == sys::fs::file_magic::unknown)
|
||||
Type = sys::fs::identify_magic(Object->getBuffer());
|
||||
|
||||
switch (Type) {
|
||||
case sys::fs::file_magic::unknown:
|
||||
|
Reference in New Issue
Block a user