Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[no_mangle] for asm. #143

Closed
coolofficials opened this issue Aug 13, 2020 · 4 comments
Closed

#[no_mangle] for asm. #143

coolofficials opened this issue Aug 13, 2020 · 4 comments
Assignees

Comments

@coolofficials
Copy link
Collaborator

gdb debug가 해결되었지만, 여전히 assembly를 위해 #[no_mangle] 추가가 필요하다면 추가하는 것이 좋을 것 같습니다.

@kimjungwow
Copy link
Collaborator

요약 : 아직 no_mangle을 꼭 추가할 이유를 찾지 못해서, 천천히 추가하면 어떨까요?

  • no_mangle 추가 후 gdb를 사용 후, no_mangle을 꼭 추가하는 것이 좋은지 고민중입니다..
  • static mut 변수에 #[no_mangle]을 추가할 경우
    • 파악한 바로는, info variables 명령어 사용시 rv6_kernel::fs.::ICACHEICACHE로 보이는 정도의 차이가 있습니다.
    • 하지만 #[no_mangle]을 추가하지 않아도 ICACHE를 사용하는 코드에 breakpoint를 건 상태에서는 gdb에서 print ICACHErv6_kernel::fs::ICACHE가 아닌 ICACHE를 바로 이용 가능해서.. 아직 static mut 변수에 #[no_mangle]이 꼭 필요한 이유는 찾지 못했습니다.
  • unsafe 함수에 #[no_mangle]을 추가할 경우
    • asm 파일 및 GDB의 어셈블리에서 함수명이 보기 좋게 표시됩니다. #[no_mangle]이 없다면, krate::module::function
      _ZN5krate6module8function17he1dfc17c86fe16daE로 표시됩니다. 참고
    • 하지만 #[no_mangle]을 추가하면 gdb에서 해당 함수에 대해 disas 명령어 사용이 안 됩니다.. (이유는 모르겠습니다)
    • 지금까지 rv6에서 디버깅한 경험으로 생각해보면, 함수명을 보기 좋게 표시하는 것보다는 disas 명령어가 사용 가능한 것이 더 중요한 것 같습니다. 상욱님과 미팅에서는 함수 주소를 이용해 disas를 사용가능하다고 말씀드렸었지만, 함수명에 바로 disas를 사용가능한 장점이 함수명을 보기 어렵게 표시하는 단점보다 큰 것 같습니다..

@jeehoonkang
Copy link
Member

정우님 의견에 모두 동의합니다.

@kimjungwow
Copy link
Collaborator

차후에 no_mangle이 필요하다고 보이면 reopen하겠습니다 :)

@efenniht
Copy link
Collaborator

별개로, #[no_mangle] 은 unsafe합니다. rust-lang/rust#28179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants