Rust equivalent to __attribute__((section(NAME), used))?


#1

Does Rust has a way to specify where to place the binary in the section of compiled elf binary? Like attribute((section(NAME), used)) in C? One usage is: http://elixir.free-electrons.com/linux/v4.11.1/source/samples/bpf/bpf_helpers.h#L8 For example, the code that uses this would be like: http://elixir.free-electrons.com/linux/v4.11.1/source/samples/bpf/tracex1_kern.c#L20


#2

Yes, you need the link_section attribute and the used attribute. At least one or both of these require nightly if I remember correctly.