@@ -319,11 +319,46 @@ to a valid `.profdata` file. See the chapter on
319319
320320## relocation-model
321321
322- This option lets you choose which
323- [ relocation] ( https://en.wikipedia.org/wiki/Relocation_\( computing\) ) model to
324- use.
322+ This option controls generation of
323+ [ position-independent code (PIC)] ( https://en.wikipedia.org/wiki/Position-independent_code ) .
325324
326- To find the valid options for this flag, run ` rustc --print relocation-models ` .
325+ Supported values for this option are:
326+
327+ #### Primary relocation models
328+
329+ - ` static ` - non-relocatable code, machine instructions may use absolute addressing modes.
330+
331+ - ` pic ` - fully relocatable position independent code,
332+ machine instructions need to use relative addressing modes.
333+ Equivalent to the "uppercase" ` -fPIC ` or ` -fPIE ` options in other compilers,
334+ depending on the produced crate types.
335+ This is the default model for majority of supported targets.
336+
337+ #### Special relocation models
338+
339+ - ` dynamic-no-pic ` - relocatable external references, non-relocatable code.
340+ Only makes sense on Darwin and is rarely used.
341+ If StackOverflow tells you to use this as an opt-out of PIC or PIE, don't believe it,
342+ use ` -C relocation-model=static ` instead.
343+ - ` ropi ` , ` rwpi ` and ` ropi-rwpi ` - relocatable code and read-only data, relocatable read-write data,
344+ and combination of both, respectively.
345+ Only makes sense for certain embedded ARM targets.
346+ - ` default ` - relocation model default to the current target.
347+ Only makes sense as an override for some other explicitly specified relocation model
348+ previously set on the command line.
349+
350+ Supported values can also be discovered by running ` rustc --print relocation-models ` .
351+
352+ #### Linking effects
353+
354+ In addition to codegen effects, ` relocation-model ` has effects during linking.
355+
356+ If the relocation model is ` pic ` and the current target supports position-independent executables
357+ (PIE), the linker will be instructed (` -pie ` ) to produce one.
358+ If the target doesn't support both position-independent and statically linked executables,
359+ then ` -C target-feature=+crt-static ` "wins" over ` -C relocation-model=pic ` ,
360+ and the linker is instructed (` -static ` ) to produce a statically linked
361+ but not position-independent executable.
327362
328363## remark
329364
0 commit comments