Using movw and movt to load a label address into a register in Arm 32 architecture. but this is not position independent code.
movw r1, #:lower16:ASM_NAME(forkx)movt r1, #:upper16:ASM_NAME(forkx)
As per the manual also it specifies that it will be resolved at the link time.
Need a position independent code, so as per the manual adr, adrl can be used, but getting below error:
../asm-arm/unix_arm.S:115:1: error: unsupported relocation on symboladr r1, __be_forkx
../asm-arm/unix_arm.S:60:1: error: invalid instruction, did you mean: adr?adrl r1, __be_forkx
it seems label can not be used in the aarch32, it is fine in aarch64 and works as intendent.
is the usage of adr command is improper? Is there a way to achieve this in aarch32? is there any equivalent command that can be used?
I am trying this, with this individual file compilation is fine. now have to check in a arm32 platform
in parallel started looking into the GCC compiler.
with gcc adrl command is also supported but for the same adr or adrl command getting the below error:
adrl r1, __be_forkx
error:
../asm-arm/unix_arm.S: Assembler messages:../asm-arm/unix_arm.S:61: Error: undefined symbol __be_forkx used as an immediate value
GLOBL_REF(__be_forkx)#.global __be_forkx
is added on top for global reference. is there anything going wrong?
DeepakHegde said:I am trying this, with this individual file compilation is fine. now have to check in a arm32 platform
In addition, does the binary also use a global offset table (GOT)? If so, it might be easier to just keep track of the location of got and patch its entries. If a GOT is present and is being used, it is likely that the address of the global/external symbol forkx is in one of its entries. There might be a different assembler syntax to refer to a got entry for a global.
DeepakHegde said:../asm-arm/unix_arm.S:61: Error: undefined symbol __be_forkx used as an immediate value
adr/l won't work with external symbols.