Hello,
For a research project, I attempted using DynamoRIO to instrument an executable written in assembly, but I always run into a segfault. After some experiments, here's a minimal example that crashes. The architecture is aarch64. Version of DynamoRIO is 11.3.0.
First I write a program that does nothing but exits:
_start:
mov x0, #0x0
mov x8, #0x5d
svc #0x0
.global _start
I compile the above file with as prog.S -o prog.o
Then I link the program with ld -T myscript.lds -e _start -o prog prog.o
The content of myscript.lds is
PHDRS {
headers PT_PHDR PHDRS ;
text PT_LOAD FILEHDR PHDRS ;
data PT_LOAD ;
}
SECTIONS {
. = 0x10000 ;
. += SIZEOF_HEADERS ;
.text : { *(.text*) } :text
.rodata : { *(.rodata*) } :text
. = ALIGN(0x1000) ;
.data : { *(.data*) } :data
.bss : { *(.bss) } :data
}
Finally I run the program with ~/DynamoRIO/bin64/drrun -t drmemtrace -offline -- ./prog
And I observe a segfault immediately. GDB says the segfault occurs at core/unix/loader.c line 1744. If I replace myscript.lds with a standard linker script from binutils the issue seems to disappear. So I guess the problem is related to my linker script. Any ideas of what is going on?