Skip to content

Commit

Permalink
#8 ELF file header
Browse files Browse the repository at this point in the history
  • Loading branch information
amosshi committed Jun 22, 2020
1 parent 79c41e1 commit 87e2418
Show file tree
Hide file tree
Showing 15 changed files with 694 additions and 299 deletions.
152 changes: 152 additions & 0 deletions FormatELF/src/main/java/org/freeinternals/format/elf/Elf64Type.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*
* Elf64Type.java June 21, 2020
*
* Copyright 2020, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
*/
package org.freeinternals.format.elf;

import java.math.BigInteger;

/**
* 64-bit ELF base types.
*
* <pre>
* typedef __u64 Elf64_Addr;
* typedef __u16 Elf64_Half;
* typedef __s16 Elf64_SHalf;
* typedef __u64 Elf64_Off;
* typedef __s32 Elf64_Sword;
* typedef __u32 Elf64_Word;
* typedef __u64 Elf64_Xword;
* typedef __s64 Elf64_Sxword;
* </pre>
*
* @author Amos Shi
* @see
* <a href="https://github.com/torvalds/linux/blob/master/include/uapi/linux/elf.h">include/uapi/linux/elf.h</a>
*/
public class Elf64Type {

/**
* <code>typedef __u64 Elf64_Addr;</code>.
*/
public static class Elf64_Addr {

/**
* Binary data length in bytes.
*/
public static final int LENGTH = 8;
public final BigInteger value;

Elf64_Addr(BigInteger big) {
this.value = big;
}
}

/**
* <code>typedef __u16 Elf64_Half;</code>.
*/
public static class Elf64_Half {
/**
* Binary data length in bytes.
*/
public static final int LENGTH = 2;
public final int value;

Elf64_Half(int i) {
this.value = i;
}
}

/**
* <code>typedef __u64 Elf64_Off;</code>.
*/
public static class Elf64_Off {
/**
* Binary data length in bytes.
*/
public static final int LENGTH = 8;
public final BigInteger value;

Elf64_Off(BigInteger big) {
this.value = big;
}
}

/**
* <code>typedef __s16 Elf64_SHalf;</code>.
*/
public static class Elf64_SHalf {
/**
* Binary data length in bytes.
*/
public static final int LENGTH = 2;
public final short value;

Elf64_SHalf(short s) {
this.value = s;
}
}

/**
* <code>typedef __s32 Elf64_Sword;</code>.
*/
public static class Elf64_Sword {
/**
* Binary data length in bytes.
*/
public static final int LENGTH = 4;
public final int value;

Elf64_Sword(int i) {
this.value = i;
}
}

/**
* <code>typedef __s64 Elf64_Sxword;</code>.
*/
public static class Elf64_Sxword {
/**
* Binary data length in bytes.
*/
public static final int LENGTH = 8;
public final long value;

Elf64_Sxword(long l) {
this.value = l;
}
}

/**
* <code>typedef __u32 Elf64_Word;</code>.
*/
public static class Elf64_Word {
/**
* Binary data length in bytes.
*/
public static final int LENGTH = 4;
public final long value;

Elf64_Word(long l) {
this.value = l;
}
}

/**
* <code>typedef __u64 Elf64_Xword;</code>.
*/
public static class Elf64_Xword {
/**
* Binary data length in bytes.
*/
public static final int LENGTH = 8;
public final BigInteger value;

Elf64_Xword(BigInteger big) {
this.value = big;
}
}

}

This file was deleted.

Loading

0 comments on commit 87e2418

Please sign in to comment.