Table of Contents
1. Using ld ............................................................................................................................................ 1
2. Overview .......................................................................................................................................... 3
3. Invocation ........................................................................................................................................ 5
3.1. Command Line Options..................................................................................................... 5
3.1.1. Options Specific to i386 PE Targets ................................................................. 21
3.2. Environment Variables..................................................................................................... 27
4. Linker Scripts................................................................................................................................ 29
4.1. Basic Linker Script Concepts........................................................................................... 29
4.2. Linker Script Format........................................................................................................ 29
4.3. Simple Linker Script Example......................................................................................... 30
4.4. Simple Linker Script Commands..................................................................................... 31
4.4.1. Setting the Entry Point...................................................................................... 31
4.4.2. Commands Dealing with Files.......................................................................... 31
4.4.3. Commands Dealing with Object File Formats.................................................. 32
4.4.4. Other Linker Script Commands ........................................................................ 33
4.5. Assigning Values to Symbols .......................................................................................... 33
4.5.1. Simple Assignments ......................................................................................... 33
4.5.2. PROVIDE.......................................................................................................... 34
4.6. SECTIONS Command..................................................................................................... 35
4.6.1. Output Section Description............................................................................... 35
4.6.2. Output Section Name........................................................................................ 36
4.6.3. Output Section Description............................................................................... 36
4.6.4. Input Section Description ................................................................................. 37
4.6.5. Output Section Data.......................................................................................... 39
4.6.6. Output Section Keywords ................................................................................. 40
4.6.7. Output Section Discarding................................................................................ 41
4.6.8. Output Section Attributes ................................................................................. 42
4.6.9. Overlay Description .......................................................................................... 44
4.7. MEMORY Command ...................................................................................................... 45
4.8. PHDRS Command ........................................................................................................... 47
4.9. VERSION Command....................................................................................................... 49
4.10. Expressions in Linker Scripts ........................................................................................ 51
4.10.1. Constants......................................................................................................... 51
4.10.2. Symbol Names................................................................................................ 51
4.10.3. The Location Counter ..................................................................................... 51
4.10.4. Operators......................................................................................................... 52
4.10.5. Evaluation ....................................................................................................... 53
4.10.6. The Section of an Expression ......................................................................... 53
4.10.7. Builtin Functions............................................................................................. 54
4.11. Implicit Linker Scripts ................................................................................................... 56
5. Machine Dependent Features ...................................................................................................... 59
5.1. ld and the H8/300............................................................................................................ 59
5.2. ld and the Intel 960 Family............................................................................................. 59
5.3. ld’s Support for Interworking Between ARM and Thumb Code ................................... 59
5.4. ld and HPPA 32-bit ELF Support ................................................................................... 60
5.5. ld and MMIX .................................................................................................................. 60
5.6. ld and MSP430 ............................................................................................................... 60
5.7. ld’s Support for Various TI COFF Versions ................................................................... 61
5.8. ld and WIN32 (cygwin/mingw)...................................................................................... 61
5.9. ld and Xtensa Processors ................................................................................................ 65