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 877
공지 [공지] IAMROOT 18차 커널 스터디 오리엔테이션 안내 [마감] [2] 문c(문영일) 2021.05.17 1249
공지 커널 스터디를 위한 문c 가이드입니다. [10] 문c(문영일) 2021.04.27 6452
1036 세미나 진행사항 및 논의 사항 [42] 백창우 2009.02.23 6689
1035 5월 8일 어버이 날입니다. [1] 강진성 2010.05.04 6679
1034 Arndale Octa Board(5420) 판매 [12] 조성진 2013.11.08 6666
1033 오늘 처음 가입을 하였는데 GCC 세미나에 참석 하고 싶습니다. [1] 강진구 2009.03.16 6661
1032 코딩 가이드 라인 [5] 백창우 2008.01.29 6634
1031 멀티코어 세미나 자료를 다운받고 싶습니다. [1] 김종화 2007.06.06 6578
1030 세미나 참가 신청 받습니다. [51] 백창우 2008.03.31 6570
1029 MULTIPLE-PROCESSOR (MP) INITIALIZATION [4] file 박한범 2010.11.04 6547
1028 kernel & cell study 장소 및 시간 공지 [7] 백창우 2007.02.22 6522
1027 비밀 게시판에 제가 하고 싶은 이야기를 적어 놓았습니다. [5] 백창우 2011.07.30 6510
1026 스터디 오리엔테이션 "와우" [5] file 김성현2 2012.04.09 6509
1025 IBM Cell SDK 3.0이 나왔습니다. 백창우 2008.02.14 6504
1024 [GCC 세미나] 온라인 입금해주세요. [30] 백창우 2009.03.12 6483
» [KVM study] native() 함수의 비밀을 알아냈습니다. 좀 허무하군요. 김정수 2008.06.16 6478
1022 세미나 참여 하고 싶습니다. [8] 전남재 2008.02.04 6473
1021 축 리눅스 탄생 20주년!! [1] 유강희 2011.08.26 6456
1020 커널 배리어에 관하여(barrier) [5] 지승화 2012.05.04 6429
1019 Intel Nehalem Architecture 세미나 자료 file 백창우 2009.03.09 6423
1018 서버 ID 신청 [36] 백창우 2007.03.16 6393
XE Login