Skip to content

A segmentation fault occurs when running a simple ELF file #461

@kjhhgt76

Description

@kjhhgt76

I ran hello.elf and it is fine.
But when I tried to run my own mul.elf, segmentation fault happened.
I tried to do some simple gdb debugging to figure out why but just gave up because my unfamiliarity with the emulator.
Can someone explain the cause?

Emulator build configuration:
Every ENABLE_* in Makefile are disabled.

$ cc --version      
cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)     
Copyright (C) 2015 Free Software Foundation, Inc.    
This is free software; see the source for copying conditions.  There is NO    
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     

hello.elf result:

$ ./rv32emu hello.elf 
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
inferior exit code 0

mul.elf result:

./rv32emu mul.elf 
Segmentation fault (core dumped)`

The objdump of mul.elf:
mul_objdump.txt

c source code:

int mul(int a, int b)
{
    a = 0x12345678;
    b = 0x87654321;
    return a * b;
}

It is just an integer multiply function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions