Thursday 18 May 2017

Ld Ausgabe Format Binär Optionen


Ld-linux (8) - Linux man page ld. so, ld-linux. so - dynamischer Linkerloader Der dynamische Linker kann entweder indirekt ausgeführt werden, indem man ein dynamisch verknüpftes Programm oder eine Bibliothek ausführt (in diesem Fall keine Befehlszeilenoptionen auf die Dynamik Linker kann übergeben werden, und im ELF-Fall wird der dynamische Linker, der im. interp-Bereich des Programms gespeichert ist, ausgeführt) oder direkt durch Ausführen: libld-linux. so. OPTIONEN PROGRAMM ARGUMENTE Beschreibung Die Programme ld. so und ld-linux. so finden und laden die freigegebenen Bibliotheken, die von einem Programm benötigt werden, das Programm vorbereiten, um es auszuführen und dann auszuführen. Linux-Binärdateien benötigen eine dynamische Verknüpfung (Verknüpfung zur Laufzeit), es sei denn, die Option - Status wurde bei der Kompilierung auf ld (1) gegeben. Das Programm ld. so behandelt a. out Binärdateien, ein Format, das vor langer Zeit verwendet wurde. Ld-linux. so verarbeitet ELF (libld-linux. so.1 für libc5, libld-linux. so.2 für glibc2), die jeder benutzt hat Seit Jahren Andernfalls haben beide das gleiche Verhalten und verwenden die gleichen Unterstützungsdateien und Programme ldd (1), ldconfig (8) und etcld. so. conf. Beim Auflösen von Bibliotheksabhängigkeiten prüft der dynamische Linker zuerst jede Abhängigkeitsfolge, um zu sehen, ob er einen Schrägstrich enthält (dies kann auftreten, wenn ein Bibliothekspfadname mit Schrägstrichen bei der Verbindungszeit angegeben wurde). Wenn ein Schrägstrich gefunden wird, wird der Abhängigkeitsstring als ein (relativer oder absoluter) Pfadname interpretiert und die Bibliothek wird mit diesem Pfadnamen geladen. Wenn eine Bibliotheksabhängigkeit keinen Schrägstrich enthält, wird sie in der folgenden Reihenfolge gesucht: o (nur ELF) Die im DTRPATH-Dynamikbereich Attribut des Binärs angegebenen Verzeichnisse, falls vorhanden und DTRUNPATH-Attribut nicht vorhanden ist. Die Verwendung von DTRPATH ist veraltet. Mit der Umgebungsvariablen LDLIBRARYPATH. Außer wenn die ausführbare Datei eine set-user-IDset-group-ID binary ist, wird in diesem Fall ignoriert. (Nur ELF) Mit den im DTRUNPATH-Dynamikbereich Attribut der Binärdatei angegebenen Verzeichnissen, falls vorhanden. Aus der Cache-Datei etcld. so. cache. Die eine kompilierte Liste von Kandidatenbibliotheken enthält, die zuvor im erweiterten Bibliothekspfad gefunden wurden. Wenn jedoch die Binärdatei mit der Option - z nodeflib linker verknüpft ist, werden Bibliotheken in den Standardbibliothekspfaden übersprungen. Bibliotheken, die in Hardware-Fähigkeitsverzeichnissen installiert sind (siehe unten), werden anderen Bibliotheken bevorzugt. Im Standardpfad lib. Und dann usrlib. Wenn die Binärdatei mit der Option - z nodeflib linker verknüpft wurde, wird dieser Schritt übersprungen. ORIGIN und rpath ld. so versteht die Zeichenfolge ORIGIN (oder äquivalent) in einer rpath-Spezifikation (DTRPATH oder DTRUNPATH), um das Verzeichnis zu verstehen, das die ausführbare Datei enthält. So könnte eine Anwendung, die sich in somedirapp befindet, mit gcc - Wl, - rpath, ORIGIN..lib kompiliert werden, so dass sie eine zugehörige shared library in somedirlib findet, egal wo somedir sich in der Verzeichnishierarchie befindet. Dies erleichtert die Erstellung von schlüsselfertigen Anwendungen, die nicht in spezielle Verzeichnisse eingebaut werden müssen, sondern stattdessen in jedes Verzeichnis entpackt werden können und immer noch eigene gemeinsame Bibliotheken finden. Alle Abhängigkeiten auflisten und wie sie aufgelöst werden. --verifizieren Vergewissern Sie sich, dass das Programm dynamisch verknüpft ist und dieser dynamische Linker damit umgehen kann. --library-path PATH Verwenden Sie PATH anstelle der LDLIBRARYPATH Umgebungsvariableneinstellung (siehe unten). --inhibit-rpath LIST Ignoriere RPATH - und RUNPATH-Informationen in Objektnamen in LIST. Diese Option wird ignoriert, wenn ld. so set-user-ID oder set-group-ID ist. --Audit LIST Verwenden Sie Objekte, die in LIST als Auditoren benannt sind. Hardware-Funktionen Einige Bibliotheken werden mit hardware-spezifischen Anweisungen kompiliert, die auf keiner CPU vorhanden sind. Solche Bibliotheken sollten in Verzeichnissen installiert werden, deren Namen die erforderlichen Hardware-Fähigkeiten wie usrlibsse2 definieren. Der dynamische Linker prüft diese Verzeichnisse auf die Hardware der Maschine und wählt die am besten geeignete Version einer bestimmten Bibliothek aus. Hardware-Fähigkeitsverzeichnisse können kaskadiert werden, um CPU-Features zu kombinieren. Die Liste der unterstützten Hardware-Fähigkeitsnamen hängt von der CPU ab. Die folgenden Namen werden derzeit erkannt: Alpha ev4, ev5, ev56, ev6, ​​ev67 loongson2e, loongson2f, octeon, octeon2 PowerPC 4xxmac, altivec, arch205, arch206, booke, cellbe, dfp, efpdouble, efpsingle, fpu, icsnoop, mmu, notb , Pa3t, power4, power5, power5, power6x, ppc32, ppc601, ppc64, smt, spe, ucache, vsx SPARC flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2 dfp, eimm, esan3, etf3enh, g5, (32-Bit nur) acpi, apic, clblush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, z100, z909, z100, I686, mca, mmx, mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm Umfeld Es gibt vier wichtige Umgebungsvariablen. LDBINDNOW (libc5 glibc seit 2.1.1) Wenn auf einen nicht leeren String gesetzt, bewirkt der dynamische Linker, alle Symbole beim Programmstart aufzulösen, anstatt die Funktion Aufrufauflösung auf den Punkt zu setzen, an dem sie zuerst referenziert werden. Dies ist nützlich bei der Verwendung eines Debuggers. LDLIBRARYPATH Eine durch Doppelpunkt getrennte Liste von Verzeichnissen, in denen nach ELF-Bibliotheken zur Ausführungszeit gesucht werden kann. Ähnlich wie die Umgebungsvariable PATH. Ignoriert in Set-User-ID und Set-Group-ID-Programmen. LDPRELOAD Eine Liste von zusätzlichen, benutzerdefinierten, ELF-geteilten Bibliotheken, die vor allen anderen geladen werden sollen. Die Einträge der Liste können durch Leerzeichen oder Doppelpunkte getrennt werden. Dies kann verwendet werden, um Funktionen in anderen gemeinsam genutzten Bibliotheken selektiv zu überschreiben. Die Bibliotheken werden nach den Regeln unter BESCHREIBUNG gesucht. Für set-user-IDset-group-ID ELF-Binärdateien werden Preload-Pfadnamen mit Schrägstrichen ignoriert und Bibliotheken in den Standard-Suchverzeichnissen werden nur geladen, wenn das Set-User-ID-Berechtigungsbit in der Bibliotheksdatei aktiviert ist. LDTRACELOADEDOBJECTS (nur ELF) Wenn Sie auf einen nicht leeren String setzen, veranlasst das Programm, seine dynamischen Bibliotheksabhängigkeiten aufzulisten, als ob er von ldd (1) ausgeführt wird, anstatt normal zu laufen. Dann gibt es viele mehr oder weniger obskure Variablen, viele veraltet oder nur für den internen Gebrauch. LDAOUTLIBRARYPATH (libc5) Version von LDLIBRARYPATH nur für nur Binärdateien. Alte Versionen von ld-linux. so.1 unterstützten auch LDELFLIBRARYPATH. LDAOUTPRELOAD (libc5) Version von LDPRELOAD nur für nur Binärdateien. Alte Versionen von ld-linux. so.1 unterstützten auch LDELFPRELOAD. LDAUDIT (glibc seit 2.4) Eine von der Dickdarm getrennte Liste von benutzerdefinierten ELF-freigegebenen Objekten, die vor allen anderen in einem separaten Linker-Namespace geladen werden sollen (d. h. eine, die nicht auf die normalen Symbolbindungen stößt, die im Prozess auftreten würden). Diese Bibliotheken können verwendet werden, um den Betrieb des dynamischen Linkers zu überprüfen. LDAUDIT wird für set-user-IDset-group-ID-Binärdateien ignoriert. Der dynamische Linker benachrichtigt die Audit-Bibliotheken an so genannten Auditing-Checkpoints - z. B. das Laden einer neuen Bibliothek, das Auflösen eines Symbols oder das Aufrufen eines Symbols aus einem anderen freigegebenen Objekt - durch Aufruf einer entsprechenden Funktion innerhalb der Audit-Bibliothek. Weitere Informationen finden Sie unter rtld-audit (7). Die Audit-Schnittstelle ist weitgehend kompatibel mit der, die auf Solaris bereitgestellt wird, wie in ihrem Linker - und Bibliotheksleitfaden beschrieben. Im Kapitel Runtime Linker Auditing Interface. LDBINDNOT (glibc seit 2.1.95) Aktualisiere die GOT (Global Offset Table) und PLT (Prozedur Verknüpfungstabelle) nach dem Auflösen eines Symbols nicht. LDDEBUG (glibc seit 2.1) Ausgabe von ausführlichen Debugging-Informationen über den dynamischen Linker. Wenn auf alle Drucke alle Debugging-Informationen, die es hat, druckt, wird eine Hilfemeldung ausgegeben, über welche Kategorien in dieser Umgebungsvariablen angegeben werden können. Da glibc 2.3.4 wird LDDEBUG für set-user-IDset-group-ID-Binärdateien ignoriert. LDDEBUGOUTPUT (glibc seit 2.1) Datei, in die LDDEBUG-Ausgang eingegeben werden soll, Standard ist Standardausgabe. LDDEBUGOUTPUT wird für set-user-IDset-group-ID-Binärdateien ignoriert. LDDYNAMICWEAK (glibc seit 2.1.91) Erlaube schwache Symbole zu überschreiben (Rückkehr zum alten Glibc-Verhalten). Aus Sicherheitsgründen, da glibc 2.3.4, wird LDDYNAMICWEAK für set-user-IDset-group-ID-Binärdateien ignoriert. LDHWCAPMASK (glibc seit 2.1) Maske für Hardware-Fähigkeiten. LDKEEPDIR (nur a. out) (libc5) Dont ignoriere das Verzeichnis in den Namen von a. out Bibliotheken, die geladen werden sollen. Die Verwendung dieser Option ist stark entmutigt. LDNOWARN (nur a. out only) (libc5) Unterdrücken von Warnungen über a. out Bibliotheken mit inkompatiblen kleinen Versionsnummern. LDORIGINPATH (glibc seit 2.1) Pfad, wo die Binärdatei gefunden wird (für Nicht-Set-User-ID-Programme). Aus Sicherheitsgründen, da glibc 2.4, wird LDORIGINPATH für set-user-IDset-group-ID-Binärdateien ignoriert. LDPOINTERGUARD (glibc seit 2.4) Auf 0 setzen, um die Zeigerüberwachung zu deaktivieren. Jeder andere Wert ermöglicht die Zeigerüberwachung, die auch der Standard ist. Zeiger-Bewachung ist ein Sicherheitsmechanismus, bei dem einige Zeiger auf Code, die in einem beschreibbaren Programmspeicher gespeichert sind (Rücksendeadressen, die durch setjmp (3) oder Funktionszeiger, die von verschiedenen Glibc-Internaten verwendet werden, gespeichert sind, halb zufällig verstrickt sind, um es einem Angreifer zu erschrecken, Zeiger für den Einsatz im Falle eines Pufferüberlaufs oder Stack-Smashing-Angriff. LDPROFILE (glibc seit 2.1) Gemeinsames Objekt, das profiliert werden soll, wird entweder als Pfadname oder als Soname angegeben. Profiling-Ausgabe wird in die Datei geschrieben, deren Name ist: LDPROFILEOUTPUT LDPROFILE. profile. LDPROFILEOUTPUT (glibc seit 2.1) Verzeichnis wo LDPROFILE Ausgabe geschrieben werden soll. Wenn diese Variable nicht definiert ist oder als leere Zeichenfolge definiert ist, dann ist die Voreinstellung vartmp. LDPROFILEOUTPUT wird für Set-User-ID - und Set-Group-ID-Programme ignoriert, die immer varprofile verwenden. LDSHOWAUXV (glibc seit 2.1) Zeige Hilfsmittel aus dem Kernel. Aus Sicherheitsgründen, da glibc 2.3.5, wird LDSHOWAUXV für set-user-IDset-group-ID-Binärdateien ignoriert. LDUSELOADBIAS Standardmäßig (d. H. Wenn diese Variable nicht definiert ist) werden ausführbare Dateien und vorverknüpfte freigegebene Objekte E-Mail-Adressen ihrer abhängigen Bibliotheken und (nicht verknüpfte) positionsspezifische ausführbare Dateien (PIEs) und andere gemeinsam genutzte Objekte nicht ehren. Wenn LDUSELOADBIAS mit dem Wert definiert ist, werden sowohl die ausführbaren Dateien als auch die PIEs die Basisadressen ehren. Wenn LDUSELOADBIAS mit dem Wert 0 definiert ist, werden weder ausführbare Dateien noch PIEs die Basisadressen ehren. Diese Variable wird von set-user-ID und Set-Group-ID-Programmen ignoriert. LDVERBOSE (glibc seit 2.1) Wenn auf eine nichtleere Zeichenfolge gesetzt, geben Sie das Symbol für die Version des Programms aus, wenn die LDTRACELOADEDOBJECTS-Variable gesetzt wurde. LDWARN (nur ELF) (glibc seit 2.1.3) Wenn auf einen nicht leeren String gesetzt, warnt vor ungelösten Symbolen. LDDARGV0 (libc5) argv 0 von ldd (1) verwendet werden, wenn keine vorhanden ist. Libld. so a. out dynamischer linkerlaader libld-linux. so. 1, 2 ELF dynamic linkerloader etcld. so. cache Datei mit einer kompilierten Liste von Verzeichnissen, in denen nach Bibliotheken und einer geordneten Liste von Kandidatenbibliotheken gesucht werden kann. Etcld. so. preload Datei mit einer durch Whitespace getrennten Liste von ELF-geteilten Bibliotheken, die vor dem Programm geladen werden sollen. Lib. so geteilte Bibliotheken Die Funktion ld. so steht für ausführbare Dateien zur Verfügung, die mit der libc Version 4.4.3 oder höher kompiliert wurden. ELF-Funktionalität ist verfügbar seit Linux 1.1.52 und libc5.Is gibt es eine Reihe von Befehlszeilenoptionen, die gcc zu überzeugen, eine flache Binärdatei aus einer in sich geschlossenen Quelldatei zu produzieren. Beispielsweise nehmen wir an, dass der Inhalt von foo. c Nein ist Externe Referenzen, nichts zu exportieren auf den Linker. Id wie eine kleine Datei mit nur die Maschine Anweisungen für diese Funktion, ohne jede andere Dekoration zu bekommen. Sortiere wie eine (DOS) Datei außer 32-Bit-geschützten Modus. Gefragt am 30. Oktober 09 um 0:26 Die anderen Antworten sind definitiv der Weg zu gehen. Allerdings musste ich zusätzliche Kommandozeilenargumente angeben, um objcopy zu sein, damit meine Ausgabe wie erwartet ist. Beachten Sie, dass ich 32-Bit-Code auf einer 64-Bit-Maschine entwickeln, daher das - m32-Argument. Auch ich mag intel Montage Syntax besser, so youll sehen, dass in den Argumenten auch. Ok, heres wo musste ich angeben, dass ich speziell nur die. text-Sektion wollte: Es hat mir ca. 2 Stunden gelesen und versucht verschiedene Optionen, bevor ich das herausgefunden habe. Hoffentlich spart das damals jemand anderes. Sie können die Optionen direkt an den Linker übergeben - Wl, ltlinker optiongt Die entsprechende Dokumentation wird unten aus dem man gcc - Wl, Option Pass Option als Option zum Linker kopiert. Wenn die Option Kommas enthält, wird sie in mehrere Kommandos aufgeteilt. Sie können diese Syntax verwenden, um ein Argument an die Option zu übergeben. Zum Beispiel, - Wl, - Map, output. map übergibt - Map output. map an den Linker. Wenn du den GNU-Linker benutzt, kannst du auch die gleiche Wirkung mit - Wl, - Mapoutput. map bekommen. Also beim Kompilieren mit gcc, wenn du passierst - Wl, - oformatbinary du wirst eine Binärdatei anstelle des Elf-Formats erzeugen. Wo - oformatbinary sagt ld, um eine Binärdatei zu erzeugen. Dies beseitigt die Notwendigkeit, separat zu kopieren. Beachten Sie, dass - oformatbinary als OUTPUTFORMAT (binary) aus einem Linkerskript ausgedrückt werden kann. Wenn Sie mit flachen Binärdateien umgehen wollen, gibt es eine große Chance, dass Sie von einem hohen Maß an Kontrolle profitieren würden, die Linker-Skripte bieten. Antwortete am 6. Mai 14 um 18: 40Der GNU-Linker ld soll eine breite Palette von Situationen abdecken und möglichst kompatibel mit anderen Linkern sein. Als Ergebnis haben Sie viele Möglichkeiten, um sein Verhalten zu kontrollieren. Hier ist eine Zusammenfassung der Optionen, die Sie auf der ld-Befehlszeile verwenden können: Diese Fülle von Befehlszeilenoptionen mag einschüchternd erscheinen, aber in der Praxis werden nur wenige von ihnen in einem bestimmten Kontext verwendet. Zum Beispiel ist eine häufige Verwendung von ld, um Standard-Unix-Objektdateien auf einem standardisierten, unterstützten Unix-System zu verknüpfen. Auf solch einem System, um eine Datei hello. o zu verknüpfen. Dies sagt ld zu produzieren eine Datei namens Ausgabe als Ergebnis der Verknüpfung der Datei libcrt0.o mit hallo und die Bibliothek libc. a. Die aus den Standard-Suchverzeichnissen kommen wird. (Siehe die Diskussion der Option - l unten.) Die Befehlszeilenoptionen auf ld können in beliebiger Reihenfolge angegeben werden und können nach Belieben wiederholt werden. Das Wiederholen der meisten Optionen mit einem anderen Argument hat entweder keinen weiteren Effekt oder überschreibt vorherige Vorkommnisse (die weiter links auf der Befehlszeile) dieser Option. Die Ausnahmen - die sinnvollerweise mehr als einmal verwendet werden können - sind - A. - b (oder sein Synonym-Format), - defsym. - L. - l. - R. - u Und - ((oder deren Synonym - Start-Gruppe) Die Liste der zu verknüpfenden Objektdateien, die als objfile dargestellt werden, kann mit Kommandozeilenoptionen folgen, vorgehen oder gemischt werden, außer dass ein objfile-Argument nicht vorhanden ist Zwischen einer Option und ihrem Argument platziert werden, in der Regel wird der Linker mit mindestens einer Objektdatei aufgerufen, aber man kann auch andere Formen von Binärdateien mit - l. - R und der Skriptbefehlssprache angeben Alles ist spezifiziert, der Linker erzeugt keine Ausgabe und gibt die Nachricht aus Keine Eingabedateien Wenn der Linker das Format einer Objektdatei nicht erkennen kann, wird davon ausgegangen, dass es sich um ein Linkerskript handelt. Ein so spezifiziertes Skript ergänzt sich Das Hauptlinkerskript, das für den Link verwendet wird (entweder das Standard-Linkerskript oder das mit "T" angegebene). Diese Funktion erlaubt es dem Linker, eine Datei zu verknüpfen, die ein Objekt oder ein Archiv zu sein scheint, aber eigentlich nur ein Symbol definiert Werte oder verwendet INPUT oder GROUP, um andere Objekte zu laden. Siehe Abschnitt Befehlssprache. Bei Optionen, deren Namen ein einziger Buchstabe sind, müssen Options-Argumente entweder dem Options-Buchstaben folgen, ohne dazwischenliegende Leerzeichen zu haben oder als separate Argumente unmittelbar nach der Option, die sie benötigt, gegeben werden. Für Optionen, deren Namen mehrere Buchstaben sind, können entweder ein Bindestrich oder zwei dem Optionsnamen vorangestellt werden. --oformat und - oformat sind gleichwertig. Argumente für mehrere Buchstaben-Optionen müssen entweder von dem Optionsnamen durch ein Gleichheitszeichen getrennt sein oder als separate Argumente unmittelbar nach der Option angegeben werden, die sie benötigt. Zum Beispiel sind --oformat srec und --oformatsrec gleichwertig. Einzigartige Abkürzungen der Namen von Mehrfachbuchstaben werden akzeptiert. - b Eingabeformat ld kann so konfiguriert werden, dass es mehr als eine Art von Objektdatei unterstützt. Wenn Ihr ld auf diese Weise konfiguriert ist, können Sie mit der Option - b das Binärformat für Eingabeobjektdateien angeben, die dieser Option auf der Befehlszeile folgen. Auch wenn ld konfiguriert ist, um alternative Objektformate zu unterstützen, müssen Sie dies normalerweise nicht angeben, da ld so konfiguriert werden sollte, dass es als Standard-Eingabeformat das üblichste Format auf jeder Maschine erwartet. Eingabeformat ist ein Textstring, der Name eines bestimmten Formats, das von den BFD-Bibliotheken unterstützt wird. (Sie können die verfügbaren Binärformate mit objdump - i auflisten.) - format-Eingabeformat hat dieselbe Wirkung wie der Skriptbefehl TARGET. Siehe Abschnitt BFD. Sie können diese Option verwenden, wenn Sie Dateien mit einem ungewöhnlichen Binärformat verknüpfen. Sie können auch - b verwenden, um Formate explizit zu wechseln (bei der Verknüpfung von Objektdateien verschiedener Formate), indem sie - b Eingabeformat vor jeder Gruppe von Objektdateien in einem bestimmten Format enthalten. Das Standardformat wird aus der Umgebungsvariable GNUTARGET übernommen. Sie können auch das Eingabeformat aus einem Skript definieren, mit dem Befehl TARGET siehe Abschnitt Optionsbefehle. - Bstatic Verknüpfe nicht mit geteilten Bibliotheken. Dies ist nur auf Plattformen sinnvoll, für die geteilte Bibliotheken unterstützt werden. - Bdynamic Link gegen dynamische Bibliotheken. Dies ist nur auf Plattformen sinnvoll, für die geteilte Bibliotheken unterstützt werden. Diese Option ist normalerweise auf diesen Plattformen standardmäßig. - Bsymbolic Wenn Sie eine freigegebene Bibliothek erstellen, binden Sie die Verweise auf globale Symbole auf die Definition innerhalb der freigegebenen Bibliothek, falls vorhanden. Normalerweise ist es möglich, dass ein Programm mit einer freigegebenen Bibliothek verknüpft ist, um die Definition innerhalb der freigegebenen Bibliothek zu überschreiben. Diese Option ist nur auf ELF-Plattformen sinnvoll, die gemeinsame Bibliotheken unterstützen. - c MRI-Befehlsdatei Für die Kompatibilität mit Linkern, die von MRI produziert werden, akzeptiert ld Skriptdateien, die in einer alternativen, eingeschränkten Befehlssprache geschrieben sind, die im Abschnitt MRI Compatible Script Files beschrieben ist. Führen Sie MRI-Skriptdateien mit der Option - c ein. Verwenden Sie die Option - T, um Linkerskripts auszuführen, die in der allgemeinen ld-Skriptsprache geschrieben sind. Wenn MRI-cmdfile nicht existiert, sucht ld es in den Verzeichnissen, die durch irgendwelche Optionen - L angegeben werden. - d - dc - dp Diese drei Optionen sind gleichwertig mehrere Formen werden für die Kompatibilität mit anderen Linkern unterstützt. Sie weisen den üblichen Symbolen Platz zu, auch wenn eine umsetzbare Ausgabedatei angegeben ist (mit - r). Der Skriptbefehl FORCECOMMONALLOCATION hat die gleiche Wirkung. Siehe Abschnitt Optionsbefehle. - defsym symbol expression Erstellen Sie ein globales Symbol in der Ausgabedatei mit der absoluten Adresse, die durch den Ausdruck angegeben wird. Sie können diese Option so oft wie nötig verwenden, um mehrere Symbole in der Befehlszeile zu definieren. Eine begrenzte Form der Arithmetik wird für den Ausdruck in diesem Zusammenhang unterstützt: Sie können eine hexadezimale Konstante oder den Namen eines vorhandenen Symbols geben oder verwenden und - um hexadezimale Konstanten oder Symbole hinzuzufügen oder zu subtrahieren. Wenn Sie ausführlichere Ausdrücke benötigen, sollten Sie die Linker-Befehlssprache aus einem Skript verwenden (siehe Abschnitt Zuordnung: Symbole definieren). Anmerkung: Es sollte kein Leerraum zwischen Symbol vorhanden sein. Das Gleiche Zeichen () und Ausdruck. - embedded-relocs Diese Option ist nur sinnvoll bei der Verknüpfung von MIPS-Embedded-PIC-Code, der von der Option - membedded-pic zum GNU-Compiler und Assembler generiert wird. Es verursacht den Linker, eine Tabelle zu erstellen, die zur Laufzeit verwendet werden kann, um alle Daten zu verlagern, die statisch auf Zeigerwerte initialisiert wurden. Siehe den Code in testsuiteld-empic für Details. - e Eintrag Verwenden Sie den Eintrag als explizites Symbol für die Ausführung des Programms und nicht für den Standardeintragspunkt. Siehe Abschnitt Der Einstiegspunkt. Für eine Diskussion über die Vorgaben und andere Möglichkeiten zur Angabe des Einstiegspunktes. - F - F Format Ignoriert. Einige ältere Linker nutzten diese Option während eines Kompilierungs-Toolchains zur Angabe des Objekt-Dateiformats für Ein - und Ausgabe-Objektdateien. Die Mechanismen ld verwenden zu diesem Zweck (die - b - oder - format-Optionen für Eingabedateien, - oformat-Option oder der TARGET-Befehl in Linkerskripten für Ausgabedateien, die GNUTARGET-Umgebungsvariable) sind flexibler, aber ld akzeptiert die Option - F Kompatibilität mit Skripten, die geschrieben wurden, um den alten Linker anzurufen. - format Eingabeformat Synonym für - b Eingabeformat. - g ignoriert Für die Kompatibilität mit anderen Werkzeugen vorgesehen. - G-Wert - G-Wert Legt die maximale Größe der zu optimierenden Objekte mit dem GP-Register auf Größe unter MIPS ECOFF fest. Ignoriert für andere Objektdateiformate. - help Drucken Sie eine Zusammenfassung der Befehlszeilenoptionen auf der Standardausgabe und beenden Sie. - i Führen Sie einen inkrementellen Link (wie die Option - r). - l ar Archivdatei-Archiv zur Liste der zu verknüpfenden Dateien hinzufügen Diese Option kann beliebig oft verwendet werden. Ld sucht ihre Pfadliste für Vorkommen von lib ar. a für jedes angegebene Archiv. - L searchdir - L searchdir Fügen Sie Pfad searchdir zur Liste der Pfade hinzu, die ld nach Archivbibliotheken und ld-Kontrollskripts suchen wird. Sie können diese Option beliebig oft verwenden. Die Verzeichnisse werden in der Reihenfolge durchsucht, in der sie auf der Befehlszeile angegeben sind. Verzeichnisse, die auf der Befehlszeile angegeben sind, werden vor den Standardverzeichnissen durchsucht. Alle - L-Optionen gelten für alle Optionen - l, unabhängig von der Reihenfolge, in der die Optionen erscheinen. Die Pfade können auch in einem Link-Skript mit dem Befehl SEARCHDIR angegeben werden. Verzeichnisse, die auf diese Weise angegeben sind, werden an dem Punkt gesucht, an dem das Linkerskript in der Befehlszeile angezeigt wird. - M Drucken (zur Standardausgabe) eine Linkkarte - Diagnoseinformationen darüber, wo Symbole von ld abgebildet werden. Und Informationen über die globale gemeinsame Speicherzuteilung. - Karte mapfile Drucken in die Datei mapfile eine Linkkarte - Diagnoseinformationen darüber, wo Symbole von ld abgebildet werden. Und Informationen über die globale gemeinsame Speicherzuteilung. - m Emulation - m Emulation Emulieren Sie den Emulations-Linker. Sie können die verfügbaren Emulationen mit den Optionen --verbose oder - V auflisten. Die Voreinstellung hängt davon ab, wie Ihr ld konfiguriert wurde. - N Stellen Sie die Text - und Datenabschnitte so ein, dass sie lesbar und beschreibbar sind. Auch das Seitensegment nicht ausrichten. Wenn das Ausgabeformat Unix-Magic-Nummern unterstützt, markieren Sie die Ausgabe als OMAGIC. - n Setzen Sie das Textsegment nur zu lesen und markieren Sie die Ausgabe als NMAGIC, wenn möglich. - noinhibit-exec Befolgen Sie die ausführbare Ausgabedatei, wenn sie noch verwendbar ist. Normalerweise wird der Linker keine Ausgabedatei erstellen, wenn er während des Verbindungsprozesses Fehler findet, ohne dass er eine Ausgabedatei ausgibt, wenn er irgendwelche Fehler ausgibt. - no-keep-memory ld optimiert normalerweise für die Geschwindigkeit über die Speicherauslastung, indem sie die Symboltabellen der Eingabedateien im Speicher zwischenspeichert. Diese Option teilt ld an, stattdessen für die Speicherauslastung zu optimieren, indem die Symboltabellen nach Bedarf neu gelesen werden. Dies kann erforderlich sein, wenn ld aus dem Speicherplatz läuft, während eine große ausführbare Datei verknüpft wird. - o Ausgabe Verwenden Sie die Ausgabe als den Namen für das Programm, das von ld erzeugt wird, wenn diese Option nicht angegeben ist, wird der Name a. out standardmäßig verwendet. Der Skriptbefehl OUTPUT kann auch den Namen der Ausgabedatei angeben. - oformat Ausgabeformat ld kann so konfiguriert werden, dass es mehr als eine Art von Objektdatei unterstützt. Wenn Ihr ld so konfiguriert ist, können Sie mit der Option - oformat das Binärformat für die Ausgabeobjektdatei angeben. Auch wenn ld konfiguriert ist, um alternative Objektformate zu unterstützen, müssen Sie dies normalerweise nicht angeben, da ld so konfiguriert werden sollte, dass es als Standardausgabeformat das üblichste Format auf jeder Maschine erstellt. Ausgabeformat ist ein Textstring, der Name eines bestimmten Formats, das von den BFD-Bibliotheken unterstützt wird. (Sie können die verfügbaren Binärformate mit objdump - i auflisten.) Der Skriptbefehl OUTPUTFORMAT kann auch das Ausgabeformat angeben, aber diese Option überschreibt sie. Siehe Abschnitt BFD. - R Dateiname Lesen Sie die Symbolnamen und ihre Adressen aus dem Dateinamen. Aber verlagern Sie es nicht oder legen Sie es in die Ausgabe ein. Damit kann Ihre Ausgabedatei symbolisch auf absolute Speicherorte verweisen, die in anderen Programmen definiert sind. - relax Eine Option mit maschinenabhängigen Effekten. Auf einigen Plattformen führt die Option - relax globale Optimierungen durch, die möglich werden, wenn der Linker die Adressierung im Programm auflöst, wie zum Beispiel entspannende Adressmodi und die Synthetisierung neuer Anweisungen in der Ausgabeobjektdatei. - retain-symbols-file Dateiname Behalten Sie nur die im Datei-Dateinamen aufgelisteten Symbole. Alle anderen verwerfen. Dateiname ist einfach eine Flat-Datei mit einem Symbolnamen pro Zeile. Diese Option ist besonders nützlich in Umgebungen, in denen eine große globale Symboltabelle allmählich akkumuliert wird, um Laufzeitspeicher zu sparen. - retain-symbols-file verwerft nicht undefinierte Symbole oder Symbole, die für Verlagerungen benötigt werden. Sie können in der Befehlszeile nur die Option - symbole-Datei angeben. Es überschreibt - s und - S. - r Generiere verlagerbare Ausgabe - d. h. Erzeugen eine Ausgabedatei, die wiederum als Eingabe in ld dienen kann. Dies wird oft als partielle Verknüpfung bezeichnet. Als Nebeneffekt, in Umgebungen, die Standard-Unix-Magic-Nummern unterstützen, setzt diese Option auch die Zieldaten der Ausgabedatei auf OMAGIC. Wenn diese Option nicht angegeben ist, wird eine absolute Datei erstellt. Beim Verknüpfen von C-Programmen wird diese Option nicht auf Verweise auf Konstruktoren aufgelöst, um dies zu tun, verwenden Sie - Ur. Diese Option macht dasselbe wie - i. - S Ausgeben von Debuggersymbolinformationen (aber nicht alle Symbole) aus der Ausgabedatei. - s Weglassen Sie alle Symbolinformationen aus der Ausgabedatei. - shared Erstellen einer gemeinsamen Bibliothek. Dies wird derzeit nur auf ELF - und SunOS-Plattformen unterstützt. Bei SunOS wird der Linker automatisch eine freigegebene Bibliothek erstellen, wenn die Option - e nicht verwendet wird und im Verzeichnis keine undefinierten Symbole vorhanden sind. - sort-common Normalerweise, wenn ld die globalen gemeinsamen Symbole in die entsprechenden Ausgabeabschnitte platziert, sortiert sie nach Größe. Zuerst kommen alle ein Byte Symbole, dann alle zwei Bytes, dann alle vier Bytes, und dann alles andere. Dies ist die Vermeidung von Lücken zwischen Symbolen aufgrund von Ausrichtungsbeschränkungen. Diese Option deaktiviert diese Sortierung. - split-by-reloc count Versucht, zusätzliche Abschnitte in der Ausgabedatei zu erstellen, so dass kein einzelner Ausgabeabschnitt in der Datei mehr als Zählverlagerungen enthält. Dies ist nützlich bei der Erzeugung von riesigen Umsetzbaren zum Herunterladen in bestimmte Echtzeit-Kernel mit dem COFF-Objekt-Dateiformat, da COFF nicht mehr als 65535 Umzüge in einem einzigen Abschnitt darstellen kann. Beachten Sie, dass dies nicht mit Objektdateiformaten funktionieren kann, die keine beliebigen Abschnitte unterstützen. Der Linker wird keine einzelnen Eingabeabschnitte für die Umverteilung aufteilen. Wenn also ein einzelner Eingabeabschnitt mehr als Zählerverlagerungen enthält, enthält ein Ausgabeabschnitt viele Umzüge. - split-by-file Ähnlich wie - split-by-reloc, sondern erstellt einen neuen Ausgabeabschnitt für jede Eingabedatei. - stats Berechnen und Anzeigen von Statistiken über den Betrieb des Linkers, wie zB Ausführungszeit und Speicherverbrauch. - Tbss org - Tdata org - Ttext org Verwenden Sie org als Startadresse für - bzw. - die bss. Daten. Oder das Textsegment der Ausgabedatei. Org muss eine einzelne hexadezimale Integer für die Kompatibilität mit anderen Linkern sein, können Sie die führenden 0x in der Regel mit hexadezimalen Werten verbunden weglassen. - T Befehlsleiste - T Befehlsleiste Lese-Link-Befehle aus der Datei-Befehlsdatei. Diese Befehle ersetzen das Ld-Standard-Verknüpfungsskript (anstatt es hinzuzufügen), so dass die Befehlsleiste alles Notwendige angeben muss, um das Zielformat zu beschreiben. Siehe Abschnitt Befehlssprache. Wenn Befehlsdatei nicht existiert, sucht ld es in den Verzeichnissen, die durch irgendwelche vorangehenden Optionen - L angegeben wurden. Multiple - T-Optionen akkumulieren. - t Drucken Sie die Namen der Eingabedateien, wie Sie sie verarbeiten. - traditionelles Format Für einige Ziele ist die Ausgabe von ld in gewisser Weise von der Ausgabe eines vorhandenen Linkers verschieden. Dieser Schalter fordert ld an, das traditionelle Format zu verwenden. Zum Beispiel, auf SunOS, ld kombiniert doppelte Einträge in der Symbol-String-Tabelle. Dies kann die Größe einer Ausgabedatei mit vollständigen Debugging-Informationen um über 30 Prozent reduzieren. Leider kann das SunOS dbx Programm das resultierende Programm nicht lesen (gdb hat keine Probleme). Der - traditional-Format-Schalter teilt ld zu, um doppelte Einträge nicht zu kombinieren. - u Symbol Force-Symbol in die Ausgabedatei als ein undefiniertes Symbol eingegeben werden. Dies kann beispielsweise die Verknüpfung zusätzlicher Module aus Standardbibliotheken auslösen. - u kann mit verschiedenen Optionsargumenten wiederholt werden, um zusätzliche undefinierte Symbole einzugeben. - Ur Für irgendetwas anderes als C-Programme entspricht diese Option - r. Es erzeugt eine verlagerbare Ausgabe - d. h. Eine Ausgabedatei, die wiederum als Eingabe für ld dienen kann. Beim Verknüpfen von C-Programmen, - Ur löst Referenzen auf Konstruktoren, im Gegensatz zu - r. Es funktioniert nicht zu verwenden - Ur auf Dateien, die selbst mit - Ur verbunden waren, sobald die Konstruktortabelle gebaut wurde, kann es nicht hinzugefügt werden. Verwenden Sie nur für den letzten Teillink und - r für die anderen. --verbose Zeigt die Versionsnummer für ld an und listet die unterstützten Linker-Emulationen auf. Zeigen Sie an, welche Eingabedateien geöffnet und nicht geöffnet werden können. - v - V Zeigt die Versionsnummer für ld an. Die Option - V listet auch die unterstützten Emulationen auf. - version Zeigt die Versionsnummer für ld an und beendet. - warn-common Warnung, wenn ein gemeinsames Symbol mit einem anderen gemeinsamen Symbol oder mit einer Symboldefinition kombiniert wird. Unix-Linker erlauben diese etwas schlampige Praxis, aber Linker auf einigen anderen Betriebssystemen nicht. Mit dieser Option können Sie mögliche Probleme aus der Kombination globaler Symbole finden. Leider verwenden einige C-Bibliotheken diese Praxis, so können Sie einige Warnungen über Symbole in den Bibliotheken sowie in Ihren Programmen erhalten. Es gibt drei Arten von globalen Symbolen, die hier durch C Beispiele dargestellt werden: int i 1 Eine Definition, die in den initialisierten Datenabschnitt der Ausgabedatei geht. Extern int i Eine undefinierte Referenz, die keinen Platz verteilt. Es muss entweder eine Definition oder ein gemeinsames Symbol für die Variable irgendwo sein. Int i Ein gemeinsames Symbol. Wenn es nur (ein oder mehrere) gemeinsame Symbole für eine Variable gibt, geht es in den nicht initialisierten Datenbereich der Ausgabedatei. Der Linker verbindet mehrere gemeinsame Symbole für die gleiche Variable in einem einzigen Symbol. Wenn sie von verschiedenen Größen sind, wählt es die größte Größe. Der Linker verwandelt ein gemeinsames Symbol in eine Deklaration, wenn es eine Definition der gleichen Variablen gibt. Die - warn-common Option kann fünf Arten von Warnungen erzeugen. Jede Warnung besteht aus einem Paar von Zeilen: das erste beschreibt das Symbol, das gerade angetroffen wird, und das zweite beschreibt das vorhergehende Symbol, das mit demselben Namen angetroffen wird. Ein oder beide der beiden Symbole sind ein gemeinsames Symbol. Ein gemeinsames Symbol in eine Referenz umwandeln, da es bereits eine Definition für das Symbol gibt. Ein gemeinsames Symbol in eine Referenz umwandeln, da eine spätere Definition für das Symbol angetroffen wird. Dies ist derselbe wie der vorherige Fall, außer dass die Symbole in einer anderen Reihenfolge angetroffen werden. Zusammenführen eines gemeinsamen Symbols mit einem vorherigen gemeinsamen Symbol. Zusammenführen eines gemeinsamen Symbols mit einem vorherigen größeren gemeinsamen Symbol. Zusammenführen eines gemeinsamen Symbols mit einem vorherigen kleineren gemeinsamen Symbol. Dies ist derselbe wie der vorherige Fall, außer dass die Symbole in einer anderen Reihenfolge angetroffen werden. - Warn-Konstruktoren Warnen, wenn irgendwelche globalen Konstruktoren verwendet werden. Dies ist nur für einige Objektdateiformate nützlich. Für Formate wie COFF oder ELF kann der Linker die Verwendung von globalen Konstruktoren nicht erkennen. - warn-once Nur einmal warnen für jedes undefinierte Symbol, anstatt einmal pro Modul, das darauf verweist. For each archive mentioned on the command line, include every object file in the archive in the link, rather than searching the archive for the required object files. This is normally used to turn an archive file into a shared library, forcing every object to be included in the resulting shared library. - X Delete all temporary local symbols. For most targets, this is all local symbols whose names begin with L. - x Delete all local symbols. - y symbol Print the name of each linked file in which symbol appears. This option may be given any number of times. On many systems it is necessary to prepend an underscore. This option is useful when you have an undefined symbol in your link but dont know where the reference is coming from. -( archives -) --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. Go to the first. previous. next. last section, table of contents. Linux and Unix ld command ld combines a number of object and archive files, relocates their data and ties up symbol references. 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 being 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.

No comments:

Post a Comment