Search in sources :

Example 1 with ObjectFileReader

use of com.oracle.truffle.llvm.parser.filereader.ObjectFileReader in project graal by oracle.

the class CoffFile method getReaderAtVirtualAddress.

public ObjectFileReader getReaderAtVirtualAddress(int virtualAddress) {
    ImageSectionHeader section = lookupOffset(virtualAddress);
    ByteSequence sectionBytes = bytes.subSequence(section.pointerToRawData, section.pointerToRawData + section.sizeOfRawData);
    ObjectFileReader reader = new ObjectFileReader(sectionBytes, true);
    reader.setPosition(virtualAddress - section.virtualAddress);
    return reader;
}
Also used : ObjectFileReader(com.oracle.truffle.llvm.parser.filereader.ObjectFileReader) ByteSequence(org.graalvm.polyglot.io.ByteSequence)

Example 2 with ObjectFileReader

use of com.oracle.truffle.llvm.parser.filereader.ObjectFileReader in project graal by oracle.

the class PEFile method create.

public static PEFile create(ByteSequence bytes) {
    ObjectFileReader reader = new ObjectFileReader(bytes, true);
    short machine = reader.getShort();
    if (machine != IMAGE_DOS_SIGNATURE) {
        throw new LLVMParserException("Invalid MS DOS file!");
    }
    reader.setPosition(OFFSET_TO_PE_SIGNATURE);
    int peOffset = reader.getInt();
    reader.setPosition(peOffset);
    int reSignature = reader.getInt();
    if (reSignature != IMAGE_NT_SIGNATURE) {
        throw new LLVMParserException("No PE Signature found in MS DOS Executable!");
    }
    return new PEFile(CoffFile.create(bytes, reader));
}
Also used : ObjectFileReader(com.oracle.truffle.llvm.parser.filereader.ObjectFileReader) LLVMParserException(com.oracle.truffle.llvm.runtime.except.LLVMParserException)

Example 3 with ObjectFileReader

use of com.oracle.truffle.llvm.parser.filereader.ObjectFileReader in project graal by oracle.

the class Xar method create.

public static Xar create(ByteSequence bytes) {
    ObjectFileReader data = new ObjectFileReader(bytes, false);
    // magic
    data.getInt();
    XarHeader header = XarHeader.create(data);
    List<XarFile> files = TocParser.parse(data, header);
    ByteSequence heap = data.slice();
    return new Xar(header, files, heap);
}
Also used : ObjectFileReader(com.oracle.truffle.llvm.parser.filereader.ObjectFileReader) ByteSequence(org.graalvm.polyglot.io.ByteSequence)

Example 4 with ObjectFileReader

use of com.oracle.truffle.llvm.parser.filereader.ObjectFileReader in project graal by oracle.

the class PEFile method loadImportData.

private void loadImportData() {
    ObjectFileReader reader = getImportDataReader();
    importData = reader == null ? null : ImageImportData.create(coffFile, reader);
}
Also used : ObjectFileReader(com.oracle.truffle.llvm.parser.filereader.ObjectFileReader)

Aggregations

ObjectFileReader (com.oracle.truffle.llvm.parser.filereader.ObjectFileReader)4 ByteSequence (org.graalvm.polyglot.io.ByteSequence)2 LLVMParserException (com.oracle.truffle.llvm.runtime.except.LLVMParserException)1