この記事で関係するターゲット
前の記事 参照zephyr.lnk
[zephyr_base]/Makefile
-nostartfiles -nodefaultlibs -nostdlib -static -Wl,-X -Wl,-N -Wl,--gc-sections -Wl,--build-id=none -Wl,-Map=[zephyr_base]/samples/hello_world/microkernel/outdir/zephyr.map -L ./include/generated -u _OffsetAbsSyms -u _ConfigAbsSyms -e __start -Wl,--start-group -Wl,--whole-archive -Wl,--no-whole-archive drivers/built-in.o ./samples/hello_world/microkernel/src/built-in.o lib/built-in.o kernel/built-in.o misc/built-in.o net/built-in.o boards/built-in.o arch/built-in.o ext/built-in.o ./arch/x86/core/offsets/offsets.o -Wl,--end-group -L /Volumes/CrossToolNG/x-tools/i586-pc-elf/lib/gcc/i586-pc-elf/5.2.0/ -lgcc
-nostartfiles
3.14 Options for Linking
Do not use the standard system startup files when linking. The standard system libraries are used normally, unless -nostdlib or -nodefaultlibs is used.スタートアップファイル(crt*.oなど)をリンクしない。
-nodefaultlibs
3.14 Options for Linking
Do not use the standard system libraries when linking. Only the libraries you specify are passed to the linker, and options specifying linkage of the system libraries, such as -static-libgcc or -shared-libgcc, are ignored. The standard startup files are used normally, unless -nostartfiles is used.標準システムライブラリ(libcなど)をリンクしない。
-nostdlib
3.14 Options for Linking
Do not use the standard system startup files or libraries when linking. No startup files and only the libraries you specify are passed to the linker, and options specifying linkage of the system libraries, such as -static-libgcc or -shared-libgcc, are ignored.オプションで指定したライブラリだけをリンクする。
-static
3.14 Options for Linking
On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.共有ライブリラリ(*.so)をリンクしない。
-Wl,-X
2.1 Command Line Options
--discard-locals Delete all temporary local symbols. (These symbols start with system-specific local label prefixes, typically `.L' for ELF systems or `L' for traditional a.out systems.)一時的(=記憶領域が割り当てられていない?)なローカル(=オブジェクトファイルスコープ?)なシンボル(ELFではLで始まる)を全て削除する。
-Wl,-N
2.1 Command Line Options
--omagic 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.textとdataセクションを読み書き可能にする。dataセグメントのページアライメントを行わない。共有ライブリラリとのリンクを禁止する。
-Wl,--gc-sections
2.1 Command Line Options
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. Note that garbage collection for COFF and PE format targets is supported, but the implementation is currently considered to be experimental. `--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.未使用の入力セクションに対するガベージコレクションを有効にする。
-Wl,--build-id=none
2.1 Command Line Options
--build-id --build-id=style Request the creation of a .note.gnu.build-id ELF note section or a .buildid COFF section. The contents of the note are unique bits identifying this linked file. style can be uuid to use 128 random bits, sha1 to use a 160-bit SHA1 hash on the normative parts of the output contents, md5 to use a 128-bit MD5 hash on the normative parts of the output contents, or 0xhexstring to use a chosen bit string specified as an even number of hexadecimal digits (- and : characters between digit pairs are ignored). If style is omitted, sha1 is used. The md5 and sha1 styles produces an identifier that is always the same in an identical output file, but will be unique among all nonidentical output files. It is not intended to be compared as a checksum for the file's contents. A linked file may be changed later by other tools, but the build ID bit string identifying the original linked file does not change. Passing none for style disables the setting from any --build-id options earlier on the command line..note.gnu.build-id セクションを作成しない。
-Wl,-Map=[zephyr_base]/samples/hello_world/microkernel/outdir/zephyr.map
2.1 Command Line Options
Print a link map to the file mapfile. See the description of the -M option, above.
-M --print-map 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: foo = 1 foo = foo * 4 foo = foo + 8 will produce the following output in the link map if the -M option is used: 0x00000001 foo = 0x1 [0x0000000c] foo = (foo * 0x4) [0x0000000c] foo = (foo + 0x8) See Expressions for more information about expressions in linker scripts.リンクマップファイル(シンボルとアドレスのマップ?)を生成する。
-L ./include/generated
3.14 Options for Linking
The directories searched include several standard system directories plus any that you specify with -L.ライブラリサーチパスに./include/generatedを追加する。
-u _OffsetAbsSyms -u _ConfigAbsSyms
3.14 Options for Linking
Pretend the symbol symbol is undefined, to force linking of library modules to define it. You can use -u multiple times with different symbols to force loading of additional library modules.シンボル(_OffsetAbsSyms,_ConfigAbsSyms)を定義するライブラリと強制的にリンクするために、シンボルを未定義として扱う?。
-e __start
2.1 Command Line Options
--entry=entry 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). See Entry Point, for a discussion of defaults and other ways of specifying the entry point.最初に実行されるエントリポイントとして__startを指定する。
-Wl,--start-group ... -Wl,--end-group
2.1 Command Line Options
--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.-Wl,--start-group と -Wl,--end-group の間にアーカイブファイル(*.a、*.o)のリストを記述する。
リストに含まれるアーカイブファイル(オブジェクトファイル)は、未定義のシンボルがなくなるまで(リスト中のファイルを横断して)探索を繰り返す。
通常は、オブジェクトファイルの指定順番はシンボルの解決順にする必要がある。(通常はファイル間で一方向の参照のみ?)
オブジェクトファイルがお互いのシンボルを参照する場合には、通常の方法では解決できないので、-Wl,--start-group と -Wl,--end-group を使う必要がある。
-Wl,--start-group drivers/built-in.o ./samples/hello_world/microkernel/src/built-in.o lib/built-in.o kernel/built-in.o misc/built-in.o net/built-in.o boards/built-in.o arch/built-in.o ext/built-in.o ./arch/x86/core/offsets/offsets.o -Wl,--end-group今回は、上記のオブジェクトファイルのシンボルを互いに繰り返し探索する。
-Wl,--whole-archive ... -Wl,--no-whole-archive
2.1 Command Line Options
-Wl,--whole-archive For each archive mentioned on the command line after the --whole-archive option, 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. This option may be used more than once. Two notes when using this option from gcc: First, gcc doesn't know about this option, so you have to use -Wl,-whole-archive. Second, don't forget to use -Wl,-no-whole-archive after your list of archives, because gcc will add its own list of archives to your link and you may not want this flag to affect those as well.
-Wl,--no-whole-archive Turn off the effect of the --whole-archive option for subsequent archive files.-Wl,--whole-archive と -Wl,--no-whole-archive の間に含まれるアーカイブ中のオブジェクトを強制的にリンクする?。
-L /Volumes/CrossToolNG/x-tools/i586-pc-elf/lib/gcc/i586-pc-elf/5.2.0/
2.1 Command Line Options
The directories searched include several standard system directories plus any that you specify with -L.ライブラリサーチパスに/Volumes/CrossToolNG/x-tools/i586-pc-elf/lib/gcc/i586-pc-elf/5.2.0/を追加する。
-lgcc
3.14 Options for Linking
In other words, when you specify -nostdlib or -nodefaultlibs you should usually specify -lgcc as well. This ensures that you have no unresolved references to internal GCC library subroutines. (An example of such an internal subroutine is __main, used to ensure C++ constructors are called; see collect2.)gccの内部ライブラリが未定義エラーを出さないようにするために、これが必要。
コメント