Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
katsyoshi committed Aug 11, 2024
1 parent 3b23c2e commit a10bd59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions lib/vaporware/compiler/assembler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,23 @@ def obj_file = @output
def to_elf(input: @input, output: @output, debug: false)
program_size = 0
read(input:)
elf_header = @elf_header.build

offset = 0
section_headers = []
name = []
names = []
bins = []
@sections.each do |section|
name << section.name
names << name = section.name
bin = section.body.build
size = bin.bytesize
offset += size
bin = section.body.align(bin, 8)
bins << bin
header = section.header
header.set!(offset:)
section_headers << header.build
end
f = File.open(output, "wb")
ensure
f.close
f.path
@elf_header.set!(phoffset: offset, shnum: 6, entry: 3, shstrndx: 6, shoffset: offset)
[@elf_header.build, *bins]
end

def read(input: @input, text: @sections.text.body)
Expand Down
2 changes: 1 addition & 1 deletion lib/vaporware/compiler/assembler/elf/sections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Vaporware::Compiler::Assembler::ELF::Sections
ATTRIBUTES = %i|null text data bss note symtab strtab shstrtab|
HAND_ASSEMBLES = %i|text shstrtab note|
HAND_ASSEMBLES = %i|text shstrtab note symtab strtab|
attr_reader *ATTRIBUTES

def initialize
Expand Down

0 comments on commit a10bd59

Please sign in to comment.