Skip to content

Commit 80fe0a9

Browse files
Merge #80
80: Change examples to reflect usage improvements r=therealprof a=toothbrush7777777 Closes #58 Co-authored-by: Toothbrush <toothbrush7777777@gmail.com>
2 parents 605bb66 + aa6eadd commit 80fe0a9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ $ cargo build --example foo
5050
$ rust-size target/examples/foo
5151
```
5252

53+
These commands take similar options to `cargo build` and you can specify
54+
a specific binary with `--bin NAME`, an example with `--example NAME`
55+
or the default binary by not passing `--bin` or `--example`.
56+
5357
In the case of `cargo-objdump` the architecture of the compilation target is
5458
passed as `-arch-name=$target` to `llvm-objdump`. `-arch-name` specifies to
5559
which architecture disassemble the object file to.
@@ -78,7 +82,7 @@ these tools may change as new Rust releases are made.
7882
List all symbols in an executable
7983

8084
``` console
81-
$ cargo nm --bin app --release
85+
$ cargo nm --release
8286
0800040a T BusFault
8387
0800040a T DebugMonitor
8488
0800040a T DefaultHandler
@@ -100,7 +104,7 @@ $ cargo nm --bin app --release
100104
List all symbols in an executable sorted by size (smallest first).
101105

102106
``` console
103-
$ cargo nm --bin app --release -- -print-size -size-sort
107+
$ cargo nm --release -- -print-size -size-sort
104108
0800040a 00000002 T DefaultHandler
105109
08000408 00000002 T UserHardFault
106110
08000004 00000004 R __RESET_VECTOR
@@ -115,7 +119,7 @@ $ cargo nm --bin app --release -- -print-size -size-sort
115119
Transform the output of Cargo (ELF) into binary format.
116120

117121
``` console
118-
$ cargo objcopy --bin app --release -- -O binary app.bin
122+
$ cargo objcopy --release -- -O binary app.bin
119123

120124
$ stat --printf="%s\n" app.bin
121125
1642
@@ -126,7 +130,7 @@ $ stat --printf="%s\n" app.bin
126130
Disassemble a binary.
127131

128132
``` console
129-
$ cargo objdump --bin app --release -- -disassemble -no-show-raw-insn
133+
$ cargo objdump --release -- -disassemble -no-show-raw-insn
130134
target/thumbv7m-none-eabi/debug/app: file format ELF32-arm-little
131135

132136
Disassembly of section .text:
@@ -155,7 +159,7 @@ Reset:
155159
Print binary size in System V format
156160

157161
``` console
158-
$ cargo size --bin app --release -- -A -x
162+
$ cargo size --release -- -A -x
159163
target/thumbv7m-none-eabi/release/app :
160164
section size addr
161165
.vector_table 0x400 0x8000000
@@ -186,7 +190,7 @@ Strip all symbols from the build artifact
186190
$ stat --printf="%s\n" target/release/hello
187191
4094240
188192

189-
$ cargo-strip --bin hello --release -- -strip-all -O smaller-hello
193+
$ cargo-strip --release -- -strip-all -O smaller-hello
190194

191195
$ stat --printf="%s\n" smaller-hello
192196
424432

0 commit comments

Comments
 (0)