C 源代码中的 PowerPC r13 寄存器小数据指针示例

PowerPC r13 Register Small Data Pointer Example in C Source Code

ppc中的r13是小数据区指针寄存器

C 源代码中将使用该寄存器的示例是什么?

您希望编译器对全局数据变量使用 .sdata.sbss。一个带有全局变量和适当编译选项的简单程序应该可以做到。

来自 RS6000/PowerPC 的 gcc:

https://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html

-msdata=eabi

On System V.4 and embedded PowerPC systems, put small initialized const global and static data in the .sdata2 section, which is pointed to by register r2. Put small initialized non-const global and static data in the .sdata section, which is pointed to by register r13. Put small uninitialized global and static data in the .sbss section, which is adjacent to the .sdata section. The -msdata=eabi option is incompatible with the -mrelocatable option. The -msdata=eabi option also sets the -memb option

-msdata=sysv

On System V.4 and embedded PowerPC systems, put small global and static data in the .sdata section, which is pointed to by register r13. Put small uninitialized global and static data in the .sbss section, which is adjacent to the .sdata section. The -msdata=sysv option is incompatible with the -mrelocatable option.

-msdata=default
-msdata

On System V.4 and embedded PowerPC systems, if -meabi is used, compile code the same as -msdata=eabi, otherwise compile code the same as -msdata=sysv.

-msdata=data

On System V.4 and embedded PowerPC systems, put small global data in the .sdata section. Put small uninitialized global data in the .sbss section. Do not use register r13 to address small data however. This is the default behavior unless other -msdata options are used.

-G num

On embedded PowerPC systems, put global and static items less than or equal to num bytes into the small data or BSS sections instead of the normal data or BSS section. By default, num is 8. The -G num switch is also passed to the linker. All modules should be compiled with the same -G num value.