Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the significance of sbss2/sdata2?

I am working with PPC microcontroller (e200z4 specifically) using GCC based compiler. The PPC EABI support small data allocation if we define a variable whose size less than defined number (my case is 8). I understand that:

  • sdata is for small initialized data and it is modificable (will be located on RAM section).
  • sbss is the same as sdata that will be located on RAM, but it is for unitialized or zero variable.
  • these 2 section is access by only one instruction that is referenced by a 16bit signed offset + base register.

What I dont know is that the significance of sbss2 and sdata2, by reading the PPC EABI specification? Will they be small variables on RAM or Flash and if they are difference from sdata and sbss?

like image 516
Truong Tran Avatar asked Jan 19 '26 15:01

Truong Tran


2 Answers

From the EABI

External variables that are scalars of 8 or fewer bytes, whose values might be changed by the program, and whose values will not be changed outside of the program, shall be accessed as .sdata or .sbss entries...

When the object file is not to be part of a shared object file, external variables that are scalars of 8 or fewer bytes, whose values cannot be changed by the program, and whose values will not be changed outside of the program, shall be accessed as .sdata2 or .sbss2 entries...

The special section .sdata2 is intended to hold initialized read-only small data that contribute to the program memory image. The section can, however, be used to hold writable data. The special section .sbss2 is intended to hold writable small data that contribute to the program memory image and whose initial values are 0.

like image 100
Eraklon Avatar answered Jan 22 '26 17:01

Eraklon


My previous e200 projects were setup like that:

             ROM
         +----------+
         |          |
         | .text    | code
         |          |
   -     +----------+
   ^     |          |
   |     | .sdata2  | constant small initialized data (max 32k)
   |     |          |
max 64k  +----------+   <~~ _SDA2_BASE_ (r2)
   |     |          |
   |     | .sbss2   | constant small not (or zero) initialized data (max 32k)
   v     |          | ALWAYS EMPTY!
   -     +----------+

             RAM
         +----------+
         |          |
         | .data    | normal initialized data
         |          |
   -     +----------+
   ^     |          |
   |     | .sdata   | normal small initialized data (max 32k)
   |     |          |
max 64k  +----------+   <~~ _SDA_BASE_ (r13)
   |     |          |
   |     | .sbss    | normal small not (or zero) initialized data (max 32k)
   v     |          |
   -     +----------+
         |          |
         | .bss     | normal not (or zero) initialized data
         |          |
         +----------+
like image 27
sergej Avatar answered Jan 22 '26 19:01

sergej



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!