'Defining TOC & SDA in GNU-PPC Linker Script

Im using the GCC Compiler for Tricore and PPC since a while. On the PPC side, i didn't figured out until now, how i can define TOC & SDA addresses for the compiler to use to shorten the code.

Im adding code into some existing binary, which is using TOC 0x5C9FF0 (%R12) and SDA 0x7FFFF0 (%R13).

If im writing my code in the linker script it works perfectly fine if i am writing it in asm directly like this, to access an variable via SDA:

enter image description here

But in "normal" code like this:

enter image description here

It will load "epc_blink_timer", which is defined @0x806F10 (in reach of SDA), it will access it via an lis/lhz combination. This takes a lot of space, which i don't have, and also unnecessary CPU usage:

enter image description here

Is there any way to define TOC/SDA, or at least SDA somewhere in my linker files, and tell the compiler to use them?

I literally tried it since years, but don't had luck so far.

Br. Chris



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source