Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to export a function in GAS assembler?

Hi I have the following assembly code ,

.export __ls__11NSDOM_EncapFf
.text 
__ls__11NSDOM_EncapFf:
/* first load the symbolic constant*/
movq _IEEE_FP@GOTPCREL(%rip), %r8  /*%r8 is a scratch register*/
movq (%r8), %r9  /* %r9 and %r11 are scratch registers*/
movl (%r9), %r11d
/* second, see if it is zero and branch accordingly */
test %r11d, %r11d   /* zero call TNS procedure */
                    /* non-zero call IEEE procedure */
je  ____ls__11NSDOM_EncapFf_tns/* constant equals 0 */
jmp  ____ls__11NSDOM_EncapFf_ieee/* constant not equal to 0 */
ret

I compile the .s file to .o file(compilation is fine) , but when I link this .o with other .o files it is failing due to unresolved reference to _ls_11NSDOM_EncapFf. I am using GNU assembler 2.19.1 on HP Non stop system, X86-64 bit architecture. Please help me to resolve the issue.

like image 248
whitetiger Avatar asked Jan 13 '23 21:01

whitetiger


2 Answers

You'll need to set your symbol global for it to be externally linkable;

.text 
.global __ls__11NSDOM_EncapFf          /* Sets the symbol externally linkable */
__ls__11NSDOM_EncapFf:
/* first load the symbolic constant*/
...
like image 180
Joachim Isaksson Avatar answered Jan 15 '23 12:01

Joachim Isaksson


Use .global symbol or .globl symbol (see Using as - Assembler directives).

like image 26
Michael Avatar answered Jan 15 '23 11:01

Michael