Question Details

No question body available.

Tags

c assembly linker avr32 avr32-gcc

Answers (1)

Accepted Answer Available
Accepted Answer
October 29, 2025 Score: 8 Rep: 72,702 Quality: Expert Completeness: 60%

you cannot use C-style bitwise operators (&, >>) on symbols like globalTest, because those are relocatable.

You must use GAS relocation modifiers that tell the assembler to take the low or high 16 bits of the address.

EDIT: tested and lo() hi() is the correct syntax

    mov  r8, lo(globalTest)
    orh  r8, hi(globalTest)

lo(globalTest) tells the assembler: Insert a relocation for the lower 16 bits of globalTest’s address.

hi(globalTest) tells it: Insert a relocation for the upper 16 bits of globalTest’s address.

The linker will then fix these correctly when the final address is known.

EDIT:

Compile using -Os -S

unsigned x;

void foo(void) { unsigned *volatile p = &x; }

and see the asembler output. I do not have avr32 toolchain but it can be lo16(globalTest) or lo(global_Test)