Skip to content

Commit f12e42c

Browse files
committed
WASM_X64: Remove unused functions
1 parent 06ed809 commit f12e42c

File tree

2 files changed

+3
-99
lines changed

2 files changed

+3
-99
lines changed

src/libasr/codegen/x86_assembler.cpp

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -474,97 +474,6 @@ Vec<uint8_t> create_elf64_x86_binary(Allocator &al, X86Assembler &a) {
474474
return bin;
475475
}
476476

477-
478-
void emit_elf64_header(X86Assembler &a) {
479-
/* Elf64_Ehdr */
480-
a.add_label("ehdr");
481-
// e_ident
482-
a.asm_db_imm8(0x7F);
483-
a.asm_db_imm8('E');
484-
a.asm_db_imm8('L');
485-
a.asm_db_imm8('F');
486-
a.asm_db_imm8(2);
487-
a.asm_db_imm8(1);
488-
a.asm_db_imm8(1);
489-
a.asm_db_imm8(0);
490-
491-
a.asm_db_imm8(0);
492-
a.asm_db_imm8(0);
493-
a.asm_db_imm8(0);
494-
a.asm_db_imm8(0);
495-
496-
a.asm_db_imm8(0);
497-
a.asm_db_imm8(0);
498-
a.asm_db_imm8(0);
499-
a.asm_db_imm8(0);
500-
501-
a.asm_dw_imm16(2); // e_type
502-
a.asm_dw_imm16(0x3e); // e_machine
503-
a.asm_dd_imm32(1); // e_version
504-
a.asm_dq_label("_start"); // e_entry
505-
a.asm_dq_label("e_phoff"); // e_phoff
506-
a.asm_dq_imm64(0); // e_shoff
507-
a.asm_dd_imm32(0); // e_flags
508-
a.asm_dw_label("ehdrsize"); // e_ehsize
509-
a.asm_dw_label("phdrsize"); // e_phentsize
510-
a.asm_dw_imm16(3); // e_phnum
511-
a.asm_dw_imm16(0); // e_shentsize
512-
a.asm_dw_imm16(0); // e_shnum
513-
a.asm_dw_imm16(0); // e_shstrndx
514-
515-
/* Elf64_Phdr */
516-
a.add_label("phdr");
517-
a.asm_dd_imm32(1); // p_type
518-
a.asm_dd_imm32(4); // p_flags (permission to read only)
519-
a.asm_dq_imm64(0); // p_offset
520-
a.asm_dq_imm64(a.origin()); // p_vaddr
521-
a.asm_dq_imm64(a.origin()); // p_paddr
522-
a.asm_dq_label("phdr_size"); // p_filesz
523-
a.asm_dq_label("phdr_size"); // p_memsz
524-
a.asm_dq_imm64(0x1000); // p_align
525-
526-
/* text_segment_phdr */
527-
a.add_label("text_phdr");
528-
a.asm_dd_imm32(1); // p_type
529-
a.asm_dd_imm32(5); // p_flags (permission to read and execute)
530-
a.asm_dq_label("text_segment_offset"); // p_offset
531-
a.asm_dq_label("text_segment_start"); // p_vaddr
532-
a.asm_dq_label("text_segment_start"); // p_paddr
533-
a.asm_dq_label("text_segment_size"); // p_filesz
534-
a.asm_dq_label("text_segment_size"); // p_memsz
535-
a.asm_dq_imm64(0x1000); // p_align
536-
537-
/* data_segment_phdr */
538-
a.add_label("data_phdr");
539-
a.asm_dd_imm32(1); // p_type
540-
a.asm_dd_imm32(6); // p_flags (permission to read and write)
541-
a.asm_dq_label("data_segment_offset"); // p_offset
542-
a.asm_dq_label("data_segment_start"); // p_vaddr
543-
a.asm_dq_label("data_segment_start"); // p_paddr
544-
a.asm_dq_label("data_segment_size"); // p_filesz
545-
a.asm_dq_label("data_segment_size"); // p_memsz
546-
a.asm_dq_imm64(0x1000); // p_align
547-
}
548-
549-
void emit_elf64_footer(X86Assembler &a) {
550-
a.add_var("ehdrsize", "ehdr", "phdr");
551-
a.add_var("phdrsize", "phdr", "text_phdr");
552-
a.add_var64("e_phoff", "ehdr", "phdr");
553-
a.add_var64("phdr_size", "ehdr", "text_segment_start");
554-
a.add_var64("text_segment_offset", "ehdr", "text_segment_start");
555-
a.add_var64("text_segment_size", "text_segment_start", "text_segment_end");
556-
a.add_var64("data_segment_offset", "ehdr", "data_segment_start");
557-
a.add_var64("data_segment_size", "data_segment_start", "data_segment_end");
558-
}
559-
560-
void emit_exit_64(X86Assembler &a, std::string name, int exit_code) {
561-
a.add_label(name);
562-
// void exit(int status);
563-
a.asm_mov_r64_imm64(LCompilers::X64Reg::rax, 60); // sys_exit
564-
a.asm_mov_r64_imm64(LCompilers::X64Reg::rdi, exit_code); // exit code
565-
a.asm_syscall(); // syscall
566-
}
567-
568477
void emit_print_64(X86Assembler &a, const std::string &msg_label, uint64_t size)
569478
{
570479
// mov rax, 1 ; write(

src/libasr/codegen/x86_assembler.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,19 +1621,14 @@ void emit_print(X86Assembler &a, const std::string &msg_label,
16211621
void emit_print_int(X86Assembler &a, const std::string &name);
16221622
void emit_print_float(X86Assembler &a, const std::string &name);
16231623

1624+
// Generate an ELF 64 bit header and footer
1625+
// With these three functions, one only must generate a `_start` assembly
1626+
// function to have a working binary on Linux.
16241627
template <typename T>
16251628
void append_header_bytes(Allocator &al, T src, Vec<uint8_t> &des);
16261629
void align_by_byte(Allocator &al, Vec<uint8_t> &code, uint64_t alignment);
16271630
Vec<uint8_t> create_elf64_x86_binary(Allocator &al, X86Assembler &a);
16281631

1629-
// Generate an ELF 64 bit header and footer
1630-
// With these two functions, one only must generate a `_start` assembly
1631-
// function to have a working binary on Linux.
1632-
void emit_elf64_header(X86Assembler &a);
1633-
void emit_elf64_footer(X86Assembler &a);
1634-
1635-
void emit_exit_64(X86Assembler &a, std::string label, int exit_code);
1636-
16371632
void emit_print_64(X86Assembler &a, const std::string &msg_label, uint64_t size);
16381633
void emit_print_int_64(X86Assembler &a, const std::string &name);
16391634
void emit_print_double(X86Assembler &a, const std::string &name);

0 commit comments

Comments
 (0)