2.PIC: Position Independent Code*位置独立コードは使えますか?
2.PIC: Position Independent Code*位置独立コードは使えますか?
If developers for instance is working on a bootloader, position independency is a great help. PIC (Position Independent Code) is relative to the program counter, so if you compile for address 0 but place the code at 81000 it still runs properly.
The compiler has an option
-fPIE
that enables the compiler to generate position independent code for executable. Add this option into the tool settings for the Assembler and C Compiler in the miscellaneous settings for C/C++ Build.
Also use this -fPIE option for the linker. E.g. in the miscellaneous settings the "Other options" field for the C linker, the command may look like
-Wl,-cref,-u,Reset_Handler -fPIE
Developer must also make sure that the stack pointer is set up correctly. This is usually done by issuing a monitor reset when launching the debug session; that will trigger the processor to read the stack pointer from the first entry in the interrupt vector.
Developer can make sure that the start code when starting also sets the stack pointer; do this by adding the following assembly line at the top of the Reset_Handler function located in the startup file:
ldr sp, =_estack
This will make sure that the stack pointer is initialized when the reset_handler runs.
Developer can also try removing the initial reset command that we issue when launching the debug session.
Do this by opening your debug configuration: Select the project in the project explorer view, then select the Run -> Debug configurations menu alternative.
Select the debug configuration, switch to the Startup Debug tab to the right.
Here developer can see all commands that we use to launch a debug session. Try commenting the monitor reset line out by adding a # sign in front.
Also in some of our examples developer will have to make some changes in the SystemInit function for the vector table relocation.
SCB->VTOR = FLASH_BASE | 0x20000; /* Vector Table Relocation in Internal FLASH */
If not, this SystemInit function will relocate interrupts to flash beginning.
1..hex-fileは作れますか?
1..hex-fileは作れますか?
To convert your program to another output format, do the following:
Install and upgrade:インストールとアップグレード
技術的な質問
Install and upgrade:インストールとアップグレード
- Java Virtual Machineを作成できない
- JNI share libraryをロードできない
- toolchainに関する一般的な情報
- ST microXplorerをどのように統合するのでしょうか?
- Atollic TrueSTUDIOが利用するメモリをどのように管理するのでしょうか?
- USBからのインストール
- インターネットへの接続無しでのインストール
- Java Heap Space error
- リモートデスクトップを使用してAtollic TrueSTUDIOを使う
- 12 month SUA(年間保守)には何が含まれるのでしょうか?
- なぜ 'JVM exited with -1' がTrueSTUDIOを立ち上げるときに表示されるのでしょうか?