2

I am working on an STM8S microcontroller with the IAR Compiler.

How can I fix the start location for more then one variable using a pragma or another method?

When I try the below code, the compiler gives this error message:

Error[Lp025]: absolute section .near.bss (main.o #12) ([0x000100-0x000100]) overlaps with absolute section .near.bss (main.o #8) ([0x000100-0x000100])

I searched on IAR tech notes for "Absolute located variable" but I couldn't find any info.

#pragma location = 0x100   /* Start address of absolute location */

extern uint8_t        R0,
                      R1,
                      R2,
                      R3,
extern uint16_t       M1;           
extern uint8_t        M2,    
                      M3;    
wovano
  • 4,543
  • 5
  • 22
  • 49
mryldz
  • 95
  • 2
  • 9

1 Answers1

3

Use #pragma location = "my_abs" or _Pragma("location=\"my_abs\"") to place the variables you want in the absolute region in the same elf-section. Since #pragma location only applies to the following declaration you may want to create a define that you can prefix when declaring a variable in the absolute block. Note that only the _Pragma("location=\"my_abs\"") syntax is allowed in preprocessor macros.

#pragma section="my_abs"
#define IN_ABS _Pragma("location=\"my_abs\"")

IN_ABS char  R0, R1, R2, R3;
IN_ABS short M1;           
IN_ABS char  M2, M3;

int no_abs;

Then add a line to the linker configuration to put this section at the designated address.

place at address mem:0x100 { rw section my_abs };

Note that you can not mix initialized and uninitialized variables in the same section.

Johan
  • 3,667
  • 6
  • 20
  • 25