Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This post was pointed out by Michael Jung:

Code Block

  MCU: STM32F4 (ARM Cortex M4)
  Build environment: arm-none-eabi-gcc 4.8.4 20140725
Code Block
  My goal is to build an image that can be run from any properly-aligned
  offset in internal flash (i.e., position-independent).  I found the
  following set of gcc flags that achieves this goal:
Code Block
    # Generate position independent code.
  1. fPIC
Code Block

    -fPIC

  # Access bss via the GOT.
  -mno-pic-data-is-text-relative

...

Code Block


    # GOT is not PC-relative; store GOT location in a register.
  -msingle-pic-base

...

Code Block


    # Store GOT location in r9.
  -mpic-register=r9

Reference: https://gcc.gnu.org/ml/gcc-help/2015-07/msg00027.html

...