I have a very stripped down binary that basically looks like the following:
Source:
extern "C" void WorkerMain()
{
// I intend to populate this later
// Exit
asm("movq $60, %rax;"
"movq $0, %rdi;"
"syscall");
}
I compile it with the following linker script:
ENTRY(WorkerMain);
SECTIONS
{
. = 0x10000;
.text : { *(.text) }
/DISCARD/ : { *(.comment) }
/DISCARD/ : { *(.note.gnu.build-id) }
/DISCARD/ : { *(.note.gnu.property) }
}
And using theis compile command:
g++ -T tiny.ld -o tiny tiny.cpp -O2 -fno-pie -fno-pic -nostartfiles -nostdlib -fno-rtti -fno-exceptions -fno-asynchronous-unwind-tables -s -static
I eventually get an elf binary with just the .text section, no other sections at all. Looking like this when I run `objdump -D tiny`:
tiny: file format elf64-x86-64
Disassembly of section .text:
0000000000010000 <.text>:
10000: f3 0f 1e fa endbr64
10004: 48 c7 c0 3c 00 00 00 mov $0x3c,%rax
1000b: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
10012: 0f 05 syscall
10014: c3 ret
This binary runs fine (even though it does nothing). No segfaults or anything weird happens. But under DR, using the following command:
/home/mewais/DynamoRIO/bin64/drrun -debug -loglevel 4 -c /home/mewais/DCSim/Debug/libSNEClient.so -- ./tiny
it gives me this error during initialization (before the client is even loaded):
<Application /home/mewais/DCSim/Debug/tiny (528524). Internal Error: DynamoRIO debug check failure: /home/travis/build/DynamoRIO/dynamorio/core/unix/loader.c:1943 is_elf_so_header(exe_map, 0)
(Error occurred @-1 frags)
version 8.0.0, build 1
-early_inject
0x00007fffd9f5c4d0 0x00007f71701e7095
0x00007fffd9f5c720 0x00007f71703fa8ad
0x00007fffd9f5d7d0 0x00007f71703aa1bd>
Naturally, I am thinking that this severe stripping down of the binary is causing this error in DR, since I have never encountered it before. So, what sections do I need to keep in my ELF binary for DR to work correctly?