PowerPC assembler not recognizing undefined variable with @h annotation

516 views Asked by At

If I assemble the following PowerPC...

asm.as:

li r0, hello
nop

... I get an appropriate error message:

> powerpc-eabi-as -mregnames -mgekko ../asm.as -o asm.ob 
../asm.as: Assembler messages:
../asm.as:2: Error: unsupported relocation against hello

This is because hello is undefined. The error is desired behavior. However, if I use the @h (higher 16-bits) annotation, it will silently assemble and assume hello has value 0:

asm.as:

li r0, hello@h
nop

Commands used:

$ powerpc-eabi-as -mregnames -mgekko ../asm.as -o asm.ob 

$ powerpc-eabi-objcopy -O "binary" asm.ob asm 

$ rm asm.ob 

$ xxd -p asm 
3800000060000000

Why is this new code now accepted by the assembler when hello is still undefined? Is there a way to enable the error message again? I want to find out immediately if an undefined variable like this is used.

0

There are 0 answers