28 lines
563 B
C
28 lines
563 B
C
#include "tcc/io.h"
|
|
#include <string.h>
|
|
#include <tcc/state.h>
|
|
#include <tcc/memory.h>
|
|
#include <tcc/object.h>
|
|
#include <tcc/object/archive.h>
|
|
#include <tcc/object/coff.h>
|
|
|
|
int
|
|
tcc_object_type(int fd, COFFFileHeader *h)
|
|
{
|
|
ssize_t size;
|
|
|
|
size = full_read(fd, h, sizeof(COFFFileHeader));
|
|
if (size == sizeof(COFFFileHeader)
|
|
&& h->magic == COFF_MAGIC
|
|
&& (h->flags & COFF_F_EXEC) == 0)
|
|
{
|
|
return (TCC_BINTYPE_COFF);
|
|
}
|
|
else if (size >= 8
|
|
&& memcmp(h, ARCHIVE_MAGIC, ARCHIVE_MAGSZ) == 0)
|
|
{
|
|
return (TCC_BINTYPE_ARCHIVE);
|
|
}
|
|
|
|
return (TCC_BINTYPE_NONE);
|
|
}
|