2014-03-18 4 views
5

모듈을 gdb에로드 한 직후에 중지하려고합니다. 바이너리가 모든 심볼 정보에서 완전히 제거되었다고 가정 해 봅시다. 따라서 메인이 없습니다.가능한 가장 빠른 중단 점을 설정하는 방법

은 이상적으로는 진입 점에 중단 점을 설정 싶지만, 그 생각으로 인해 재배치에 고장 : 그런 종류의-의 작품 (내가 새 주소에서 새 중단 점을 설정할 수

(gdb) info target 
Symbols from "./application". 
Local exec file: 
    `./application', file type elf64-x86-64. 
    Entry point: 0xc154 
... 
(gdb) break *0xc154 
Breakpoint 1 at 0xc154 
(gdb) r 
Starting program: ./application 
Warning: 
Cannot insert breakpoint 1. 
Error accessing memory address 0xc154: Input/output error. 

(gdb) info target 
Symbols from "./application". 
Unix child process: 
    Using the running image of child process 22835. 
    While running this, GDB does not access memory from... 
Local exec file: 
    `./application', file type elf64-x86-64. 
    Entry point: 0x555555560154 

에도 불구하고 gdb 스크립트/배치 모드를 통해 쉽게 실행될 수 없습니다. 중간에 실패한 명령어가 있기 때문입니다.

할 방법이 있습니까? 이상적으로는 "실행"보다는 "단일 명령 실행"과 같은 것이 유용 할 것입니다.

답변

8

진입 점 : 0xc154

이것은 동적 링크 위치 독립적 (PIE) 이진.

바이너리가로드되고 재배치되었지만 실행되기 전에 동적 링커에서 멈추고 싶습니다.

(gdb) set stop-on-solib-events 1 
(gdb) run 
Starting program: /tmp/a.out 
Stopped due to shared library event (no libraries added or removed) 
(gdb) info target 
Symbols from "/tmp/a.out". 
Unix child process: 
     Using the running image of child process 13746. 
     While running this, GDB does not access memory from... 
Local exec file: 
     `/tmp/a.out', file type elf64-x86-64. 
     Entry point: 0x5555555545f0 
     ... 

(gdb) bt 
#0 __GI__dl_debug_state() at dl-debug.c:77 
#1 0x00007ffff7ddd488 in dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=0x7ffff7ffe870) at rtld.c:1678 
#2 0x00007ffff7defb24 in _dl_sysdep_start (start_argptr=<optimized out>, dl_main=0x7ffff7ddc6e0 <dl_main>) at ../elf/dl-sysdep.c:244 
#3 0x00007ffff7ddf365 in _dl_start_final (arg=0x7fffffffe440) at rtld.c:338 
#4 _dl_start (arg=0x7fffffffe440) at rtld.c:564 
#5 0x00007ffff7ddb6b8 in _start() from /lib64/ld-linux-x86-64.so.2 
+0

내가 필요한 것 – viraptor

+0

이것은 위치 독립적 실행 파일에서 작동하지 않습니다. –

+0

@ZachRiggle 위의 대답은 * PIE 바이너리 용으로 수집 된 GDB 명령의 추적을 포함하고 있으며 분명히 * 작동합니다. 그것이 당신을 위해 작동하지 않았다면, 아마도 당신은 오래된/버그가있는 GDB를 가지고 있거나, GLIBC를 사용하지 않았을 것입니다. 또는 ... –

관련 문제