I have a simple C program as follows:
int a = 10;
int b = 20;
int sum = 0;
void add() { sum = a + b; }
int main() {
  add();
  return 0;
}
I compile this for risc-v with the following command and specify that .text segment should start at 0x1000.
riscv32-unknown-elf-gcc -static -T elf32lriscv.x -Wl,-Ttext-segment=0x1000 -Wl,-Map=add.elf.map -o add.elf add.c
If I print the info of the file using gdb, I see the following:
(gdb) i files
Symbols from "/home/mango/myp/risc-v/prog/add.elf".
Local exec file:
        `/home/mango/myp/risc-v/prog/add.elf', file type elf32-littleriscv.
        Entry point: 0x108c
        0x00001074 - 0x0000159c is .text
        0x0000259c - 0x000025a0 is .eh_frame
        0x000025a0 - 0x000025a8 is .init_array
        0x000025a8 - 0x000025ac is .fini_array
        0x000025b0 - 0x000029d8 is .data
        0x000029d8 - 0x000029ec is .sdata
        0x000029ec - 0x000029f0 is .sbss
        0x000029f0 - 0x00002a0c is .bss
Is there a simple way to dump the memory starting from 0x1074 to 0x2a0c?
The dump memory command requires a start and end address, but since this changes based on the program, I'd prefer to be able to auto-dump this value. Also, this is clearly accessible within gdb, is there a way to get this automatically?
My end goal is to create a command file for gdb and pass that as follows to automate the memory dumping:
gdb --command=gdb_commands <filename>
 
    