리눅스 인터럽트 시스템콜 확인하기

gag2012의 이미지

리눅스 상에 코드를 실행했을 때 호출되는 시스템콜을 다 알아보고 싶어서

몇 가지를 수정했습니다.

첫 번째, 스택을 이용해서 show_sysnum의 파라미터에게 시스템콜 번호를 넘겨주려고 했습니다.
그리고 show _sysnum은 그 번호를 printk로 출력하도록 했습니다.

entry_32.C

pushl %eax
call show_sysnum
call *sys_call_table(,%eax,4)
popl %eax

두 번째,

fs/read_write.c

int flag;
asmlinkage void show_system(int x){
     if(flag = 1){
          printk("sysnum : %d", x);
     }
}
 
asmlinkage void start_show_sysnum(){
     flag = 1;
}
 
amlinkage void stop_show_sysnum(){
     flag = 0;
]

세 번째,

syscall_table_32.S

.....
.long start_show_sysnum //17번째
.....
.long stop_show_sysnum //31번째

이후 bzImage를 컴파일했고

다음과 같은 코드를 작성해서 hi 문자가 찍히는 동안의 어떤 시스템콜이 출력되는지 확인하고 싶었습니다.

#include <stdio.h>
 
void main(){
 
   syscall(17);
   printf("hi\n");
   syscall(31);
 
}

하지만 예상과는 다르게 general protection ip 란 오류가 뜹니다. (파일첨부했습니다.)

아무래도 뭔가 잘못 건드린 것 같은데 혹시 접근방법이 틀린 부분이 있을까요?

허접한 질문 죄송합니다.

File attachments: 
첨부파일 크기
Image icon 11.jpg136.79 KB
shint의 이미지

예상 원인
- 과도한 호출
- _syscall0() ~ _syscall6() 을 이용한다고 합니다.
- 잘되는 책 예제 소스를 참고해보세요.
- 소스 코드를. 한줄씩 지우고 해보세요.
- 전문 블로그 / 기업 / 전문 학교 / 학원 / 등에도 문의해보세요.
- 디버깅 방법이 몇가지 보입니다.

//
System Calls
2014년 2학기 시스템 프로그래밍 시험 공부
https://libsora.so/posts/system-prog-system-call/

Adding a New System Call
_syscall0() ~ _syscall6() 이용

시스템 콜(System Call)
http://leeeeye321.tistory.com/221

Reload this Page get rid of "printk: # messages suppressed" message
https://www.linuxquestions.org/questions/linux-general-1/get-rid-of-printk-messages-suppressed-message-511702/
printk kernel messages suppressed

https://www.centos.org/forums/viewtopic.php?t=35106

centos, messges 로그에서 kernel: printk messages..

https://kldp.org/node/99966
시스템에 과접속이 발생했을 경우, 저 메시지는 tcp/ip 패킷을 드롭되고 있을 가능성이 높습니다.

GCC: Difference between buildroot gcc and precompiled gcc (installed with APT)?
https://stackoverflow.com/questions/24990851/gcc-difference-between-buildroot-gcc-and-precompiled-gcc-installed-with-apt

Change your program, inside main() use a for(;;) loop and see what happens. – rakib_ Jul 28 '14 at 8:25

제목 : Linux System Call - 구조 분석 및 간단한 Syscall 작성
http://coffeenix.net/doc/develop/syscall.txt

시스템 인터럽트(interrupt), 시스템 콜(system call
http://luckyyowu.tistory.com/2

6장 인터럽트와 트랩 그리고 시스템 호출
http://hayeol.tistory.com/16

SYSTEM CALL IN LINUX KERNEL - (1) 시스템콜 수정, 추가해보기
http://casualprogramming.tistory.com/11

리눅스 상에서 명령어 사용시(system call 분석)
https://kin.naver.com/qna/detail.nhn?d1id=1&dirId=10302&docId=75409859&qb=66as64iF7IqkIOyduO2EsOufve2KuCDsi5zsiqTthZzsvZwg7ZmV7J24&enc=utf8&section=kin&rank=3&search_sort=0&spq=0

Linux Kernel: memory corruption - debug tricks
http://helenfornazier.blogspot.com/2015/07/linux-kernel-memory-corruption-debug.html

댓글 첨부 파일: 

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

익명 사용자의 이미지

정확히 뭘 하고 싶으신 건지 모르겠는데 그냥 strace 쓰면 안되나요?

https://linux.die.net/man/1/strace

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.