Why is the ELF execution entry point virtual address of the form 0x80xxxxx and not zero 0x0? और Why do virtual memory addresses for linux binaries start at 0x8048000? के बाद, मैं ld
ld -e
के साथ डिफ़ॉल्ट से भिन्न प्रविष्टि बिंदु का उपयोग क्यों नहीं कर सकता?ईएलएफ प्रविष्टि बिंदु 0x8048000 "ld -e" विकल्प के साथ क्यों नहीं बदला जा सकता है?
यदि ऐसा है, तो मुझे डिफ़ॉल्ट कोड बिंदु के करीब पते के लिए भी segmentation fault
रिटर्न कोड 13 9 के साथ मिलता है। क्यूं कर?
संपादित करें:
मैं प्रश्न अधिक विशिष्ट कर देगा: यदि मैं as program.s -o program.o
के साथ इस संकलन
.text
.globl _start
_start:
movl $0x4,%eax # eax = code for 'write' system call
movl $1,%ebx # ebx = file descriptor to standard output
movl $message,%ecx # ecx = pointer to the message
movl $13,%edx # edx = length of the message
int $0x80 # make the system call
movl $0x0,%ebx # the status returned by 'exit'
movl $0x1,%eax # eax = code for 'exit' system call
int $0x80 # make the system call
.data
.globl message
message:
.string "Hello world\n" # The message as data
और फिर इसे स्थिर लिंक ld -N program.o -o program
, readelf -l program
शो 0x0000000000400078
के साथ पाठ का VirtAddr
के रूप में सेगमेंट और 0x400078
प्रवेश बिंदु के रूप में। जब चलाने के लिए, `नमस्ते दुनिया" छपा है।
हालांकि, जब मैं (4 बाइट्स द्वारा पाठ खंड और प्रवेश बिंदु से आगे बढ़), कार्यक्रम killed
हो जाएगा। readelf -l
के साथ निरीक्षण अब दो अलग हेडर से पता चलता ld -N -e0x400082 -Ttext=0x400082 program.o -o program
साथ लिंक करने का प्रयास प्रकार LOAD
, 0x0000000000400082
से कम एक और 0x00000000004000b0
में एक के।
जब मैं 0x400086
कोशिश, यह सब काम करता है, और वहाँ केवल एक LOAD
खंड है।
- यहाँ क्या हो रहा है?
- मैं कौन से मेमोरी पते चुन सकता हूं, जिन्हें मैं नहीं चुन सकता और क्यों?
धन्यवाद।
मैं भी लिंकर स्क्रिप्ट के साथ प्रवेश बिंदु को संशोधित करने में सक्षम है: http://stackoverflow.com/a/30536800/895245 –