~yujiri/compiler

6c5e1890b310bee3ff98e070dc43477f7882ff47 — Evin Yulo 10 months ago af2c60a
elf: remove unused program headers
1 files changed, 3 insertions(+), 57 deletions(-)

M elf.zig
M elf.zig => elf.zig +3 -57
@@ 42,62 42,8 @@ pub fn main() !void {
    // alignment
    try writer.writeIntNative(u64, 4096);

    // addr 0xb0: 3rd program header entry
    // segment type: auxiliary info
    try writer.writeIntNative(u32, 4);
    // strange flags
    try writer.writeIntNative(u32, 4);
    // offset of the segment in file image
    try writer.writeIntNative(u64, 0x158);
    // virtual addr of segment in memory
    try writer.writeIntNative(u64, 0x400158);
    // physical addr
    try writer.writeIntNative(u64, 0x400158);
    // size of segment in file image
    try writer.writeIntNative(u64, 48);
    // size of segment in memory
    try writer.writeIntNative(u64, 48);
    // alignment
    try writer.writeIntNative(u64, 8);

    // addr 0xe8: 4th program header entry
    // segment type: auxiliary info
    try writer.writeIntNative(u32, 4);
    // strange flags
    try writer.writeIntNative(u32, 4);
    // offset of the segment in file image
    try writer.writeIntNative(u64, 0x188);
    // virtual addr of segment in memory
    try writer.writeIntNative(u64, 0x400188);
    // physical addr
    try writer.writeIntNative(u64, 0x400188);
    // size of segment in file image
    try writer.writeIntNative(u64, 36);
    // size of segment in memory
    try writer.writeIntNative(u64, 36);
    // alignment
    try writer.writeIntNative(u64, 4);

    // addr 0x120: 5th program header entry
    // segment type: gnu property
    try writer.writeIntNative(u32, 0x6474e553);
    // strange flags
    try writer.writeIntNative(u32, 4);
    // offset of the segment in file
    try writer.writeIntNative(u64, 0x158);
    // virtual addr of segment in memory
    try writer.writeIntNative(u64, 0x400158);
    // physical addr
    try writer.writeIntNative(u64, 0x400158);
    // size of segment in file image
    try writer.writeIntNative(u64, 48);
    // size of segment in memory
    try writer.writeIntNative(u64, 48);
    // alignment
    try writer.writeIntNative(u64, 8);

    // addr 0x158: useless stuff
    try writer.writeByteNTimes(0, 3752);
    // useless filler
    try writer.writeByteNTimes(0, 3920);

    // addr: 0x1000: exe
    // mov 60 to rax


@@ 192,7 138,7 @@ pub fn writeElfHeader(writer: anytype) !void {
    // size of a program header entry
    try writer.writeIntNative(u16, 56);
    // number of program header entries
    try writer.writeIntNative(u16, 5);
    try writer.writeIntNative(u16, 2);
    // size of a section header entry
    try writer.writeIntNative(u16, 64);
    // number of section header entries