Skip to content

Commit

Permalink
Merge branch 'feature/riscv-hello'
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfkda committed Apr 25, 2024
2 parents 0f6702a + 37fd02e commit 7c800f1
Show file tree
Hide file tree
Showing 22 changed files with 1,367 additions and 234 deletions.
11 changes: 9 additions & 2 deletions include/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,15 @@ typedef struct {
#define R_X86_64_PC32 (2) /* PC relative 32 bit signed */
#define R_X86_64_PLT32 (4) /* 32 bit PLT address */

#define R_RISCV_CALL (18)
#define R_RISCV_RELAX (51)
#define R_RISCV_64 (2)
#define R_RISCV_BRANCH (16)
#define R_RISCV_JAL (17)
#define R_RISCV_CALL (18)
#define R_RISCV_PCREL_HI20 (23)
#define R_RISCV_PCREL_LO12_I (24)
#define R_RISCV_RVC_BRANCH (44)
#define R_RISCV_RVC_JUMP (45)
#define R_RISCV_RELAX (51)

#define ELF64_R_SYM(info) ((info) >> 32)
#define ELF64_R_TYPE(info) ((Elf64_Word)(info))
Expand Down
8 changes: 0 additions & 8 deletions src/as/arch/aarch64/asm_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
#include "parse_asm.h"
#include "util.h"

#ifndef MAKE_CODE16
#define MAKE_CODE16(inst, code, ...) do { unsigned short buf[] = {__VA_ARGS__}; make_code16(inst, code, buf, sizeof(buf)); } while (0)
#endif

#ifndef MAKE_CODE32
#define MAKE_CODE32(inst, code, ...) do { unsigned int buf[] = {__VA_ARGS__}; make_code32(inst, code, buf, sizeof(buf)); } while (0)
#endif

void make_code16(Inst *inst, Code *code, unsigned short *buf, int len) {
assert(code->len + len <= (int)sizeof(code->buf));
code->inst = inst;
Expand Down
2 changes: 1 addition & 1 deletion src/as/arch/aarch64/inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum Opcode {
};

enum RegType {
NOREG,
NOREG = -1,

// 32bit
W0, W1, W2, W3, W4, W5, W6, W7, W8, W9, W10, W11, W12, W13, W14, W15,
Expand Down
5 changes: 3 additions & 2 deletions src/as/arch/aarch64/parse_aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static enum RegType find_register(const char **pp) {
for (int i = 0; i < (int)ARRAY_SIZE(kRegisters); ++i) {
const char *name = kRegisters[i].name;
size_t n = strlen(name);
if (strncmp(p, name, n) == 0 && !isdigit(p[n])) {
if (strncmp(p, name, n) == 0 && !is_label_chr(p[n])) {
*pp = p + n;
return kRegisters[i].reg;
}
Expand Down Expand Up @@ -167,7 +167,8 @@ static bool parse_operand(ParseInfo *info, Operand *operand) {
return false;
}

void parse_inst(ParseInfo *info, Inst *inst) {
void parse_inst(ParseInfo *info, Line *line) {
Inst *inst = &line->inst;
Operand *opr_table[] = {&inst->opr1, &inst->opr2, &inst->opr3};
for (int i = 0; i < (int)ARRAY_SIZE(opr_table); ++i)
opr_table[i]->type = NOOPERAND;
Expand Down
Loading

0 comments on commit 7c800f1

Please sign in to comment.