Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
[Revert later] Adding additional files
Browse files Browse the repository at this point in the history
  • Loading branch information
cathylu10 committed Sep 9, 2021
1 parent 1b7ad81 commit cdd12cb
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/host/Elfloader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "ElfFile.hpp"

int parseElf(char* fileName);
29 changes: 29 additions & 0 deletions src/host/Elfloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//******************************************************************************
// Copyright (c) 2018, The Regents of the University of California (Regents).
// All Rights Reserved. See LICENSE for license details.
//------------------------------------------------------------------------------
#include "Elfloader.hpp"
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>


static int
parseElf(char* fileName, bool isRuntime) {
int ret;

ElfFile* elfFile = ElfFile(fileName);


if (!elfFile->initialize(isRuntime)) {
// TODO: Error handling
return false;
}






return 1;
}
3 changes: 3 additions & 0 deletions src/host/loader.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parse_runtime:

parse_eapp:
Empty file added src/host/parseElf.c
Empty file.
7 changes: 7 additions & 0 deletions src/host/toy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
int
main() {
unsigned int a = 7;
unsigned int b = 3;
unsigned int result = a + b;
return result;
}
Binary file added src/host/toy.out
Binary file not shown.
26 changes: 26 additions & 0 deletions src/host/toy.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.file "toy.c"
.option pic
.text
.align 1
.globl main
.type main, @function
main:
addi sp,sp,-32
sd s0,24(sp)
addi s0,sp,32
li a5,7
sw a5,-20(s0)
li a5,3
sw a5,-24(s0)
lw a4,-20(s0)
lw a5,-24(s0)
addw a5,a4,a5
sw a5,-28(s0)
lw a5,-28(s0)
mv a0,a5
ld s0,24(sp)
addi sp,sp,32
jr ra
.size main, .-main
.ident "GCC: (GNU) 10.2.0"
.section .note.GNU-stack,"",@progbits

0 comments on commit cdd12cb

Please sign in to comment.