native() 함수의 비밀을 알아냈습니다.

아주 가까운데에 있더군요.. ㅡ.ㅡ

invokeNativeFunction() 에 있는 NativeFunctionPtr 형 native 입니다.

즉, 함수포인터 였던거죠.

그래서 인즉 Object 파일을 분석하지 않으면 어떤 함수포인터가 호출되는지 알지 못하겠

더라구요. 저도 같이 Object 파일분석해서 올리겠습니다.

그럼 이번주 토요일에 뵙겠습니다.

void invokeNativeFunction(METHOD thisMethod)
{
    ...
    NativeFunctionPtr native = thisMethod->u.native.code;

    if (native == NULL) {
        /* Native function not found; throw error */

        /* The GC may get confused by the arguments on the stack */
        setSP(getSP() - thisMethod->argCount);

        START_TEMPORARY_ROOTS
            DECLARE_TEMPORARY_ROOT(char*, className,
                     getClassName((CLASS)(thisMethod->ofClass)));
            sprintf(str_buffer,
                    KVM_MSG_NATIVE_METHOD_NOT_FOUND_2STRPARAMS,
                    className, methodName(thisMethod));
        END_TEMPORARY_ROOTS
        fatalError(str_buffer);
    }

#if INCLUDEDEBUGCODE
    if (tracemethodcalls || tracemethodcallsverbose) {
        frameTracing(thisMethod, "=>", +1);
    }
    saved_TemporaryRootsLength = TemporaryRootsLength;
#endif

#if USE_KNI
    /* Note: Unlike many other Java VMs, KVM does not create      */
    /* stack frames for native function calls.  This makes native */
    /* function calls faster.  However, at the same time it means */
    /* that the native function programmer must be careful not to */
    /* screw up the stack pointer when popping and pushing items  */
    /* to and from the operand stack.                             */

    /* Because of the lack of stack frames for native functions,  */
    /* KNI calls need special assistance to access the parameters */
    /* of a native method.  Basically, we create a new "pseudo-   */
    /* local pointer" called "nativeLp" to point to the locals of */
    /* the native method.  Old-style (pre-KNI) native methods can */
    /* simply ignore this new variable.                           */
    if ((thisMethod->accessFlags & ACC_STATIC) && CurrentThread) {
        CurrentThread->nativeLp = getSP() - (thisMethod->argCount);
    } else {
        CurrentThread->nativeLp = getSP() - (thisMethod->argCount-1);
    }
#endif /* USE_KNI */

    /* Call the native function we are supposed to call */
    CurrentNativeMethod = thisMethod;
    native();

    ...

}
번호 제목 글쓴이 날짜 조회 수
공지 [공지] IAMROOT 19차 커널 스터디 오리엔테이션 (zoom 접속 안내) [5] 문c(문영일) 2022.05.07 882
공지 [공지] IAMROOT 18차 커널 스터디 오리엔테이션 안내 [마감] [2] 문c(문영일) 2021.05.17 1249
공지 커널 스터디를 위한 문c 가이드입니다. [10] 문c(문영일) 2021.04.27 6476
1037 [커널 15차 A팀] 50주차 참석인원 조사합니다. [3] 코딩코딩 2019.04.01 98
1036 [해킹/보안] 170520 진행내용 pororo 2017.05.21 99
1035 [커널 15차 A팀] 19주차 2018년 9월 1일 (토) 스터디 노트 킹콩 2018.09.01 99
1034 [커널 15차 A팀] 56주차 장소공지 코딩코딩 2019.05.15 99
1033 [커널 16차] 109주차 [2] file 이파란 2021.09.05 100
1032 [커널 15차 A팀] 66주차 참석인원 조사 [1] 코딩의노예 2019.07.24 100
1031 [커널 16차] 146주차 [2] 이파란 2022.05.22 100
1030 [공지] 커널 주중 E팀 17주차(9/6) 스터디 참가여부 조사 (월요일 마감) [7] 김지성 2017.09.02 101
1029 [공지] 커널 주중 D,E팀 49주차(5/2) 스터디 참여조사 (월요일 오후 7시까지) [1] 정한빛 2018.04.30 101
1028 [공지] 커널 주중 D,E팀 54주차(6/6) 스터디 참여조사 (월요일 오후 7시까지) [1] 김지성 2018.06.02 101
1027 [공지] 커널 주중 D,E팀 56주차(6/20) 스터디 참여조사 김지성 2018.06.19 101
1026 [커널 16차 스터디] 77주차 참석인원 조사 [5] 커널열공 2021.01.16 101
1025 [커널 16차] 163주차 [3] 이파란 2022.09.25 101
1024 해킹/보안 팀 17/05/13 진도 pororo 2017.05.17 102
1023 [공지] 커널 주중 D팀 17주차(9/6) 스터디 참가여부 조사 (월요일 한) [7] 깜시 2017.09.01 102
1022 [공지] 커널 주중 E팀 36주차(1/31) 스터디 참여조사 (월요일 오후 7시까지) [3] 정한빛 2018.01.28 102
1021 [커널 16차 스터디] 86주차 참석인원 조사 [4] 커널열공 2021.03.28 102
1020 [커널 16차 스터디] 87주차 참석인원 조사 [5] 커널열공 2021.04.04 102
1019 [커널 16차] 145주차 [3] 이파란 2022.05.14 102
1018 2017 웹앱 스터디 2주차 장소 공지 [3] 김상진 2017.05.21 103
XE Login