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
977 지난 토욜에 술마시며 했던 얘기중에서... [3] 이수연 2008.05.05 4628
976 [공지] KVM 스터디 05/09 [5] 이수연 2008.05.09 3934
975 [공지] 토론회 주제 백창우 2008.05.10 4260
974 [KVM 스터디] 오늘 분석한 클래스 파일 이수연 2008.05.11 5008
973 [KVM study] class file 분석 [2] 이정우 2008.05.13 5796
972 [KVM Study] interface 구현한 자바 파일은 아니지만 기본으로 만들어서 분석한 class파일입니다. file 김정수 2008.05.14 4794
971 [KVM STUDY] JAVA BYTE CODE 분석 [4] 이수연 2008.05.24 6893
970 금일 세미나 참석하신분 백창우 2008.05.24 4308
969 백승주님 세미나 자료입니다. file 백창우 2008.05.25 5842
968 주변에 웹 디자인 & 프로그램 할수 있는 사람 있다면 추천 부탁드립니다. [1] 백창우 2008.05.30 5426
967 [KVM Study] bytecodes.c file 이정우 2008.06.03 4660
966 [KVM Study] 정수님 보세요. [1] 이정우 2008.06.07 3851
965 bytecode에 제가 주석단거 추가해서 올립니다. file 김정수 2008.06.09 4625
» [KVM study] native() 함수의 비밀을 알아냈습니다. 좀 허무하군요. 김정수 2008.06.16 6478
963 [KVM Study] bytecode. 이정우 2008.06.28 4520
962 [KVM STUDY] 금일 스터디 의문사항 이수연 2008.07.06 4284
961 CE Linux Forum 한국 Jamboree 행사 [2] 백창우 2008.07.10 4767
960 [kvm study] 다음주 스터디 관련하여... [2] 이수연 2008.07.14 4121
959 커널 5기 멤버 모집 공고에 앞서. [1] 백창우 2008.07.17 4330
958 커널 5기 멤버 모집 공고에 앞서. [1] 백창우 2008.07.17 4331
XE Login