[問題] linux 下 c/c++ libc.so ld.so

看板C_and_CPP作者 (The Beginning)時間15年前 (2010/09/09 15:15), 編輯推噓3(3016)
留言19則, 7人參與, 最新討論串1/1
linux 下 c/c++ 的程式 就算只有 int main() { return 0; } 在他的記憶體裡面都會有多 libc-xxx.so, ld-xxx.so 這兩個 .so 在一個linux process 下的作用是? 謝謝 -- The Beginning is the end The End is the beginning -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.147.15.66

09/09 15:17, , 1F
ld 是讀 .so 但偽什麼它要被放進process memory map?
09/09 15:17, 1F

09/09 15:21, , 2F
要有ld才能去連其他的動態庫阿
09/09 15:21, 2F

09/09 15:22, , 3F
請參考 jserv 大神的「深入淺出 HelloWorld」
09/09 15:22, 3F

09/09 15:22, , 4F
沒有編成 static 都一定會有加這進去吧
09/09 15:22, 4F

09/09 15:23, , 5F

09/09 15:23, , 6F
我認為,若能了解這一系列的內涵,就算了解得滿透徹了
09/09 15:23, 6F

09/09 15:25, , 7F
那libc 在process裡面是作什麼的?
09/09 15:25, 7F

09/09 15:38, , 8F
那是 C 的標準函式庫...
09/09 15:38, 8F

09/09 15:39, , 9F
libc就是那些C function的runtime library
09/09 15:39, 9F

09/09 15:40, , 10F
在執行期map進process memory讓你的程式呼叫
09/09 15:40, 10F
在wiki找到的, C standard library: The run-time support provides not only the C standard library functions, but possibly other material needed to create an environment for the C program, such as initialization prior to the invocation of the main function, or subroutines to provide arithmetic operations missing from the CPU that are needed by code generated by the C compiler. 所以這段話的意思是, process在進入main前, 會有一些動作需要由libc來處理嗎?

09/09 15:49, , 11F
runtime library, 所以沒有呼叫到他也會被放進去?
09/09 15:49, 11F
※ 編輯: powertodream 來自: 122.147.15.66 (09/09 15:58)

09/09 16:05, , 12F
會有一些initialization需要libc裡的東西
09/09 16:05, 12F

09/09 16:55, , 13F
我記得啦 之前看書是說真正的進入點不是main 會在runtime
09/09 16:55, 13F

09/09 16:55, , 14F
library用好之後 才跳到main去執行
09/09 16:55, 14F

09/09 17:03, , 15F
至少你得開好 stdin 和 stdout 給使用者用吧 XD
09/09 17:03, 15F

09/09 17:03, , 16F
這些都是 CRT (C Runtime Library, 我偏好此稱呼)在做準備的
09/09 17:03, 16F

09/09 17:03, , 17F
推樓上, 就算cin、cout也要先建構好, 是這意思吧?
09/09 17:03, 17F

09/09 17:04, , 18F
當然還有一些其他的雜事就是
09/09 17:04, 18F

09/09 18:09, , 19F
準備STACK?
09/09 18:09, 19F
文章代碼(AID): #1CY8cDOA (C_and_CPP)