From e26ca966fba2d5107f8fb74eff069505ad554aa4 Mon Sep 17 00:00:00 2001 From: James Henderson Date: Wed, 3 Jul 2019 14:21:48 +0000 Subject: [PATCH] [docs][llvm-objcopy] Write documentation for llvm-objcopy This patch addresses https://bugs.llvm.org/show_bug.cgi?id=42183 by replacing the stub markdown doc for llvm-objcopy with a full one describing the current options available in llvm-objcopy. Reviewed by: jakehehrlich, MaskRay Differential Revision: https://reviews.llvm.org/D63820 llvm-svn: 365042 --- llvm/docs/CommandGuide/llvm-objcopy.md | 16 -- llvm/docs/CommandGuide/llvm-objcopy.rst | 482 ++++++++++++++++++++++++++++++++ 2 files changed, 482 insertions(+), 16 deletions(-) delete mode 100644 llvm/docs/CommandGuide/llvm-objcopy.md create mode 100644 llvm/docs/CommandGuide/llvm-objcopy.rst diff --git a/llvm/docs/CommandGuide/llvm-objcopy.md b/llvm/docs/CommandGuide/llvm-objcopy.md deleted file mode 100644 index 3b79fb7..0000000 --- a/llvm/docs/CommandGuide/llvm-objcopy.md +++ /dev/null @@ -1,16 +0,0 @@ -# llvm-objcopy - object copying tool - -## SYNOPSIS - -**llvm-objcopy** [*options*] - -## DESCRIPTION - -**llvm-objcopy** is a tool to copy and manipulate objects. - -The tool is still in active development, but in most scenarios it works as a -drop-in replacement for GNU's **objcopy**. - -## SEE ALSO - -[llvm-strip](llvm-strip.html) diff --git a/llvm/docs/CommandGuide/llvm-objcopy.rst b/llvm/docs/CommandGuide/llvm-objcopy.rst new file mode 100644 index 0000000..0119280 --- /dev/null +++ b/llvm/docs/CommandGuide/llvm-objcopy.rst @@ -0,0 +1,482 @@ +llvm-objcopy - object copying and editing tool +============================================== + +.. program:: llvm-objcopy + +SYNOPSIS +-------- + +:program:`llvm-objcopy` [*options*] *input* [*output*] + +DESCRIPTION +----------- + +:program:`llvm-objcopy` is a tool to copy and manipulate objects. In basic +usage, it makes a semantic copy of the input to the output. If any options are +specified, the output may be modified along the way, e.g. by removing sections. + +If no output file is specified, the input file is modified in-place. If "-" is +specified for the input file, the input is read from the program's standard +input stream. If "-" is specified for the output file, the output is written to +the standard output stream of the program. + +If the input is an archive, any requested operations will be applied to each +archive member individually. + +The tool is still in active development, but in most scenarios it works as a +drop-in replacement for GNU's :program:`objcopy`. + +GENERIC AND CROSS-PLATFORM OPTIONS +---------------------------------- + +The following options are either agnostic of the file format, or apply to +multiple file formats. + +.. option:: --add-gnu-debuglink + + Add a .gnu_debuglink section for ```` to the output. + +.. option:: --disable-deterministic-archives, -U + + Use real values for UIDs, GIDs and timestamps when updating archive member + headers. + +.. option:: --discard-all, -x + + Remove most local symbols from the output. Different file formats may limit + this to a subset of the local symbols. For example, file and section symbols in + ELF objects will not be discarded. + +.. option:: --enable-deterministic-archives, -D + + Enable deterministic mode when copying archives, i.e. use 0 for archive member + header UIDs, GIDs and timestamp fields. On by default. + +.. option:: --help, -h + + Print a summary of command line options. + +.. option:: --only-section
, -j + + Remove all sections from the output, except for sections named ``
``. + Can be specified multiple times to keep multiple sections. + +.. option:: --regex + + If specified, symbol and section names specified by other switches are treated + as extended POSIX regular expression patterns. + +.. option:: --remove-section
, -R + + Remove the specified section from the output. Can be specified multiple times + to remove multiple sections simultaneously. + +.. option:: --strip-all-gnu + + Remove all symbols, debug sections and relocations from the output. This option + is equivalent to GNU :program:`objcopy`'s ``--strip-all`` switch. + +.. option:: --strip-all, -S + + For ELF objects, remove from the output all symbols and non-alloc sections not + within segments, except for .gnu.warning sections and the section name table. + + For COFF objects, remove all symbols, debug sections, and relocations from the + output. + +.. option:: --strip-debug, -g + + Remove all debug sections from the output. + +.. option:: --strip-symbol , -N + + Remove all symbols named ```` from the output. Can be specified + multiple times to remove multiple symbols. + +.. option:: --strip-symbols + + Remove all symbols whose names appear in the file ````, from the + output. In the file, each line represents a single symbol name, with leading + and trailing whitespace ignored, as is anything following a '#'. Can be + specified multiple times to read names from multiple files. + +.. option:: --strip-unneeded-symbol + + Remove from the output all symbols named ```` that are local or + undefined and are not required by any relocation. + +.. option:: --strip-unneeded-symbols + + Remove all symbols whose names appear in the file ````, from the + output, if they are local or undefined and are not required by any relocation. + In the file, each line represents a single symbol name, with leading and + trailing whitespace ignored, as is anything following a '#'. Can be specified + multiple times to read names from multiple files. + +.. option:: --strip-unneeded + + Remove from the output all local or undefined symbols that are not required by + relocations. + +.. option:: --version, -V + + Display the version of this program. + +COFF-SPECIFIC OPTIONS +--------------------- + +The following options are implemented only for COFF objects. If used with other +objects, :program:`llvm-objcopy` will either emit an error or silently ignore +them. + +.. option:: --only-keep-debug + + Remove the contents of non-debug sections from the output, but keep the section + headers. + +ELF-SPECIFIC OPTIONS +-------------------- + +The following options are implemented only for ELF objects. If used with other +objects, :program:`llvm-objcopy` will either emit an error or silently ignore +them. + +.. option:: --add-section + + Add a section named ``
`` with the contents of ```` to the + output. The section will be of type `SHT_NOTE`, if the name starts with + ".note". Otherwise, it will have type `SHT_PROGBITS`. Can be specified multiple + times to add multiple sections. + +.. option:: --add-symbol =[
:][,] + + Add to the output a new symbol called ```` to the symbol table, in the + section named ``
``, with value ````. If ``
`` is not + specified, the symbol is added as an absolute symbol. The ```` affect + the symbol properties. Accepted values are: + + - `global` = the symbol will have global binding. + - `local` = the symbol will have local binding. + - `weak` = the symbol will have weak binding. + - `default` = the symbol will have default visibility. + - `hidden` = the symbol will have hidden visibility. + - `file` = the symbol will be an `STT_FILE` symbol. + - `section` = the symbol will be an `STT_SECTION` symbol. + - `object` = the symbol will be an `STT_OBJECT` symbol. + - `function` = the symbol will be an `STT_FUNC` symbol. + - `indirect-function` = the symbol will be an `STT_GNU_IFUNC` symbol. + + Additionally, the following flags are accepted but ignored: `debug`, + `constructor`, `warning`, `indirect`, `synthetic`, `unique-object`, `before`. + + Can be specified multiple times to add multiple symbols. + +.. option:: --allow-broken-links + + Allow llvm-objcopy to remove sections even if it would leave invalid section + references. Any invalid sh_link fields will be set to zero. + +.. option:: --binary-architecture , -B + + Specify the architecture to use, when transforming an architecture-less format + (e.g. binary) to another format. Valid options are: + + - `aarch64` + - `arm` + - `i386` + - `i386:x86-64` + - `mips` + - `powerpc:common64` + - `riscv:rv32` + - `riscv:rv64` + - `sparc` + - `sparcel` + - `x86-64` + +.. option:: --build-id-link-dir + + Set the directory used by :option:`--build-id-link-input` and + :option:`--build-id-link-output`. + +.. option:: --build-id-link-input + + Hard-link the input to ``/xx/xxx``, where ```` is the directory + specified by :option:`--build-id-link-dir`. The path used is derived from the + hex build ID. + +.. option:: --build-id-link-output + + Hard-link the output to ``/xx/xxx``, where ```` is the directory + specified by :option:`--build-id-link-dir`. The path used is derived from the + hex build ID. + +.. option:: --change-start , --adjust-start + + Add ```` to the program's start address. Can be specified multiple + times, in which case the values will be applied cumulatively. + +.. option:: --compress-debug-sections [