لد-لينوكس (8) - لينوكس مان بادج ld. so، ld-linux. so - ديناميك لينكرلوادر يمكن تشغيل الرابط الديناميكي إما بشكل غير مباشر عن طريق تشغيل بعض البرامج أو المكتبات المرتبطة ديناميكيا (وفي هذه الحالة لا توجد خيارات سطر الأوامر للديناميكية لينكر يمكن أن تنتقل، وفي حالة إلف، يتم تنفيذ الارتباط الديناميكي الذي يتم تخزينه في قسم. interp من البرنامج) أو مباشرة عن طريق تشغيل: libld-linux. so. أوبتيونس بروغرام أراجمنتس وصف البرامج ld. so و ld-linux. so العثور على وتحميل المكتبات المشتركة التي يحتاجها برنامج إعداد البرنامج لتشغيل ثم قم بتشغيله. تتطلب الثنائيات لينكس الربط الديناميكي (ربط في وقت التشغيل) ما لم يتم إعطاء الخيار - static لد (1) أثناء التجميع. البرنامج ld. so يعالج a. out الثنائيات، وهو شكل المستخدمة منذ فترة طويلة ld-linux. so يعالج إلف (libld - linux. so.1 ل libc5، ليبلد-linux. so.2 ل glibc2)، والتي كان الجميع باستخدام منذ سنوات. وإلا فإن كلا منهما له نفس السلوك، واستخدام نفس ملفات الدعم والبرامج لد (1)، لدكونفيغ (8) و etcld. so. conf. عند حل تبعيات المكتبة، يقوم الرابط الديناميكي أولا بفحص كل سلسلة تبعية لمعرفة ما إذا كان يحتوي على شرطة مائلة (يمكن أن يحدث هذا إذا تم تحديد اسم مسار مكتبة يحتوي على سلاشس في وقت الارتباط). في حالة العثور على شرطة مائلة، يتم تفسير سلسلة التبعية كاسم مسار (نسبي أو مطلق)، ويتم تحميل المكتبة باستخدام اسم المسار هذا. في حالة عدم وجود تبعية مكتبة على شرطة مائلة، يتم البحث عنها بالترتيب التالي: o (إلف فقط) استخدام الدلائل المحددة في سمة القسم الديناميكي دترباث للخاصية الثنائية إذا كانت سمة دترونباث الحالية موجودة. تم إيقاف استخدام دترباث. استخدام متغير البيئة لدليبراريباث. إلا إذا كان القابل للتنفيذ هو ثنائي مجموعة-إدسيت-إد-إد ثنائي، وفي هذه الحالة يتم تجاهلها. (إلف فقط) باستخدام الدلائل المحددة في سمة القسم الديناميكي دترونباث للثنائي إذا كان موجودا. من ملف ذاكرة التخزين المؤقت etc. ld. so. cache. الذي يحتوي على قائمة مجمعة من المكتبات المرشحة وجدت سابقا في مسار المكتبة المعززة. إذا، ومع ذلك، تم ربط ثنائي مع الخيار - z نودفليب رابط، يتم تخطي المكتبات في مسارات المكتبة الافتراضية. المكتبات المثبتة في الدلائل القدرة الأجهزة (انظر أدناه) ويفضل المكتبات الأخرى. في المسار الافتراضي ليب. ثم أوسرليب. إذا تم ربط ثنائي مع الخيار - z نودفليب رابط، يتم تخطي هذه الخطوة. أوريجين و رباث ld. so يفهم سلسلة أوريجين (أو ما يعادلها) في مواصفات رباث (دترباث أو دترونباث) يعني الدليل الذي يحتوي على التطبيق القابل للتنفيذ. وهكذا، يمكن تجميع تطبيق يقع في سوميديراب مع غك - Wl، - rpath، ORIGIN..lib بحيث يجد مكتبة مشتركة المرتبطة في سومديرليب بغض النظر عن مكان سومدير يقع في التسلسل الهرمي الدليل. وهذا يسهل إنشاء التطبيقات مفتاح بدوره التي لا تحتاج إلى تثبيت في الدلائل الخاصة، ولكن يمكن بدلا من ذلك تفكيكها في أي دليل ولا تزال تجد المكتبات المشتركة الخاصة بهم. سرد جميع التبعيات وكيفية حلها. - التحقق تحقق من ربط البرنامج ديناميكيا وهذا الرابط الديناميكي يمكن التعامل معها. --library-باث باث استخدم باث بدلا من لدليبراريباث إعداد متغير البيئة (انظر أدناه). --inhibit-رباث ليست تجاهل معلومات رباث و رونباث في أسماء الكائنات في ليست. يتم تجاهل هذا الخيار إذا كان ld. so هو سيت-وسر-إد أو سيت-غروب-إد. - أوديت ليست استخدم الكائنات المسماة في ليست كمدققين. قدرات الأجهزة يتم تجميع بعض المكتبات باستخدام تعليمات الأجهزة الخاصة التي لا توجد على كل وحدة المعالجة المركزية. وينبغي تثبيت هذه المكتبات في أدلة تحدد أسماؤها قدرات الأجهزة المطلوبة، مثل usrlibsse2. يقوم الرابط الديناميكي بالتحقق من هذه الدلائل ضد الأجهزة الخاصة بالجهاز ويختار النسخة الأنسب لمكتبة معينة. يمكن أن تتعاقب الدلائل القدرة الأجهزة إلى الجمع بين ميزات وحدة المعالجة المركزية. تعتمد قائمة أسماء قدرات الأجهزة المدعومة على وحدة المعالجة المركزية. يتم التعرف على الأسماء التالية حاليا: ألفا ev4 و ev5 و ev56 و ev6 و ev67 loongson2e و loongson2f و أوكتون و octeon2 بويرك 4xxmac و ألتيفيك و arch205 و arch206 و بوك و سيلب و دف و إفدوبل و إفسنغل و فبو و إسنوب و ممو و نوتب ، pa6t، power4، power5، power5، power6x، ppc32، ppc601، ppc64، سمت، سب، أوكاش، فسكس سبارك فلوش، مولديف، ستبار، سواب، ultra3، v9، v9v، v9v2 دف، إيم، esan3، etf3enh، g5، هسبرس، هبرس، لديسب، مسا، ستفل، z900، z990، z9-109، z10، زارك x86 (32 بت فقط) أكبي، أبيك، كلفلوش، كموف، cx8، دتس، فكسر، هت، i386، i486، i586، i686، مكا، مكس، متر، بات، بب، بجي، ين، pse36، سيب، سس، سس، sse2، تم البيئة هناك أربعة متغيرات بيئة مهمة. لدبيندنو (libc5 غليبك منذ 2.1.1) إذا تم تعيينه إلى سلسلة غير هام، يؤدي الارتباط الديناميكي إلى حل كافة الرموز عند بدء تشغيل البرنامج بدلا من تأجيل دقة استدعاء الدالة إلى النقطة عند الرجوع إليها أولا. هذا مفيد عند استخدام مصحح أخطاء. لدليبراريباث قائمة مفصولة بقولون من الدلائل التي للبحث عن مكتبات إلف في وقت التنفيذ. على غرار متغير بيئة باث. تم تجاهلها في سيت-وسر-إد و سيت-غروب-إد. لدبريلواد قائمة بالمكتبات الإضافية، المحددة من قبل المستخدم، إلف التي سيتم تحميلها قبل كل الآخرين. يمكن فصل عناصر القائمة بمسافات أو كولون. ويمكن استخدام هذا لتجاوز الوظائف بشكل انتقائي في المكتبات المشتركة الأخرى. يتم البحث عن المكتبات لاستخدام القواعد الواردة تحت دسكريبتيون. بالنسبة إلى الثنائيات إلف-إدج-غروب-إد إلف، يتم تجاهل التحميل المسبق للأسماء التي تحتوي على سلاشس، ويتم تحميل المكتبات في أدلة البحث القياسية فقط إذا تم تمكين بت إذن المستخدم-سيت-إد على ملف المكتبة. لدترسلواددوبجيكتس (إلف فقط) إذا تم تعيينها إلى سلسلة غير نيمبتي، يؤدي البرنامج إلى قائمة تبعيات المكتبة الحيوية، كما لو كان تشغيل بواسطة لد (1)، بدلا من تشغيل بشكل طبيعي. ثم هناك الكثير من المتغيرات الغامضة أكثر أو أقل، العديد من عفا عليها الزمن أو فقط للاستخدام الداخلي. لداوتليبراريباث (libc5) إصدار لدليبراريباث ل a. out ثنائيات فقط. كما دعمت الإصدارات القديمة من لد-linux. so.1 لدلفليبراريباث. لداوتبريلواد (libc5) إصدار لدبريلواد ل a. out الثنائيات فقط. كما دعمت الإصدارات القديمة من لد-linux. so.1 لدلفريلواد. لداوديت (غليبك سينس 2.4) قائمة مفصولة بفصل القولون من العناصر المحددة من قبل المستخدم، إلف التي سيتم تحميلها قبل كل الآخرين في مساحة اسم ارتباط منفصلة (أي تلك التي لا تتدخل على ارتباطات الرموز العادية التي قد تحدث في العملية). ويمكن استخدام هذه المكتبات لتدقيق تشغيل الرابط الديناميكي. يتم تجاهل لداوديت لمجموعة الثنائيات-إدسيت-غروب-إد الثنائيات. سيقوم الرابط الديناميكي بإخطار مكتبات التدقيق في ما يسمى نقاط التفتيش التدقيقية - على سبيل المثال، تحميل مكتبة جديدة، حل رمز، أو استدعاء رمز من كائن مشترك آخر عن طريق استدعاء دالة مناسبة داخل مكتبة التدقيق. لمزيد من التفاصيل، راجع رتلد-أوديت (7). واجهة التدقيق متوافقة إلى حد كبير مع تلك المقدمة على سولاريس، كما هو موضح في دليل لينكر والمكتبات. في الفصل واجهة وقت التشغيل رابط التدقيق. لدبيندنوت (غليبك منذ 2.1.95) لا تقم بتحديث غوت (الجدول العالمي تعويض) و بلت (جدول الربط الإجراء) بعد حل رمز. لديديبوج (غليبك منذ 2.1) إخراج مطول التصحيح المعلومات حول الارتباط الديناميكي. إذا تم تعيينه على كافة المطبوعات كافة معلومات التصحيح، إذا تم تعيينه للمساعدة في طباعة رسالة مساعدة حول الفئات التي يمكن تحديدها في متغير البيئة هذا. منذ غليبك 2.3.4، يتم تجاهل لدديبوج لثلاث مستخدمين إدسيت-غروب-إد الثنائيات. لديبوغوتبوت (غليبك منذ 2.1) ملف حيث يجب أن يتم تغذية الناتج لدديبوج، الافتراضي هو الإخراج القياسية. يتم تجاهل لديبوغوتبوت لثنائيات مجموعة إدسيت-غروب-إد. لديناميكويك (غليبك سينس 2.1.91) السماح بتجاوز الرموز الضعيفة (العودة إلى سلوك غليبك القديم). لأسباب أمنية، منذ غليبك 2.3.4، يتم تجاهل لديناميكويك لثلاث مستخدمين إدسيت مجموعة إد الثنائيات. لدوكابماسك (غليبك منذ 2.1) قناع لقدرات الأجهزة. لدكيبدير (a. out فقط) (libc5) لا تجاهل الدليل في أسماء مكتبات a. out ليتم تحميلها. ولا يشجع استخدام هذا الخيار بشدة. لدنوارن (a. out أونلي) (libc5) قم بقمع التحذيرات حول مكتبات a. out مع أرقام إصدارات ثانوية غير متوافقة. لدوريجينباث (غليبك سينس 2.1) المسار حيث تم العثور على ثنائي (للبرامج غير المحددة للمستخدم معرف). لأسباب أمنية، منذ غليبك 2.4، يتم تجاهل لدوريجينباث لثلاث مستخدمين إدسيت مجموعة إد الثنائيات. لدبوانتيرغوارد (غليبك منذ 2.4) تعيين إلى 0 لتعطيل مؤشر الحراسة. أي قيمة أخرى تمكن مؤشر الحراسة، وهو أيضا الافتراضي. مؤشر الحراسة هو آلية أمنية حيث بعض المؤشرات إلى التعليمات البرمجية المخزنة في ذاكرة برنامج للكتابة (عناوين العودة المحفوظة من قبل سيتيمب (3) أو مؤشرات وظيفة المستخدمة من قبل مختلف غليبك الداخلية) هي مانغلد شبه عشوائي لجعل الأمر أكثر صعوبة للمهاجم لاختطاف مؤشرات للاستخدام في حالة تجاوز المخزن المؤقت أو هجوم تحطيم كومة. لدبروفيل (غليبك منذ 2.1) كائن مشترك أن تكون لمحة، المحدد إما كاسم مسار أو سونام. يتم كتابة إخراج التنميط إلى الملف الذي اسمه: لدبروفيلوتبوت لدبروفيل. profile. لدبروفيلوتبوت (غليبك منذ 2.1) دليل حيث يجب أن تكون مكتوبة الانتاج لدبروفيل. إذا لم يتم تعريف هذا المتغير، أو تم تعريفه على أنه سلسلة فارغة، ثم الافتراضي هو فارتمب. يتم تجاهل لدبروفيلوتبوت ل سيت-وسر-إد و سيت-غروب-إد البرامج التي تستخدم دائما فاربروفيل. لدشووكسف (غليبك منذ 2.1) عرض مجموعة مساعدة مرت من النواة. لأسباب أمنية، منذ غليبك 2.3.5، يتم تجاهل لدشووكسف لثنائيات مجموعة إدسيت-إد-إد. لدوسلوادبياس بشكل افتراضي (بمعنى أنه إذا لم يتم تعريف هذا المتغير) إكسكوتابلز والأجسام المشتركة التي تم ربطها مسبقا ستحترم العناوين الأساسية للمكتبات التابعة لها و (نونبرلينكد) المنفذة للموقف مستقل (بييس) وغيرها من الكائنات المشتركة لن تحترم لهم. إذا تم تعريف لدوسلوادبياس خفة دم القيمة، فإن كل من الملفات التنفيذية و بييس تكريم عناوين قاعدة. إذا تم تعريف لدوسلوادبياس بالقيمة 0، فإن أي من الملفات التنفيذية أو بييس ستحترم عناوين الأساس. يتم تجاهل هذا المتغير بواسطة سيت-وسر-إد و سيت-غروب-إد. لدفيربوس (غليبك سينس 2.1) إذا تم تعيينها إلى سلسلة غير نادرة، رمز الإخراج بإصدار معلومات حول البرنامج إذا تم تعيين لدترسلواددوبجيكتس متغير. لدوارن (إلف فقط) (غليبك منذ 2.1.3) إذا تم تعيينها على سلسلة غير نادرة، تحذير حول رموز لم يتم حلها. LDDARGV0 (libc5) أرجف 0 ليتم استخدامها بواسطة لد (1) عند عدم وجود أي منها. libld. so a. out ديناميك لينكرلوادر libld-linux. so. 1، 2 إلف ديناميك لينكرلوادر etc. ld. so. cache ملف يحتوي على قائمة مجمعة من الدلائل التي للبحث عن المكتبات وقائمة مرتبة من المكتبات المرشحة. إلخld. so. preload ملف يحتوي على قائمة مفصولة بمسافة بيضاء من مكتبات إلف المشتركة يتم تحميلها قبل البرنامج. lib. so المكتبات المشتركة الوظيفة ld. so متاحة للتنفيذية التي تم تجميعها باستخدام ليبك الإصدار 4.4.3 أو أكبر. وظائف إلف متوفرة منذ لينكس 1.1.52 و libc5.هل هناك مجموعة من خيارات سطر الأوامر التي سوف تقنع غك لإنتاج ملف ثنائي مسطح من ملف مصدر بذاته على سبيل المثال، لنفترض محتويات foo. c لا مراجع خارجية، لا شيء للتصدير إلى رابط. معرف ترغب في الحصول على ملف صغير مع مجرد تعليمات الجهاز لهذه الوظيفة، دون أي زخرفة أخرى. نوع مثل ملف (دوس) باستثناء الوضع المحمي 32 بت. طلب 30 أكتوبر 09 في 0:26 الأجوبة الأخرى هي بالتأكيد الطريق للذهاب. ومع ذلك، كان علي تحديد وسيطات سطر الأوامر إضافية إلى أوبجكوبي من أجل إخراج بلدي لتكون كما هو متوقع. لاحظ أن أنا تطوير التعليمات البرمجية 32 بت على جهاز 64 بت، وبالتالي الوسيطة - m32. أيضا، وأنا أحب تركيب الجملة إنتل أفضل، لذلك سترى أن في الحجج كذلك. طيب، هيريس حيث كان لي أن تحديد أنني على وجه التحديد يريد فقط قسم. text: استغرق مني حوالي 2 ساعة من القراءة ومحاولة خيارات مختلفة قبل أن أحسب ذلك. نأمل أن هذا يحفظ شخص آخر ذلك الوقت. يمكنك تمرير الخيارات إلى رابط مباشرة مع - Wl، لتلينكر أوبتيونغت يتم نسخ الوثائق ذات الصلة أدناه من الرجل غك - Wl، الخيار الخيار تمرير كخيار للرابط. إذا كان الخيار يحتوي على فواصل، يتم تقسيمه إلى خيارات متعددة في الفواصل. يمكنك استخدام بناء الجملة هذا لتمرير وسيطة إلى الخيار. على سبيل المثال، - Wl، - Map، output. map يمر - Map output. map إلى رابط. عند استخدام رابط غنو، يمكنك أيضا الحصول على نفس التأثير مع - Wl، - Mapoutput. map. حتى عند تجميع مع غك إذا كنت تمر - Wl، - أوفورماتبيناري سوف تولد ملف ثنائي بدلا من تنسيق قزم. حيث يخبر --oformatbinary لد لتوليد ملف ثنائي. هذا يزيل الحاجة إلى أوبجكوبي بشكل منفصل. لاحظ أن --oformatbinary يمكن التعبير عن أوتبوتفورمات (ثنائي) من داخل البرنامج النصي لينكر. إذا كنت ترغب في التعامل مع الثنائيات شقة، ثيريس فرصة كبيرة أن تستفيد من مستوى عال من السيطرة التي توفر البرامج النصية ربط. أجاب في مايو 04 14 في 18: 40 غنو رابط لد يهدف إلى تغطية مجموعة واسعة من الحالات، وتكون متوافقة قدر الإمكان مع غيرها من لينكرس. ونتيجة لذلك، لديك العديد من الخيارات للتحكم في سلوكه. وفيما يلي ملخص للخيارات التي يمكنك استخدامها على سطر الأوامر لد: قد يبدو هذا العدد الكبير من خيارات سطر الأوامر مخيفا، ولكن في الممارسة الفعلية يتم استخدام القليل منها في أي سياق معين. على سبيل المثال، الاستخدام المتكرر لل لد هو ربط ملفات كائن يونكس القياسية على نظام يونكس قياسي معتمد. على مثل هذا النظام، لربط ملف hello. o. هذا يروي لد لإنتاج ملف يسمى الإخراج نتيجة لربط libcrt0.o الملف مع hello. o ومكتبة libc. a. والتي سوف تأتي من أدلة البحث القياسية. (انظر مناقشة الخيار - l أدناه.) يمكن تحديد خيارات سطر الأوامر إلى لد بأي ترتيب، ويمكن تكرارها عند الإرادة. وتكرار معظم الخيارات مع وسيطة مختلفة إما أن يكون لها أي تأثير آخر، أو تجاوز الأحداث السابقة (تلك إلى اليسار على سطر الأوامر) من هذا الخيار. الاستثناءات - التي قد تستخدم بشكل مفيد أكثر من مرة - هي - A. - b (أو مرادف-تنسيق)، - defsym. - L. - l. - R. - u. و - ((أو مرادفها - مجموعة فرعية).يمكن أن تتبع قائمة ملفات الكائنات التي سيتم ربطها معا، كما هو موضح في أوبجفيل، أو تسبقها أو تكون مختلطة مع خيارات سطر الأوامر، إلا أن وسيطة أوبجفيل قد لا توضع بين خيار وحجة، وعادة ما يتم استدعاء الوصلة بملف كائن واحد على الأقل، ولكن يمكنك تحديد أشكال أخرى من ملفات الإدخال الثنائي باستخدام - l - R ولغة الأمر النصي. إذا لم يكن هناك ملفات الإدخال ثنائي في يتم تحديد كل ارتباط، لا ينتج رابط أي إخراج، ويصدر الرسالة لا توجد ملفات الإدخال، وإذا كان الرابط لا يمكن التعرف على تنسيق ملف كائن، وسوف نفترض أنه هو برنامج نصي لينكر. نصي المحدد بهذه الطريقة أوغمنتس النص البرمجي لينكر الرئيسي المستخدم للرابط (إما البرنامج النصي لينكر الافتراضي أو واحد المحدد باستخدام - T) تسمح هذه الميزة رابط الارتباط ضد ملف الذي يبدو كائن أو أرشيف، ولكن في الواقع مجرد تعريف بعض الرموز أو يستخدم إنبوت أو غروب لتحميل أشياء أخرى نشيط لغة القيادة. بالنسبة للخيارات التي تكون أحرفها حرف واحد، يجب أن تقوم وسيطات الخيار إما باتباع حرف الخيار بدون مسافة بيضاء للتدخل، أو أن تعطى كوسائط منفصلة مباشرة بعد الخيار الذي يتطلبها. بالنسبة للخيارات التي تكون أسماءها أحرفا متعددة، يمكن أن تسبق أي شرطة واحدة أو اثنتين اسم الخيار على سبيل المثال، - تعبير فورمات و - Format مكافئان. يجب أن يتم فصل الوسيطات إلى خيارات متعددة الأحرف من اسم الخيار بواسطة علامة متساوية، أو يتم منحها كوسيطات منفصلة مباشرة بعد الخيار الذي يتطلبها. على سبيل المثال، --oformat سريك و - أوفورماتسريك ما يعادلها. يتم قبول الاختصارات الفريدة لأسماء الخيارات متعددة الأحرف. - b قد يتم تكوين تنسيق الإدخال لد لدعم أكثر من نوع واحد من ملف الكائن. إذا تم تكوين لد الخاص بك بهذه الطريقة، يمكنك استخدام الخيار - b لتحديد تنسيق ثنائي لملفات كائن الإدخال التي تتبع هذا الخيار على سطر الأوامر. حتى عندما يتم تكوين لد لدعم تنسيقات الكائنات البديلة، لا تحتاج عادة لتحديد هذا، كما يجب أن يتم تكوين لد لتوقع شكل تنسيق الإدخال الافتراضي التنسيق الأكثر شيوعا على كل جهاز. إنبوت-فورمات عبارة عن سلسلة نصية، اسم تنسيق معين تدعمه مكتبات بفد. (يمكنك سرد التنسيقات الثنائية المتاحة مع أوبجدومب - i.) - تنسيق الإدخال تنسيق له نفس التأثير، كما يفعل الأمر سكريبت الأمر. انظر القسم بفد. قد تحتاج إلى استخدام هذا الخيار إذا كنت تقوم بربط الملفات بتنسيق ثنائي غير عادي. يمكنك أيضا استخدام - b لتحويل الصيغ بشكل صريح (عند ربط ملفات الكائن بتنسيقات مختلفة)، من خلال تضمين - b تنسيق الإدخال قبل كل مجموعة من ملفات الكائن بتنسيق معين. يتم أخذ التنسيق الافتراضي من متغير البيئة غنوتارجيت. يمكنك أيضا تحديد تنسيق الإدخال من البرنامج النصي، باستخدام الأمر تارجيت راجع القسم أوبتيون كوماندس. - Bstatic لا ربط ضد المكتبات المشتركة. وهذا مفيد فقط على المنصات التي يتم دعم المكتبات المشتركة. ارتباط - Bdynamic ضد المكتبات الديناميكية. وهذا مفيد فقط على المنصات التي يتم دعم المكتبات المشتركة. هذا الخيار هو عادة الافتراضي على هذه المنصات. - Bsymbolic عند إنشاء مكتبة مشتركة، ربط الإشارات إلى رموز عالمية للتعريف داخل المكتبة المشتركة، إن وجدت. عادة، من الممكن لبرنامج مرتبط بمكتبة مشتركة لتجاوز التعريف داخل المكتبة المشتركة. هذا الخيار مفيد فقط على منصات إلف التي تدعم المكتبات المشتركة. - c مري-كوماندفيل للتوافق مع لينكرز التي تنتجها التصوير بالرنين المغناطيسي، لد يقبل ملفات النصي مكتوبة بلغة بديلة، مقيدة الأوامر، الموصوفة في قسم مري الملفات النصية المتوافقة. إدخال ملفات النصي بالرنين المغناطيسي مع الخيار - c استخدام الخيار - T لتشغيل البرامج النصية لينكر مكتوبة في لغة البرمجة العامة للأغراض العامة. إذا لم يكن موجي-ممدفيل موجودا، لد يبحث عنه في الدلائل المحددة من قبل أي - L الخيارات. - d - dc - dp هذه الخيارات الثلاثة هي ما يعادلها أشكال متعددة معتمدة للتوافق مع لينكرز أخرى. وهي تعين مساحة للرموز المشتركة حتى لو تم تحديد ملف ناتج قابل لإعادة التوزيع (مع - r). الأمر سكريبت فورسيكومونالوكاشيون له نفس التأثير. راجع قسم أوامر الخيار. تعبير رمز - defsym إنشاء رمز عام في ملف الإخراج، يحتوي على العنوان المطلق تعطى بواسطة التعبير. يمكنك استخدام هذا الخيار عدة مرات حسب الضرورة لتعريف رموز متعددة في سطر الأوامر. ويدعم شكل محدود من الحساب للتعبير في هذا السياق: قد تعطي ثابت سداسي عشري أو اسم رمز موجود، أو استخدام و - لإضافة أو طرح الثوابت السداسية العشرية أو الرموز. إذا كنت بحاجة إلى تعبيرات أكثر تفصيلا، فكر في استخدام لغة الأمر لينكر من نص برمجي (راجع قسم التعيين: تعريف الرموز). ملاحظة: يجب ألا يكون هناك مسافة بيضاء بين الرمز. علامة يساوي ()، والتعبير. - imedded-ريلوس هذا الخيار مفيد فقط عند ربط ميبس جزءا لا يتجزأ من رمز بيك، التي تم إنشاؤها بواسطة الخيار - membedded الموافقة المسبقة عن علم إلى مترجم غنو والمجمع. يؤدي الارتباط لإنشاء جدول التي يمكن استخدامها في وقت التشغيل لنقل أي البيانات التي تم تهيئة بشكل ثابت لقيم المؤشر. انظر التعليمات البرمجية في تيستسويتلد-إمبيك للحصول على التفاصيل. - e الإدخال استخدم الإدخال كرمز صريح لبدء تنفيذ البرنامج، بدلا من نقطة الإدخال الافتراضية. انظر القسم نقطة الإدخال. لمناقشة حالات التخلف عن السداد وطرق أخرى لتحديد نقطة الدخول. تنسيق - F - F تم تجاهلها. استخدم بعض لينكرز القديمة هذا الخيار في جميع أنحاء أداة توليف تجميع لتحديد تنسيق ملف الكائن لكلا المدخلات والمخرجات ملفات الكائن. يتم استخدام الآليات لد لهذا الغرض (-b أو - خيارات التنسيق لملفات الإدخال أو الخيار - oformat أو الأمر تارجيت في البرامج النصية للوصل لملفات الإخراج ومتغير بيئة غنوتارجيت) تكون أكثر مرونة ولكن لد يقبل الخيار - F ل التوافق مع النصوص المكتوبة لاستدعاء رابط القديم. - format-إنبوت-فورمات مرادف ل - b المدخلات الشكل. - g تم تجاهلها. شريطة التوافق مع الأدوات الأخرى. - G قيمة - G قيمة تعيين الحد الأقصى لحجم الكائنات إلى أن يكون الأمثل باستخدام سجل غب لحجم تحت ميبس إكوف. تم تجاهلها لتنسيقات ملفات الكائنات الأخرى. - help طباعة ملخص للخيارات سطر الأوامر على الإخراج القياسية والخروج. - i قم بتنفيذ ارتباط تزايدي (نفس الخيار - r). - l أر إضافة أرشيف ملف أرشيف إلى قائمة الملفات لربط. يمكن استخدام هذا الخيار في أي عدد من المرات. سوف لد البحث في مسارها قائمة لحدوث ليب أر. أ لكل أرشيف المحدد. - L سيرشدير - L سيرتشدير إضافة سيرتشدير مسار إلى قائمة المسارات التي لد سوف تبحث عن مكتبات الأرشيف و لد السيطرة على البرامج النصية. يمكنك استخدام هذا الخيار أي عدد من المرات. يتم البحث في الدلائل في الترتيب الذي يتم تحديدها على سطر الأوامر. يتم البحث عن الدلائل المحددة في سطر الأوامر قبل الدلائل الافتراضية. تنطبق جميع خيارات - L على جميع الخيارات - l، بغض النظر عن الترتيب الذي تظهر فيه الخيارات. ويمكن أيضا تحديد المسارات في نص برمجي للوصلة مع الأمر سيرتشدير. يتم البحث عن الدلائل المحددة بهذه الطريقة عند النقطة التي يظهر فيها البرنامج النصي لينكر في سطر الأوامر. - M طباعة (إلى الإخراج القياسي) خريطة الارتباط - معلومات تشخيصية حول حيث يتم تعيين الرموز التي كتبها لد. ومعلومات عن تخصيص التخزين المشترك العالمي. - Map مابفيل طباعة إلى ملف مابفيل خريطة الارتباط - معلومات تشخيصية حول حيث يتم تعيين الرموز التي كتبها لد. ومعلومات عن تخصيص التخزين المشترك العالمي. - m مضاهاة محاكاة - m محاكاة مضاهاة رابط. يمكنك سرد المحاكاة المتاحة مع --verbose أو خيارات - V. الافتراضي يعتمد على كيفية تكوين لد الخاص بك. - N تعيين أقسام النص والبيانات لتكون قابلة للقراءة وقابلة للكتابة. أيضا، لا الصفحة محاذاة شريحة البيانات. إذا كان تنسيق الإخراج يدعم أونيكس الأرقام السحر نمط، علامة الإخراج كما أوماجيك. - n قم بتعيين شريحة النص لقراءة فقط، ووضع علامة على الإخراج كما نماجيك إذا كان ذلك ممكنا. - noinhibit-إيكسيك الاحتفاظ ملف الإخراج القابل للتنفيذ كلما كان لا يزال صالحة للاستعمال. عادة، لن يقوم الرابط بإنتاج ملف إخراج إذا واجه أخطاء أثناء عملية الارتباط التي يخرج منها دون كتابة ملف إخراج عندما يصدر أي خطأ على الإطلاق. - no-كيب-ميموري لد يحسن عادة للسرعة على استخدام الذاكرة عن طريق تخزين جداول الرموز لملفات الإدخال في الذاكرة. هذا الخيار يقول لد بدلا من ذلك تحسين استخدام الذاكرة، عن طريق إعادة قراءة جداول الرموز حسب الضرورة. قد يكون هذا مطلوبا إذا تم تشغيل لد من مساحة الذاكرة أثناء ربط كبير قابل للتنفيذ. - o الإخراج استخدام الإخراج كاسم للبرنامج التي تنتجها لد إذا لم يتم تحديد هذا الخيار، يتم استخدام اسم a. out بشكل افتراضي. يمكن أن يقوم الأمر سكريبت أوتبوت أيضا بتحديد اسم ملف الإخراج. قد يتم تكوين تنسيق-تنسيق تنسيق لد لدعم أكثر من نوع واحد من ملف الكائن. إذا تم تكوين لد الخاص بك بهذه الطريقة، يمكنك استخدام الخيار - oformat لتحديد التنسيق الثنائي لملف كائن الإخراج. حتى عندما يتم تكوين لد لدعم تنسيقات الكائنات البديلة، أنت لا تحتاج عادة لتحديد هذا، كما يجب أن يتم تكوين لد لإنتاج كما تنسيق الإخراج الافتراضي التنسيق الأكثر شيوعا على كل جهاز. أوتبوت-فورمات عبارة عن سلسلة نصية، اسم تنسيق معين تدعمه مكتبات بفد. (يمكنك سرد الصيغ الثنائية المتاحة مع أوبجدومب - i.) الأمر سكريبت يمكن أيضا أن يحدد أوتبوتفورمات تنسيق الإخراج، ولكن هذا الخيار يتجاوزه. انظر القسم بفد. - R فلنام قراءة أسماء الرموز وعناوينها من اسم الملف. ولكن لا نقله أو تضمينه في الإخراج. وهذا يسمح ملف الإخراج الخاص بك للإشارة رمزيا إلى مواقع مطلقة من الذاكرة المحددة في برامج أخرى. - relax خيار مع الآثار تعتمد آلة. على بعض الأنظمة الأساسية، يقوم الخيار - relax بإجراء التحسينات العالمية التي تصبح ممكنة عندما يحل رابط الارتباط في البرنامج، مثل وسائط عنوان الاسترخاء وتوليف تعليمات جديدة في ملف كائن الإخراج. - retain-سيمبولس-فيل فلنام الاحتفاظ بالرموز المدرجة في اسم الملف فقط. التخلص من جميع الآخرين. اسم الملف هو مجرد ملف مسطح، مع اسم رمز واحد في كل سطر. هذا الخيار مفيد بشكل خاص في البيئات حيث يتم تجميع جدول رموز عالمي كبير تدريجيا، للحفاظ على الذاكرة وقت التشغيل. - retain-سيمبولس-فيل لا تتجاهل الرموز غير المعرفة، أو الرموز اللازمة لإعادة الترحيل. يمكنك فقط تحديد - retain-سيمبولس-فيل مرة واحدة في سطر الأوامر. ويتجاوز - s و - S. - r توليد الإخراج ريلوكاتابل - أي. توليد ملف الإخراج التي يمكن بدورها بمثابة مدخل إلى لد. وهذا غالبا ما يسمى الربط الجزئي. كآثار جانبية، في البيئات التي تدعم أرقام السحر يونكس القياسية، هذا الخيار أيضا يحدد عدد الملفات المخرجات السحرية إلى أوماجيك. إذا لم يتم تحديد هذا الخيار، يتم إنشاء ملف مطلق. عند ربط برامج C، لن يؤدي هذا الخيار إلى حل الإشارات إلى منشئين للقيام بذلك، استخدم - Ur. هذا الخيار يفعل نفس الشيء - i. - S حذف معلومات رمز المصحح (ولكن ليس كل الرموز) من ملف الإخراج. - s حذف كافة معلومات الرمز من ملف الإخراج. - shared إنشاء مكتبة مشتركة. ويدعم هذا حاليا فقط على منصات إلف و سونوس. في سونوس، سيقوم الرابط تلقائيا بإنشاء مكتبة مشتركة إذا لم يتم استخدام الخيار - e وهناك رموز غير محددة في الرابط. - sort-كومون عادة، عندما يضع لد الرموز المشتركة العالمية في أقسام الإخراج المناسبة، فإنه يصنفها حسب الحجم. يأتي أولا كل رموز بايت واحد، ثم كل بايت اثنين، ثم كل بايت أربعة، ثم كل شيء آخر. هذا هو لمنع الفجوات بين الرموز بسبب قيود المحاذاة. يؤدي هذا الخيار إلى تعطيل هذا التصنيف. - split-بي-ريلوك كونت يحاول إنشاء أقسام إضافية في ملف الإخراج بحيث لا يوجد قسم إخراج واحد في الملف يحتوي على أكثر من إعادة الترحيل العد. وهذا مفيد عند توليد ضخمة ريلوكاتابل للتحميل في بعض حبات الوقت الحقيقي مع تنسيق ملف كوف كوف منذ كوف لا يمكن أن تمثل أكثر من 65535 إعادة التوطين في قسم واحد. لاحظ أن هذا سوف تفشل في العمل مع تنسيقات ملفات الكائن التي لا تدعم المقاطع التعسفية. لن يقسم الوصلة أقسام الإدخال الفردية لإعادة التوزيع، لذلك إذا كان قسم الإدخال الوحيد يحتوي على أكثر من إعادة الترحيل، فسيتضمن قسم إخراج واحد العديد من عمليات النقل. - split-بي-فيل مماثلة ل - split-بي-ريلوك ولكن يخلق قسم إخراج جديد لكل ملف الإدخال. - stats حساب وعرض إحصاءات حول تشغيل رابط، مثل وقت التنفيذ واستخدام الذاكرة. - Tbss أورغ - Tdata أورغ - Ttext أورغ استخدام أورغ كعنوان البداية ل - على التوالي - بس. البيانات. أو الجزء النص من ملف الإخراج. أورغ يجب أن يكون عدد صحيح سداسي عشري واحد للتوافق مع لينكرز أخرى، يمكنك حذف 0x الرائدة عادة المرتبطة بالقيم السداسية العشرية. - T كوماندفيل - T كوماندفيل قراءة الأوامر الارتباط من ملف كوماندفيل. تحل هذه الأوامر محل البرنامج النصي ل ليند الافتراضي (بدلا من الإضافة إليه)، لذا يجب أن يحدد كوماندفيل كل ما هو ضروري لوصف تنسيق الهدف. راجع قسم لغة الأوامر. في حالة عدم وجود كوماندفيل، بد يبحث عن ذلك في الدلائل المحددة من قبل أي خيارات - L السابقة. متعددة - T الخيارات تتراكم. - t طباعة أسماء ملفات الإدخال كما لد العمليات لهم. - traditional-فورمات بالنسبة لبعض الأهداف، خرج لد يختلف في بعض الطرق عن إخراج بعض رابط القائمة. هذا المفتاح يطلب لد لاستخدام التنسيق التقليدي بدلا من ذلك. على سبيل المثال، على سونوس، لد يجمع الإدخالات المكررة في جدول سلسلة الرموز. وهذا يمكن أن تقلل من حجم ملف الإخراج مع معلومات التصحيح الكامل بنسبة أكثر من 30 في المئة. لسوء الحظ، فإن برنامج سونوس دبكس لا يمكن قراءة البرنامج الناتج (غب لا يوجد لديه مشكلة). ويخبر مفتاح - traditional-فورمات لد عدم الجمع بين الإدخالات المكررة. - u رمز القوة الذي سيتم إدخاله في ملف الإخراج كرمز غير معروف. قد يؤدي القيام بذلك، على سبيل المثال، إلى ربط وحدات إضافية من المكتبات القياسية. - u يمكن أن تتكرر مع وسيطات خيارات مختلفة لإدخال رموز إضافية غير معرفة. - أو لأي شيء آخر غير برامج C، هذا الخيار يعادل - r. فإنه يولد الناتج ريلوكاتابل - أي. ملف الإخراج التي يمكن بدورها بمثابة مدخل إلى لد. عند ربط برامج C، - Ur لا حل الإشارات إلى منشئ، على عكس - r. أنها لا تعمل على استخدام - Ur على الملفات التي كانت مرتبطة أنفسهم مع - Ur مرة واحدة وقد تم بناء الجدول منشئ، فإنه لا يمكن أن تضاف إلى. استخدام - Ur فقط لآخر وصلة جزئية، و - r للآخرين. --verbose عرض رقم الإصدار ل لد و قائمة المحاكاة رابط معتمدة. عرض ملفات الإدخال التي يمكن ولا يمكن فتحها. - v - V عرض رقم الإصدار ل لد. يسرد الخيار - V أيضا المحاكاة المدعومة. - version عرض رقم الإصدار ل لد والخروج. - warn-كومون تحذر عندما يتم دمج رمز مشترك مع رمز مشترك آخر أو مع تعريف الرمز. وتسمح وصلات أونيكس بهذه الممارسة القذرة نوعا ما، ولكن الروابط في بعض أنظمة التشغيل الأخرى لا تفعل ذلك. هذا الخيار يسمح لك لإيجاد المشاكل المحتملة من الجمع بين الرموز العالمية. لسوء الحظ، بعض المكتبات C تستخدم هذه الممارسة، لذلك قد تحصل على بعض التحذيرات حول الرموز في المكتبات وكذلك في البرامج الخاصة بك. هناك ثلاثة أنواع من الرموز العالمية، موضحة هنا من الأمثلة C: إنت i 1 تعريف، الذي يذهب في قسم البيانات المبدئية من ملف الإخراج. إكسترن إنت i مرجع غير محدد، لا يخصص مساحة. يجب أن يكون هناك تعريف أو رمز مشترك للمتغير في مكان ما. إنت i رمز شائع. إذا كان هناك فقط (واحد أو أكثر) رموز مشتركة لمتغير، فإنه يذهب في منطقة البيانات غير مهيأ من ملف الإخراج. يربط الوصلة رموز مشتركة متعددة لنفس المتغير في رمز واحد. إذا كانت من أحجام مختلفة، فإنه يختار أكبر حجم. ويحول الرابط رمزا مشتركا إلى إعلان، إذا كان هناك تعريف لنفس المتغير. الخيار - warn المشتركة يمكن أن تنتج خمسة أنواع من التحذيرات. يتكون كل تحذير من زوج من الخطوط: يصف الأول الرمز الذي تمت مواجهته للتو، ويصف الثاني الرمز السابق الذي تمت مصادته بنفس الاسم. واحد أو كل من الرمزين سيكون رمزا شائعا. تحويل رمز مشترك إلى مرجع، لأن هناك بالفعل تعريف للرمز. تحويل رمز مشترك إلى مرجع، لأنه تم التعرف على تعريف لاحق للرمز. هذا هو نفس الحالة السابقة، إلا أن يتم مصادفة الرموز بترتيب مختلف. دمج رمز مشترك برمز مشترك سابق بنفس الحجم. دمج رمز مشترك مع رمز مشترك سابق أكبر. دمج رمز مشترك مع رمز مشترك أصغر السابقة. هذا هو نفس الحالة السابقة، إلا أن يتم مصادفة الرموز بترتيب مختلف. - warn-كونستروكتورس تحذير إذا تم استخدام أي منشئات عالمية. هذا مفيد فقط لبعض تنسيقات ملفات الكائن. بالنسبة إلى تنسيقات مثل كوف أو إلف، لا يمكن للرابط الكشف عن استخدام منشئين عالميين. - warn-مرة فقط تحذير مرة واحدة لكل رمز غير معروف، بدلا من مرة واحدة لكل وحدة الذي يشير إليها. لكل أرشيف المذكور في سطر الأوامر، قم بتضمين كل ملف كائن في الأرشيف في الوصلة، بدلا من البحث في الأرشيف لملفات الكائن المطلوبة. يستخدم هذا عادة لتحويل ملف أرشيف إلى مكتبة مشتركة، مما يجبر كل كائن على تضمينها في المكتبة المشتركة الناتجة. - X حذف جميع الرموز المحلية المؤقتة. بالنسبة إلى معظم الأهداف، هذه هي كل الرموز المحلية التي تبدأ الأسماء ب L. - x حذف كافة الرموز المحلية. - y رمز طباعة اسم كل ملف مرتبط يظهر فيه الرمز. يمكن إعطاء هذا الخيار أي عدد من المرات. على العديد من الأنظمة من الضروري أن يسبق تسطير أسفل السطر. يكون هذا الخيار مفيدا عندما يكون لديك رمز غير معرف في الرابط الخاص بك ولكن لا أعرف من أين يأتي المرجع من. - (أرشيف -) --start-غروب أرتشيفس --end-غروب يجب أن تكون المحفوظات قائمة بملفات الأرشيف. قد تكون إما أسماء الملفات الصريحة، أو - l الخيارات. يتم البحث في الأرشيفات بشكل متكرر حتى لا يتم إنشاء مراجع جديدة غير معرفة. عادة، يتم البحث في الأرشيف مرة واحدة فقط بالترتيب الذي يتم تحديده على سطر الأوامر. إذا كان هناك حاجة إلى رمز في هذا الأرشيف لحل رمز غير معروف المشار إليه بواسطة كائن في أرشيف يظهر لاحقا على سطر الأوامر، فلن يتمكن الرابط من حل هذا المرجع. من خلال تجميع الأرشيفات، يتم البحث فيها بشكل متكرر حتى يتم حل جميع المراجع المحتملة. يؤدي استخدام هذا الخيار إلى تكلفة أداء كبيرة. فمن الأفضل أن تستخدم فقط عندما يكون هناك مراجع دائرية لا مفر منه بين اثنين أو أكثر من المحفوظات. انتقل إلى الأول. سابقة. التالى. القسم الأخير، جدول المحتويات. لينكس و أونيكس لد الأمر لد يجمع بين عدد من الملفات الكائن والأرشيف، يرسل البيانات الخاصة بهم ويربط مراجع الرمز. Usually the last step in compiling a program is to run ld. ld accepts Linker Command Language files written in a superset of ATampT s Link Editor Command Language syntax, to provide explicit and total control over the linking process. For full details on the ld command language, see the ld info page. Here, well cover a broad overview of how to use GNU ld, which is used in most versions of Linux . This version of ld uses the general purpose BFD libraries to operate on object files. This allows ld to read, combine, and write object files in many different formats: for example, COFF or a. out . Different formats may be linked together to produce any available kind of object file. Aside from its flexibility, the GNU linker is more helpful than other linkers in providing diagnostic information. Many linkers abandon execution immediately upon encountering an error whenever possible, ld continues executing, allowing you to identify other errors (or, in some cases, to get an output file in spite of the error). The GNU linker ld is meant to cover a broad range of situations, and to be as compatible as possible with other linkers. As a result, you have many choices to control its behavior. The linker supports many command-line options, but in actual practice few of them are used in any particular context. For instance, a frequent use of ld is to link standard Unix object files on a standard, supported Unix system. On such a system, to link a file hello. o : This tells ld to produce a file called output as the result of linking the file libcrt0.o with hello. o and the library libc. a , which will come from the standard search directories. See the - l option below. Some of the command-line options to ld may be specified at any point in the command line. However, options which refer to files, such as - l or - T . cause the file to be read at the point at which the option appears in the command line, relative to the object files and other file options. Repeating non-file options with a different argument will either have no further effect, or override prior occurrences (those further to the left on the command line) of that option. Options which may be meaningfully specified more than once are noted in the descriptions below. Non-option arguments are object files or archives which are to be linked together. They may follow, precede, or be mixed in with command-line options, except that an object file argument may not be placed between an option and its argument. Usually the linker is invoked with at least one object file, but you can specify other forms of binary input files using - l . - R . and the script command language. If no binary input files at all are specified, the linker does not produce any output, and issues the message No input files . If the linker cannot recognize the format of an object file, it will assume that it is a linker script. A script specified in this way augments the main linker script used for the link (either the default linker script or the one specified by using - T ). This feature permits the linker to link against a file which appears to be an object or an archive. but actually merely defines some symbol values, or uses INPUT or GROUP to load other objects. Specifying a script in this way merely augments the main linker script, with the extra commands placed after the main script use the - T option to replace the default linker script entirely, but note the effect of the INSERT command. For options whose names are a single letter, option arguments must either follow the option letter without intervening whitespace. or be given as separate arguments immediately following the option that requires them. For options whose names are multiple letters, either one dash or two can precede the option name for example, - trace-symbol and --trace-symbol are equivalent. Note that there is one exception to this rule: Multiple letter options that start with a lower case o can only be preceded by two dashes. This is to reduce confusion with the - o option. So for example - omagic sets the output file name to magic whereas --omagic sets the NMAGIC flag on the output. Arguments to multiple-letter options must either be separated from the option name by an equals sign, or be given as separate arguments immediately following the option that requires them. For example, --trace-symbol foo and --trace-symbolfoo are equivalent. Unique abbreviations of the names of multiple-letter options are accepted. Note that if the linker is being invoked indirectly, via a compiler driver (e. g. gcc ) then all the linker command line options should be prefixed by - Wl . (or whatever is appropriate for the particular compiler driver) like this: This is important, because otherwise the compiler driver program may silently drop the linker options, resulting in a bad link. Confusion may also arise when passing options that require values through a driver, as the use of a space between option and argument acts as a separator, and causes the driver to pass only the option to the linker and the argument to the compiler. In this case, it is simplest to use the joined forms of both single - and multiple-letter options, such as: Here is a table of the generic command line switches accepted by the GNU linker: Read command-line options from file . The options read are inserted in place of the original file option. If file does not exist, or cannot be read, then the option will be treated literally, and not removed. Options in file are separated by whitespace. A whitespace character may be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to be included with a backslash. The file may itself contain additional file options any such options will be processed recursively . This option is supported for HP-UX compatibility. The keyword argument must be one of the strings archive . shared . or default . - aarchive is functionally equivalent to - Bstatic . and the other two keywords are functionally equivalent to - Bdynamic . This option may be used any number of times. Adds AUDITLIB to the DTAUDIT entry of the dynamic section. AUDITLIB is not checked for existence, nor will it use the DTSONAME specified in the library. If specified multiple times DTAUDIT will contain a colon separated list of audit interfaces to use. If the linker finds an object with an audit entry while searching for shared libraries, it will add a corresponding DTDEPAUDIT entry in the output file. This option is only meaningful on ELF platforms supporting the rtld-audit interface. In the current release of ld . this option is useful only for the Intel 960 family of architectures. In that ld configuration, the architecture argument identifies the particular architecture in the 960 family, enabling some safeguards and modifying the archive-library search path. Future releases of ld may support similar functionality for other architecture families. ld may be configured to support more than one kind of object file. If your ld is configured this way, you can use the - b option to specify the binary format for input object files that follow this option on the command line. Even when ld is configured to support alternative object formats, you dont usually need to specify this, as ld should be configured to expect as a default input format the most usual format on each machine. input-format is a text string, the name of a particular format supported by the BFD libraries. You can list the available binary formats with objdump - i . You may want to use this option if you are linking files with an unusual binary format. You can also use - b to switch formats explicitly (when linking object files of different formats), by including - b input-format before each group of object files in a particular format. The default format is taken from the environment variable GNUTARGET. You can also define the input format from a script, using the command TARGET For compatibility with linkers produced by MRI, ld accepts script files written in an alternate, restricted command language, described in the MRI Compatible Script Files section of GNU ld documentation. Introduce MRI script files with the option - c use the - T option to run linker scripts written in the general-purpose ld scripting language. If MRI-cmdfile does not exist, ld looks for it in the directories specified by any - L options. These three options are equivalent multiple forms are supported for compatibility with other linkers. They assign space to common symbols even if a relocatable output file is specified (with - r ). The script command FORCECOMMONALLOCATION has the same effect. Adds AUDITLIB to the DTDEPAUDIT entry of the dynamic section. AUDITLIB is not checked for existence, nor will it use the DTSONAME specified in the library. If specified multiple times DTDEPAUDIT will contain a colon separated list of audit interfaces to use. This option is only meaningful on ELF platforms supporting the rtld-audit interface. The - P option is provided for Solaris compatibility. Use entry as the explicit symbol for beginning execution of your program, rather than the default entry point. If there is no symbol named entry . the linker will try to parse entry as a number, and use that as the entry address (the number will be interpreted in base 10 you may use a leading 0x for base 16, or a leading 0 for base 8). Specifies a list of archive libraries from which symbols should not be automatically exported. The library names may be delimited by commas or colons. Specifying --exclude-libs ALL excludes symbols in all archive libraries from automatic export. This option is available only for the i386 PE targeted port of the linker and for ELF targeted ports. For i386 PE, symbols explicitly listed in a. def file are still exported, regardless of this option. For ELF targeted ports, symbols affected by this option will be treated as hidden. Specifies a list of object files or archive members, from which symbols should not be automatically exported, but which should be copied wholesale into the import library being generated during the link. The module names may be delimited by commas or colons, and must match exactly the filenames used by ld to open the files for archive members, this is simply the member name, but for object files the name listed must include and match precisely any path used to specify the input file on the linkers command-line. This option is available only for the i386 PE targeted port of the linker. Symbols explicitly listed in a. def file are still exported, regardless of this option. When creating a dynamically linked executable, using the - E option or the --export-dynamic option causes the linker to add all symbols to the dynamic symbol table. The dynamic symbol table is the set of symbols which are visible from dynamic objects at run time. If you do not use either of these options (or use the --no-export-dynamic option to restore the default behavior), the dynamic symbol table will normally contain only those symbols which are referenced by some dynamic object mentioned in the link. If you use dlopen to load a dynamic object which needs to refer back to the symbols defined by the program, rather than some other dynamic object, then you will probably need to use this option when linking the program itself. You can also use the dynamic list to control what symbols should be added to the dynamic symbol table if the output format supports it. See the description of --dynamic-list . Note that this option is specific to ELF targeted ports. PE targets support a similar function to export all symbols from a DLL or EXE see the description of --export-all-symbols below. Link big-endian objects. This affects the default output format. Link little-endian objects. This affects the default output format. When creating an ELF shared object, set the internal DTAUXILIARY field to the specified name. This tells the dynamic linker that the symbol table of the shared object should be used as an auxiliary filter on the symbol table of the shared object name. If you later link a program against this filter object, then, when you run the program, the dynamic linker will see the DTAUXILIARY field. If the dynamic linker resolves any symbols from the filter object, it will first check whether there is a definition in the shared object name. If there is one, it will be used instead of the definition in the filter object. The shared object name need not exist. Thus the shared object name may be used to provide an alternative implementation of certain functions, perhaps for debugging or for machine specific performance. This option may be specified more than once. The DTAUXILIARY entries will be created in the order in which they appear on the command line. When creating an ELF shared object, set the internal DTFILTER field to the specified name. This tells the dynamic linker that the symbol table of the shared object which is being created should be used as a filter on the symbol table of the shared object name. If you later link a program against this filter object, then, when you run the program, the dynamic linker will see the DTFILTER field. The dynamic linker will resolve symbols according to the symbol table of the filter object as usual, but it will actually link to the definitions found in the shared object name. Thus the filter object can be used to select a subset of the symbols provided by the object name. Some older linkers used the - F option throughout a compilation toolchain for specifying object-file format for both input and output object files. The GNU linker uses other mechanisms for this purpose: the - b . --format . --oformat options, the TARGET command in linker scripts, and the GNUTARGET environment variable. The GNU linker will ignore the - F option when not creating an ELF shared object. When creating an ELF executable or shared object, call NAME when the executable or shared object is unloaded, by setting DTFINI to the address of the function. By default, the linker uses fini as the function to call. Ignored. Provided for compatibility with other tools. Set the maximum size of objects to be optimized using the GP register to size. This is only meaningful for object file formats such as MIPS ECOFF which supports putting large and small objects into different sections. This is ignored for other object file formats. When creating an ELF shared object, set the internal DTSONAME field to the specified name. When an executable is linked with a shared object which has a DTSONAME field, then when the executable is run the dynamic linker will attempt to load the shared object specified by the DTSONAME field rather than the using the file name given to the linker. Perform an incremental link (same as option - r ). When creating an ELF executable or shared object, call NAME when the executable or shared object is loaded, by setting DTINIT to the address of the function. By default, the linker uses init as the function to call. Add the archive or object file specified by namespec to the list of files to link. This option may be used any number of times. If namespec is of the form : filename . ld will search the library path for a file called filename . otherwise it will search the library path for a file called lib namespec. a . On systems which support shared libraries, ld may also search for files other than lib namespec. a . Specifically, on ELF and SunOS systems, ld will search a directory for a library called lib namespec. so before searching for one called lib namespec. a . By convention, a. so extension indicates a shared library. Note that this behavior does not apply to : filename . which always specifies a file called filename . The linker will search an archive only once, at the location where it is specified on the command line. If the archive defines a symbol which was undefined in some object which appeared before the archive on the command line, the linker will include the appropriate file(s) from the archive. However, an undefined symbol in an object appearing later on the command line will not cause the linker to search the archive again. See the -( option for a way to force the linker to search archives multiple times. You may list the same archive multiple times on the command line. This type of archive searching is standard for Unix linkers. However, if you are using ld on AIX. note that it is different from the behaviour of the AIX linker. Add path searchdir to the list of paths that ld will search for archive libraries and ld control scripts. You may use this option any number of times. The directories are searched in the order in which they are specified on the command line. Directories specified on the command line are searched before the default directories. All - L options apply to all - l options, regardless of the order in which the options appear. - L options do not affect how ld searches for a linker script unless - T option is specified. If searchdir begins with , then the will be replaced by the sysroot prefix, a path specified when the linker is configured. The default set of paths searched (without bei ng specified with - L ) depends on which emulation mode ld is using, and in some cases also on how it was configured at build time. The paths can also be specified in a link script with the SEARCHDIR command. Directories specified this way are searched at the point in which the linker script appears in the command line. Emulate the emulation linker. You can list the available emulations with the --verbose or - V options. If the - m option is not used, the emulation is taken from the LDEMULATION environment variable, if that is defined. Otherwise, the default emulation depends upon how the linker was configured. Print a link map to the standard output. A link map provides information about the link, including the following: Where object files are mapped into memory. How common symbols are allocated. All archive members included in the link, with a mention of the symbol which caused the archive member to be brought in. The values assigned to symbols. Note: symbols whose values are computed by an expression which involves a reference to a previous value of the same symbol may not have correct result displayed in the link map. This is because the linker discards intermediate results and only retains the final value of an expression. Under such circumstances the linker will display the final value enclosed by square brackets. Thus for example a linker script containing:will produce the following output in the link map if the - M option is used: Turn off page alignment of sections, and disable linking against shared libraries. If the output format supports Unix style magic numbers, mark the output as NMAGIC. Set the text and data sections to be readable and writable. Also, do not page-align the data segment, and disable linking against shared libraries. If the output format supports Unix style magic numbers, mark the output as OMAGIC. Note: Although a writable text section is allowed for PE-COFF targets, it does not conform to the format specification published by Microsoft . This option negates most of the effects of the - N option. It sets the text section to be read-only, and forces the data segment to be page-aligned. Note - this option does not enable linking against shared libraries. Use - Bdynamic for this. Use output as the name for the program produced by ld if this option is not specified, the name a. out is used by default. The script command OUTPUT can also specify the output file name. If level is a numeric value greater than zero ld optimizes the output. This might take significantly longer and therefore probably should only be enabled for the final binary. At the moment this option only affects ELF shared library generation. Future releases of the linker may make more use of this option. Also currently there is no difference in the linkers behaviour for different non-zero values of this option. Again this may change with future releases. Leave relocation sections and contents in fully linked executables. Post link analysis and optimization tools may need this information in order to perform correct modifications of executables. This results in larger executables. This option is currently only supported on ELF platforms. Force the output file to have dynamic sections. This option is specific to VxWorks targets. Generate relocatable output: i. e. generate an output file that can in turn serve as input to ld . This is often called partial linking. As a side effect, in environments that support standard Unix magic numbers, this option also sets the output files magic number to OMAGIC. If this option is not specified, an absolute file is produced. When linking C programs, this option will not resolve references to constructors to do that, use - Ur . When an input file does not have the same format as the output file, partial linking is only supported if that input file does not contain any relocations. Different output formats can have further restrictions for example some a. out - based formats do not support partial linking with input files in other formats at all. This option does the same thing as - i . Read symbol names and their addresses from filename . but do not relocate it or include it in the output. This allows your output file to refer symbolically to absolute locations of memory defined in other programs. You may use this option more than once. For compatibility with other ELF linkers, if the - R option is followed by a directory name, rather than a file name, it is treated as the - rpath option. Omit all symbol information from the output file. Use scriptfile as the linker script. This script replaces ld s default linker script (rather than adding to it), so commandfile must specify everything necessary to describe the output file. If scriptfile does not exist in the current directory, ld looks for it in the directories specified by any preceding - L options. Multiple - T options accumulate. Use scriptfile as the default linker script. This option is similar to the --script option except that processing of the script is delayed until after the rest of the command line has been processed. This allows options placed after the --default-script option on the command line to affect the behaviour of the linker script, which can be important when the linker command line cannot be directly controlled by the user. (e. g. because the command line is being constructed by another tool, such as gcc ). Force symbol to be entered in the output file as an undefined symbol. Doing this may, for example, trigger linking of additional modules from standard libraries. - u may be repeated with different option arguments to enter additional undefined symbols. This option is equivalent to the EXTERN linker script command. For anything other than C programs, this option is equivalent to - r . it generates relocatable output i. e. an output file that can in turn serve as input to ld . When linking C programs, - Ur does resolve references to constructors, unlike - r . It does not work to use - Ur on files that were themselves linked with - Ur once the constructor table has been built, it cannot be added to. Use - Ur only for the last partial link, and - r for the others. Creates a separate output section for every input section matching SECTION, or if the optional wildcard SECTION argument is missing, for every orphan input section. An orphan section is one not specifically mentioned in a linker script. You may use this option multiple times on the command line It prevents the normal merging of input sections with the same name, overriding output section assignments in a linker script. Display the version number for ld . The - V option also lists the supported emulations. Other keywords are ignored for Solaris compatibility. --start-group archives --end-group The archives should be a list of archive files. They may be either explicit file names, or - l options. The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line. If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference. By grouping the archives, they all be searched repeatedly until all possible references are resolved. Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives. Tells the linker to accept input files whose architecture cannot be recognised. The assumption is that the user knows what they are doing and deliberately wants to link in these unknown input files. This was the default behaviour of the linker, before release 2.14. The default behaviour from release 2.14 onwards is to reject such input files, and so the --accept-unknown-input-arch option has been added to restore the old behaviour. This option affects ELF DTNEEDED tags for dynamic libraries mentioned on the command line after the --as-needed option. Normally the linker will add a DTNEEDED tag for each dynamic library mentioned on the command line, regardless of whether the library is actually needed or not. --as-needed causes a DTNEEDED tag to only be emitted for a library that satisfies an undefined symbol reference from a regular object file or, if the library is not found in the DTNEEDED lists of other libraries linked up to that point, an undefined symbol reference from another dynamic library. --no-as-needed restores the default behaviour. These two options have been deprecated because of the similarity of their names to the --as-needed and --no-as-needed options. They have been replaced by --copy-dt-needed-entries and --no-copy-dt-needed-entries . This option is ignored for SunOS compatibility. Link against dynamic libraries. This is only meaningful on platforms for which shared libraries are supported. This option is normally the default on such platforms. The different variants of this option are for compatibility with various systems. You may use this option multiple times on the command line: it affects library searching for - l options which follow it. Set the DF1GROUP flag in the DTFLAGS1 entry in the dynamic section. This causes the runtime linker to handle lookups in this object and its dependencies to be performed only inside the group. --unresolved-symbolsreport-all is implied. This option is only meaningful on ELF platforms which support shared libraries. Do not link against shared libraries. This is only meaningful on platforms for which shared libraries are supported. The different variants of this option are for compatibility with various systems. You may use this option multiple times on the command line: it affects library searching for - l options which follow it. This option also implies --unresolved-symbolsreport-all . This option can be used with - shared . Doing so means that a shared library is being created but that all of the librarys external references must be resolved by pulling in entries from static libraries. When creating a shared library, bind references to global symbols to the definition within the shared library, if any. Normally, it is possible for a program linked against a shared library to override the definition within the shared library. This option is only meaningful on ELF platforms which support shared libraries. When creating a shared library, bind references to global function symbols to the definition within the shared library, if any. This option is only meaningful on ELF platforms which support shared libraries. Specify the name of a dynamic list file to the linker. This is typically used when creating shared libraries to specify a list of global symbols whose references shouldnt be bound to the definition within the shared library, or creating dynamically linked executables to specify a list of symbols which should be added to the symbol table in the executable. This option is only meaningful on ELF platforms which support shared libraries. The format of the dynamic list is the same as the version node without scope and node name. Include all global data symbols to the dynamic list. Provide the builtin dynamic list for C operator new and delete. It is mainly useful for building shared libstdc. Provide the builtin dynamic list for C runtime type identification. Asks the linker not to check section addresses after they have been assigned to see if there are any overlaps. Normally the linker will perform this check, and if it finds any overlaps it will produce suitable error messages. The linker does know about, and does make allowances for sections in overlays. The default behaviour can be restored by using the command line switch --check-sections . Section overlap is not usually checked for relocatable links. You can force checking in that case by using the --check-sections option. This option affects the treatment of dynamic libraries referred to by DTNEEDED tags inside ELF dynamic libraries mentioned on the command line. Normally the linker wont add a DTNEEDED tag to the output binary for each library mentioned in a DTNEEDED tag in an input dynamic library. With --copy-dt-needed-entries specified on the command line however any dynamic libraries that follow it will have their DTNEEDED entries added. The default behaviour can be restored with --no-copy-dt-needed-entries . This option also has an effect on the resolution of symbols in dynamic libraries. With --copy-dt-needed-entries dynamic libraries mentioned on the command line will be recursively searched, following their DTNEEDED tags to other libraries, in order to resolve symbols required by the output binary. With the default setting however the searching of dynamic libraries that follow it will stop with the dynamic library itself. No DTNEEDED links will be traversed to resolve symbols. Output a cross reference table. If a linker map file is being generated, the cross reference table is printed to the map file. Otherwise, it is printed on the standard output. The format of the table is intentionally simple, so that it may be easily processed by a script if necessary. The symbols are printed out, sorted by name. For each symbol, a list of file names is given. If the symbol is defined, the first file listed is the location of the definition. The remaining files contain references to the symbol. This option inhibits the assignment of addresses to common symbols. The script command INHIBITCOMMONALLOCATION has the same effect. The --no-define-common option allows decoupling the decision to assign addresses to Common symbols from the choice of the output file type otherwise a non-Relocatable output type forces assigning addresses to Common symbols. Using --no-define-common allows Common symbols that are referenced from a shared library to be assigned addresses only in the main program. This eliminates the unused duplicate space in the shared library, and also prevents any possible confusion over resolving to the wrong duplicate when there are many dynamic modules with specialized search paths for runtime symbol resolution. Create a global symbol in the output file, containing the absolute address given by expression . You may use this option as many times as necessary to define multiple symbols in the command line. A limited form of arithmetic is supported for the expression in this context: you may give a hexadecimal constant or the name of an existing symbol, or use and - to add or subtract hexadecimal constants or symbols. If you need more elaborate expressions, consider using the linker command language from a script. Note: there should be no white space between symbol, the equals sign ( ), and expression . These options control whether to demangle symbol names in error messages and other output. When the linker is told to demangle, it tries to present symbol names in a readable fashion: it strips leading underscores if they are used by the object file format, and converts C mangled symbol names into user readable names. Different compilers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler. The linker will demangle by default unless the environment variable COLLECTNODEMANGLE is set. These options may be used to override the default. Set the name of the dynamic linker. This is only meaningful when generating dynamically linked ELF executables. The default dynamic linker is normally correct dont use this unless you know what you are doing. Treat all warnings as errors. The default behaviour can be restored with the option --no-fatal-warnings . Make sure that an output file has a. exe suffix. If a successfully built fully linked output file does not have a. exe or. dll suffix, this option forces the linker to copy the output file to one of the same name with a. exe suffix. This option is useful when using unmodified Unix makefiles on a Microsoft Windows host, since some versions of Windows wont run an image unless it ends in a. exe suffix. Enable garbage collection of unused input sections. It is ignored on targets that do not support this option. The default behaviour (of not performing this garbage collection) can be restored by specifying --no-gc-sections on the command line. --gc-sections decides which input sections are used by examining symbols and relocations. The section containing the entry symbol and all sections containing symbols undefined on the command-line will be kept, as will sections containing symbols referenced by dynamic objects. Note that when building shared libraries, the linker must assume that any visible symbol is referenced. Once this initial set of sections has been determined, the linker recursively marks as used any section referenced by their relocations. See --entry and --undefined . This option can be set when doing a partial link (enabled with option - r ). In this case the root of symbols kept must be explicitly specified either by an --entry or --undefined option or by a ENTRY command in the linker script. List all sections removed by garbage collection. The listing is printed on stderr. This option is only effective if garbage collection has been enabled via the --gc-sections ) option. The default behaviour (of not listing the sections that are removed) can be restored by specifying --no-print-gc-sections on the command line. Print the name of the default output format (perhaps influenced by other command-line options). This is the string that would appear in an OUTPUTFORMAT linker script command. Print a summary of the command-line options on the standard output and exit. Report unresolved symbols that are contained in shared libraries, but ignore them if they come from regular object files. Report unresolved symbols that come from regular object files, but ignore them if they come from shared libraries. This can be useful when creating a dynamic binary and it is known that all the shared libraries that it should be referencing are included on the linkers command line. The behaviour for shared libraries on their own can also be controlled by the -- no - allow-shlib-undefined option. Normally the linker will generate an error message for each reported unresolved symbol but the option --warn-unresolved-symbols can change this to a warning. Display the version number for ld and list the linker emulations supported. Display which input files can and cannot be opened. Display the linker script being used by the linker. If the optional NUMBER argument gt 1 . plugin symbol status will also be displayed. Specify the name of a version script to the linker. This is typically used when creating shared libraries to specify additional information about the version hierarchy for the library being created. This option is only fully supported on ELF platforms which support shared libraries. It is partially supported on PE platforms, which can use version scripts to filter symbol visibility in auto-export mode: any symbols marked local in the version script will not be exported. Warn when a common symbol is combined with another common symbol or with a symbol definition. Unix linkers allow this somewhat sloppy practice, but linkers on some other operating systems do not. This option allows you to find potential problems from combining global symbols. Unfortunately, some C libraries use this practice, so you may get some warnings about symbols in the libraries as well as in your programs. There are three kinds of global symbols, illustrated here by C examples: A definition, which goes in the initialized data section of the output file. An undefined reference, which does not allocate space. There must be either a definition or a common symbol for the variable somewhere. A common symbol. If there are only (one or more) common symbols for a variable, it goes in the uninitialized data area of the output file. The linker merges multiple common symbols for the same variable into a single symbol. If they are of different sizes, it picks the largest size. The linker turns a common symbol into a declaration, if there is a definition of the same variable. The --warn-common option can produce five kinds of warnings. Each warning consists of a pair of lines: the first describes the symbol just encountered, and the second describes the previous symbol encountered with the same name. One or both of the two symbols will be a common symbol. 1. Turning a common symbol into a reference, because there is already a definition for the symbol. 2. Turning a common symbol into a reference, because a later definition for the symbol is encountered. This is the same as the previous case, except that the symbols are encountered in a different order. 3. Merging a common symbol with a previous same-sized common symbol. 4. Merging a common symbol with a previous larger common symbol. 5. Merging a common symbol with a previous smaller common symbol. This is the same as the previous case, except that the symbols are encountered in a different order. Warn if any global constructors are used. This is only useful for a few object file formats. For formats like COFF or ELF, the linker can not detect the use of global constructors. Warn if multiple global pointer values are required in the output file. This is only meaningful for certain processors, such as the DEC Alpha. Specifically, some processors put large-valued constants in a special section. A special register (the global pointer) points into the middle of this section, so that constants can be loaded efficiently via a base-register relative addressing mode. Since the offset in base-register relative mode is fixed and relatively small (e. g. 16 bits ), this limits the maximum size of the constant pool. Thus, in large programs, it is often necessary to use multiple global pointer values in order to be able to address all possible constants. This option causes a warning to be issued whenever this case occurs. Only warn once for each undefined symbol, rather than once per module which refers to it. Warn if the address of an output section is changed because of alignment. Typically, the alignment will be set by an input section. The address will only be changed if it not explicitly specified that is, if the SECTIONS command does not specify a start address for the section. Warn if the linker adds a DTTEXTREL to a shared object.
Comments
Post a Comment