no_mangle을 설정하면 c에서 사용가능한 함수로 빌드 되는 듯.
Every function in your Rust-ffi API needs to have a corresponding header function. #[no_mangle] pub extern "C" fn rust_function() {} would then become void rust_function(); |
[링크 : https://docs.rust-embedded.org/book/interoperability/rust-with-c.html]
[링크 : https://dev.to/dandyvica/how-to-call-rust-functions-from-c-on-linux-h37]
mangle.. mangle이면 cpp이랑 좀 더 용이하게 붙을 느낌인데..?
$ readelf -a main | grep demangle 387: 0000000000000000 0 FILE LOCAL DEFAULT ABS rustc_demangle.9c38528e-c 393: 0000000000000000 0 FILE LOCAL DEFAULT ABS rustc_demangle.9c38528e-c 394: 0000000000000000 0 FILE LOCAL DEFAULT ABS rustc_demangle.9c38528e-c 395: 0000000000000000 0 FILE LOCAL DEFAULT ABS rustc_demangle.9c38528e-c 400: 000000000002fc20 320 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v010H 401: 000000000002fd60 152 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v06Pa 402: 000000000002fe00 181 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v06Pa 403: 000000000002fec0 202 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v06Pa 404: 000000000002ff90 85 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v06Pa 405: 000000000002fff0 471 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v06Pa 406: 00000000000301d0 79 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 407: 0000000000030220 411 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 408: 00000000000303c0 411 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 409: 0000000000032a00 1868 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 410: 0000000000030560 396 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 411: 0000000000031c00 1282 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 412: 00000000000306f0 354 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 413: 0000000000030860 241 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 414: 0000000000030960 748 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 415: 0000000000032800 509 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 416: 0000000000030c50 514 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 417: 0000000000032110 1138 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 418: 0000000000030e60 152 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 419: 0000000000030f00 159 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 420: 0000000000030fa0 666 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 421: 0000000000031240 147 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 422: 0000000000031af0 260 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 423: 00000000000312e0 164 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 424: 0000000000032590 610 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 425: 0000000000033150 487 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 426: 0000000000033340 720 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 427: 0000000000000000 0 FILE LOCAL DEFAULT ABS rustc_demangle.9c38528e-c 429: 0000000000000000 0 FILE LOCAL DEFAULT ABS rustc_demangle.9c38528e-c 430: 0000000000000000 0 FILE LOCAL DEFAULT ABS rustc_demangle.9c38528e-c 492: 000000000002f460 635 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v08de 624: 0000000000033620 802 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle6legac 654: 0000000000031390 1878 FUNC LOCAL DEFAULT 14 _ZN14rustc_demangle2v07Pr 758: 000000000002ea40 395 FUNC GLOBAL DEFAULT 14 _ZN63_$LT$rustc_demangle. 848: 000000000002e330 1695 FUNC GLOBAL DEFAULT 14 _ZN14rustc_demangle8deman 956: 0000000000033950 2970 FUNC GLOBAL DEFAULT 14 _ZN71_$LT$rustc_demangle. 1021: 000000000002f6e0 1332 FUNC GLOBAL DEFAULT 14 _ZN64_$LT$rustc_demangle. 1090: 000000000002ea30 9 FUNC GLOBAL DEFAULT 14 _ZN14rustc_demangle8Deman 1278: 000000000002e9d0 82 FUNC GLOBAL DEFAULT 14 _ZN14rustc_demangle12try_ 1303: 000000000002ebd0 21 FUNC GLOBAL DEFAULT 14 _ZN71_$LT$rustc_demangle. |
'Programming > rust' 카테고리의 다른 글
rust 소유권 (0) | 2023.05.25 |
---|---|
rust was (0) | 2023.05.20 |
rust 실행파일 (0) | 2023.05.11 |
rust if문 (0) | 2023.05.11 |
rust rustup doc (0) | 2023.05.10 |