"Text Relocation" issue when calling asm function from c code.

cancel
Showing results for 
Search instead for 
Did you mean: 

"Text Relocation" issue when calling asm function from c code.

1,853 Views
simmisxu
Contributor III

Hi,

     I am now trying to write a assembly funciton which is called by c code. The platform is imx6 DL, and OS is based on android 4.4.2_r1 patch.

     The sample code is like this.

-------------------------------------

The asm code:

     .global asm_func

     .text

     .align

asm_func:

     ldr r1, =_VAR

     ldr r0, [r1]

     .data

_VAR: .word 10

-------------------------------------

The c code:

void main(void) {

     int ret;

     extern int asm_func();

     ret = asm_func();

     printf("Result of asm_func: %d.\n", ret);

     return.

}

--------------------------------------

     The program can be compiled and run. But when executing, there is warning msg "WARNING: linker: ./asm_test_imx has text relocations. This is wasting memory and is a security risk. Please fix."

     Do you know why the "text relocation" warning?

Thanks,

Simmis.

Labels (2)
Tags (1)
0 Kudos
3 Replies

56 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Simmis

seems this is well known error and well described on Android forums:

android - Warning: linker: app_process has text relocations. This is wasting memory and is a securit...

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

56 Views
simmisxu
Contributor III

No, Igor. I think your link is another Android issue.

In fact, in my sample code, if I remove the directive ".data", which means _VAR is in the same text section as asm_func. Then the warning disappears.

During my test, warning appears when asm lables are used like this:

_VAR: .word 10

_VAR1: word _VAR

No matter they are in seperate data section or in the same text section as asm_func.

Regards,

Simmis.


0 Kudos

56 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Simmis

I do not think that Android has different errors,

output is the same, probably you can check this with Linux.

Best regards

igor

0 Kudos