I'm writing a Rust program targeted for an STM32F407 processor using zinc. I'd like to be able to produce a linker map file. I've found that I can put the following in my main.rs and this gives me the desired result:
#![feature(link_args)]
#[link_args = "-Wl,-Map=blink_stm32f4.map"]
extern {}
However, the documentation for link_args
suggests not to use this method.
What other methods exist to get the linker to produce a map file?
Select Tools > Generate, or press Ctrl+G. The Generate Mapping File dialog appears. Enter the reader and writer parameters you want to use for the mapping file. Parameters:When you select certain source formats, the Parameters button becomes available.
A linker map is a file produced by the linker. The file shows the symbols and sections contained in a binary. The linker also provides the memory address and size for each symbol.
The map file is generated by the linker and the format of the file will be different for each linker. Your best bet is the documentation for the linker itself - there is unlikely to be a "general" tutorial. However for the most part a map file is simply a table of symbols, their location and their size.
More generically, the . MAP extension can be used to denote any file type that indicates relative offsets from a starting point. MAP file types are used in this way, for example, when variables in software are expected to be "mapped" to a specific spot in memory.
link-args
is possible to pass to rustc
via rustc -C link-args="-Wl,-Map=blink_stm32f4.map" test.rs
.
And there is option of cargo
rustflags
in build
section. See cargo config. It works like this:
$ cargo new --bin testbin
$ cd testbin
$ cat .cargo/config
[build]
rustflags = ["-Clink-args=-Wl,-Map=/tmp/blink_f7.map"]
$ cargo build
Also there is linker
option in cargo
config. I don't try to pass via
this option gcc
plus flags
, only gcc
, but you can write gcc
wrapper script like:
$ cat my-linker.sh
#!/bin/sh
arm-...-gcc -Wl,-Map=blink_stm32f4.map $@
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With